direct-io.hg

changeset 12970:5a3fd0b7617d

[XEN][POWERPC] Fix IPI stall timeout without using timebase_freq
When using the register dump feature of Xen, one will sometimes see a
message about an IPI finish stall. This is because of an int to long
comparison bug, so fix it by doing proper nanosecond based time
accounting with no explicit reference to timebase_freq.
Signed-off-by: Amos Waterland <apw@us.ibm.com>
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Tue Nov 28 18:46:13 2006 -0500 (2006-11-28)
parents 4a27df713c66
children 6deca1ea217f
files xen/arch/powerpc/smp.c
line diff
     1.1 --- a/xen/arch/powerpc/smp.c	Tue Nov 28 17:01:00 2006 -0500
     1.2 +++ b/xen/arch/powerpc/smp.c	Tue Nov 28 18:46:13 2006 -0500
     1.3 @@ -90,7 +90,8 @@ int on_selected_cpus(
     1.4      int retry,
     1.5      int wait)
     1.6  {
     1.7 -    int t, retval = 0, nr_cpus = cpus_weight(selected);
     1.8 +    int retval = 0, nr_cpus = cpus_weight(selected);
     1.9 +    unsigned long start, stall = SECONDS(1);
    1.10  
    1.11      spin_lock(&call_lock);
    1.12  
    1.13 @@ -104,19 +105,21 @@ int on_selected_cpus(
    1.14      send_IPI_mask(selected, CALL_FUNCTION_VECTOR);
    1.15  
    1.16      /* We always wait for an initiation ACK from remote CPU.  */
    1.17 -    for (t = 0; atomic_read(&call_data.started) != nr_cpus; t++) {
    1.18 -        if (t && t % timebase_freq == 0) {
    1.19 +    for (start = NOW(); atomic_read(&call_data.started) != nr_cpus; ) {
    1.20 +        if (NOW() > start + stall) {
    1.21              printk("IPI start stall: %d ACKS to %d SYNS\n", 
    1.22                     atomic_read(&call_data.started), nr_cpus);
    1.23 +	    start = NOW();
    1.24          }
    1.25      }
    1.26  
    1.27      /* If told to, we wait for a completion ACK from remote CPU.  */
    1.28      if (wait) {
    1.29 -        for (t = 0; atomic_read(&call_data.finished) != nr_cpus; t++) {
    1.30 -            if (t > timebase_freq && t % timebase_freq == 0) {
    1.31 +        for (start = NOW(); atomic_read(&call_data.finished) != nr_cpus; ) {
    1.32 +            if (NOW() > start + stall) {
    1.33                  printk("IPI finish stall: %d ACKS to %d SYNS\n", 
    1.34                         atomic_read(&call_data.finished), nr_cpus);
    1.35 +                start = NOW();
    1.36              }
    1.37          }
    1.38      }
    1.39 @@ -168,6 +171,11 @@ void smp_message_recv(int msg, struct cp
    1.40  #ifdef DEBUG_IPI
    1.41  static void debug_ipi_ack(void *info)
    1.42  {
    1.43 +    if (info) {
    1.44 +	unsigned long start, stall = SECONDS(5);
    1.45 +	for (start = NOW(); NOW() < start + stall; );
    1.46 +	printk("IPI recv on cpu #%d: %s\n", smp_processor_id(), (char *)info);
    1.47 +    }
    1.48      return;
    1.49  }
    1.50  
    1.51 @@ -175,12 +183,12 @@ void ipi_torture_test(void)
    1.52  {
    1.53      int cpu;
    1.54      unsigned long before, after, delta;
    1.55 -    unsigned long min = ~0, max = 0, mean = 0, sum = 0, tick = 0;
    1.56 +    unsigned long min = ~0, max = 0, mean = 0, sum = 0, trials = 0;
    1.57      cpumask_t mask;
    1.58  
    1.59      cpus_clear(mask);
    1.60  
    1.61 -    while (tick < 1000000) {
    1.62 +    while (trials < 1000000) {
    1.63          for_each_online_cpu(cpu) {
    1.64              cpu_set(cpu, mask);
    1.65              before = mftb();
    1.66 @@ -192,12 +200,15 @@ void ipi_torture_test(void)
    1.67              if (delta > max) max = delta;
    1.68              if (delta < min) min = delta;
    1.69              sum += delta;
    1.70 -            tick++;
    1.71 +            trials++;
    1.72          }
    1.73      }
    1.74  
    1.75 -    mean = sum / tick;
    1.76 +    mean = tb_to_ns(sum / trials);
    1.77  
    1.78 -    printk("IPI tb ticks: min = %ld max = %ld mean = %ld\n", min, max, mean);
    1.79 +    printk("IPI latency: min = %ld ticks, max = %ld ticks, mean = %ldns\n",
    1.80 +	   min, max, mean);
    1.81 +
    1.82 +    smp_call_function(debug_ipi_ack, "Hi", 0, 1);
    1.83  }
    1.84  #endif