From: "Jan Beulich" Subject: RE: cpuidle causing Dom0 soft lockups Date: Fri, 05 Feb 2010 08:48:51 +0000 Message-ID: <4B6BE984020000780002DDF9@vpn.id2.novell.com> References: <4B58402E020000780002B3FE@vpn.id2.novell.com> <4B67E85E020000780002D1A0@vpn.id2.novell.com> <8B81FACE836F9248894A7844CC0BA814250B940CFF@shzsmsx501.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF0DADD63.2__=" Return-path: In-Reply-To: <8B81FACE836F9248894A7844CC0BA814250B940CFF@shzsmsx501.ccr.corp.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ke Yu Cc: Kevin Tian , "xen-devel@lists.xensource.com" , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartF0DADD63.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Yes, this patch works for us too. So a non-hacky version of it would be appreciated. I also meanwhile tried out the idea to reduce the contention on xtime_lock (attached for reference). Things appear to work fine, but there is an obvious problem (with - thus far to me - no obvious explanation) with it: The number of timer interrupts on CPUs not on duty to run do_timer() and alike is increasing significantly, with spikes of over 100,000 per second. I'm investigating this, but of course any idea anyone of you might have what could be causing this would be very welcome. Jan >>> "Yu, Ke" 03.02.10 08:32 >>> Hi Jan, Could you please try the attached patch. this patch try to avoid entering = deep C state when there is vCPU local irq disabled, and polling event = channel. When tested in my 64 CPU box, this issue is gone with this patch. Best Regards Ke --=__PartF0DADD63.2__= Content-Type: text/plain; name="xen-x86-xtime-lock.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-x86-xtime-lock.patch" From: jbeulich@novell.com=0ASubject: reduce contention on xtime_lock=0APatc= h-mainline: n/a=0AReferences: bnc#569014, bnc#571041, bnc#571769, = bnc#572146=0A=0AEspecially on large systems the number of CPUs queueing up = on=0Axtime_lock may become signficiant, and (as reported in the bugs = above)=0Amay even prevent proper operation of the system when Xen is = using=0Adeep C-states. There is, however, no need for all CPUs in the = system=0Ato update global time - it is sufficient to have a single (at any = given=0Apoint in time) CPU being responsible for this.=0A=0A--- sle11sp1-20= 10-02-02.orig/arch/x86/kernel/time-xen.c 2010-02-04 15:51:34.0000000= 00 +0100=0A+++ sle11sp1-2010-02-02/arch/x86/kernel/time-xen.c 2010-02-05 = 09:04:48.000000000 +0100=0A@@ -13,6 +13,7 @@=0A #include =0A #include =0A #include =0A+#include = =0A #include =0A #include =0A #include =0A@@ -122,6 +123,21 @@ static int = __init __permitted_clock_jitt=0A }=0A __setup("permitted_clock_jitter=3D", = __permitted_clock_jitter);=0A =0A+static unsigned int duty_cpu =3D = NR_CPUS;=0A+=0A+static int __cpuinit duty_cpu_callback(struct notifier_bloc= k *nb,=0A+ unsigned long action, void = *hcpu)=0A+{=0A+ if ((action & ~CPU_TASKS_FROZEN) =3D=3D CPU_DOWN_PREPARE=0A= + && duty_cpu =3D=3D (unsigned long)hcpu)=0A+ duty_cpu = =3D NR_CPUS;=0A+ return NOTIFY_DONE;=0A+}=0A+=0A+static struct = notifier_block __cpuinitdata duty_cpu_notifier =3D {=0A+ .notifier_c= all =3D duty_cpu_callback=0A+};=0A+=0A /*=0A * Scale a 64-bit delta by = scaling and multiplying by a 32-bit fraction,=0A * yielding a 64-bit = result.=0A@@ -415,6 +431,7 @@ static irqreturn_t timer_interrupt(int i=0A = s64 delta, delta_cpu, stolen, blocked;=0A unsigned int i, cpu =3D = smp_processor_id();=0A struct shadow_time_info *shadow =3D &per_cpu(shadow= _time, cpu);=0A+ bool duty =3D false;=0A struct vcpu_runstat= e_info runstate;=0A =0A /* Keep nmi watchdog up to date */=0A@@ = -427,7 +444,12 @@ static irqreturn_t timer_interrupt(int i=0A * the irq = version of write_lock because as just said we have irq=0A * locally = disabled. -arca=0A */=0A- write_seqlock(&xtime_lock);=0A+ if = (duty_cpu =3D=3D cpu=0A+ || (duty_cpu =3D=3D NR_CPUS=0A+ = && cmpxchg(&duty_cpu, NR_CPUS, cpu) =3D=3D NR_CPUS)) {=0A+ = duty =3D true;=0A+ write_seqlock(&xtime_lock);=0A+ }=0A =0A = do {=0A get_time_values_from_xen(cpu);=0A@@ -441,8 +463,7 = @@ static irqreturn_t timer_interrupt(int i=0A get_runstate_snapsh= ot(&runstate);=0A } while (!time_values_up_to_date());=0A =0A- if = ((unlikely(delta < -(s64)permitted_clock_jitter) ||=0A- unlikely(delta= _cpu < -(s64)permitted_clock_jitter))=0A+ if (duty && unlikely(delta = < -(s64)permitted_clock_jitter)=0A && printk_ratelimit()) {=0A = printk("Timer ISR/%u: Time went backwards: "=0A = "delta=3D%lld delta_cpu=3D%lld shadow=3D%lld "=0A@@ -454,27 +475,45 @@ = static irqreturn_t timer_interrupt(int i=0A for (i =3D 0; i < = num_online_cpus(); i++)=0A printk(" %d: %lld\n", = i,=0A per_cpu(processed_system_time, i));=0A+ } = else if (unlikely(delta_cpu < -(s64)permitted_clock_jitter)=0A+ = && printk_ratelimit()) {=0A+ if (!duty)=0A+ = write_seqlock(&xtime_lock);=0A+ printk("Timer ISR/%u: Time went = backwards: "=0A+ "delta=3D-%Lx shadow=3D%Lx = off=3D%Lx processed=3D%Lx/%Lx\n",=0A+ cpu, -delta_cpu, = shadow->system_timestamp,=0A+ get_nsec_offset(shadow), = processed_system_time,=0A+ per_cpu(processed_system_tim= e, cpu));=0A+ for_each_cpu_and(i, cpu_online_mask, cpumask_of(cpu= ))=0A+ printk(" %u: %Lx\n", i,=0A+ = per_cpu(processed_system_time, i));=0A+ if (!duty)=0A+ = write_sequnlock(&xtime_lock);=0A }=0A =0A- /* = System-wide jiffy work. */=0A- if (delta >=3D NS_PER_TICK) {=0A- = do_div(delta, NS_PER_TICK);=0A- processed_system_time +=3D delta * = NS_PER_TICK;=0A- while (delta > HZ) {=0A- = clobber_induction_variable(delta);=0A- do_timer(HZ);=0A- = delta -=3D HZ;=0A+ if (duty) {=0A+kstat_incr_irqs_this= _cpu(0, irq_to_desc(0));//temp=0A+ /* System-wide jiffy work. = */=0A+ if (delta >=3D NS_PER_TICK) {=0A+ = do_div(delta, NS_PER_TICK);=0A+ processed_system_time +=3D = delta * NS_PER_TICK;=0A+ while (delta > HZ) {=0A+ = clobber_induction_variable(delta);=0A+ = do_timer(HZ);=0A+ delta -=3D HZ;=0A+ = }=0A+ do_timer(delta);=0A = }=0A- do_timer(delta);=0A- }=0A =0A- if (shadow_tv_versi= on !=3D HYPERVISOR_shared_info->wc_version) {=0A- update_wall= clock();=0A- if (keventd_up())=0A- schedule_wo= rk(&clock_was_set_work);=0A- }=0A+ if (shadow_tv_version !=3D = HYPERVISOR_shared_info->wc_version) {=0A+ update_wall= clock();=0A+ if (keventd_up())=0A+ = schedule_work(&clock_was_set_work);=0A+ }=0A =0A- write_sequn= lock(&xtime_lock);=0A+ write_sequnlock(&xtime_lock);=0A+ = }=0A+else percpu_inc(mce_exception_count);//temp=0A =0A /*=0A * = Account stolen ticks.=0A@@ -692,6 +731,7 @@ static void __init setup_cpu0_t= imer_irq(=0A {=0A timer_irq =3D bind_virq_to_irqaction(VIRQ_TIMER, = 0, &timer_action);=0A BUG_ON(timer_irq < 0);=0A+ register_hotcpu_not= ifier(&duty_cpu_notifier);=0A }=0A =0A void __init time_init(void)=0A@@ = -765,6 +805,8 @@ static void stop_hz_timer(void)=0A unsigned long = j;=0A int rc;=0A =0A+ if (duty_cpu =3D=3D cpu)=0A+ duty_cpu = =3D NR_CPUS;=0A cpumask_set_cpu(cpu, nohz_cpu_mask);=0A =0A /* = See matching smp_mb in rcu_start_batch in rcupdate.c. These mbs */=0A --=__PartF0DADD63.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartF0DADD63.2__=--