Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly caused by netem)
Subsystems (10)
Quoted 8 lines · Andres Freund
Quoted 4 lines · Jarek Poplawski
On Thu, Jul 02, 2009 at 01:43:49PM +0200, Andres Freund wrote: ...
Quoted 2 lines
I will start trying to place the issue by testing with existing kernels between 2.6.30 and now.
If you can afford your time of course this would be very helpful.
Well. Waiting for the issue to resolve itself would cost time as well ;-) I wont be able to finish this today, but perhaps some reduction of the search space will be enough.
I lied.
Quoted 3 lines
I placed it between 2.6.30 and
03347e2592078a90df818670fddf97a33eec70fb(v2.6.30-5415-g03347e2) so far.
Ok. I finally see the light. I bisected the issue down to eea08f32adb3f97553d49a4f79a119833036000a : timers: Logic to move non pinned timers
Disabling timer migration like provided in the earlier commit stops the issue from occuring.
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using qdisc_watchdog...
Andres
Repasted original problem description for newly CC'ed people:
Quoted 27 lines
While playing around with netem (time, not packet count based loss- bursts) I experienced soft lockups several times - to exclude it was my modifications causing this I recompiled with the original and it is still locking up. I captured several of those traces via the thankfully still working netconsole. The simplest policy I could reproduce the error with was: tc qdisc add dev eth0 root handle 1:
netem delay 10ms loss 0I could not reproduce the error without delay - but that may only be a timing issue, as the host I was mainly transferring data to was on a local network. I could not reproduce the issue on lo.
The time to reproduce the error varied from seconds after executing tc to several minutes.
Traces 5+6 are made with vanilla
52989765629e7d182b4f146050ebba0abf2cb0b7The earlier traces are made with parts of my patches applied, and only included for completeness as I don't believe my modifications were causing this and all traces are different, so it may give some clues.
Lockdep was enabled but did not diagnose anything relevant (one dvb warning during bootup).
Any ideas for debugging?
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
On Fri, Jul 03, 2009 at 03:31:31AM +0200, Andres Freund wrote:
...
Quoted 10 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...
Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 10 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
On Fri, Jul 03, 2009 at 03:31:31AM +0200, Andres Freund wrote:
...Quoted 7 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
Quoted 6 lines
Quoted 3 lines
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-)
Does anybody of you have an idea where the problem actually resides? qdisc_watchdog_schedule looks innocent enough for my uneducated eyes - and the patch/infrastructure from Arun goes over my head...
I will happily test some ideas/patches.
Aside from that - is the whole PSCHED_TICKS2NS/PSCHED_NS2TICKS conversion business purely backward compatibility?
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 15 lines · Andres Freund
Quoted 14 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
On Fri, Jul 03, 2009 at 03:31:31AM +0200, Andres Freund wrote:
...Quoted 10 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...
Quoted 5 lines
Quoted 2 lines
Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-)
Does anybody of you have an idea where the problem actually resides?
Do you mean possibly broken timers are not enough?
Quoted 6 lines
qdisc_watchdog_schedulelooks innocent enough for my uneducated eyes - and the patch/infrastructure from Arun goes over my head...
I will happily test some ideas/patches.Aside from that - is the whole PSCHED_TICKS2NS/PSCHED_NS2TICKS conversion business purely backward compatibility?
The whole PSCHED_ conversion was to get finer resolution without breaking backward compatibility, I hope.;-)
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 12 lines · On Friday 03 July 2009 14:03:01 Jarek Poplawski wrote:
Quoted 11 lines · Andres Freund
Quoted 10 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
On Fri, Jul 03, 2009 at 03:31:31AM +0200, Andres Freund wrote:
...Quoted 7 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-) Does anybody of you have an idea where the problem actually resides?
Do you mean possibly broken timers are not enough?
I have no ideas how/if the timers are actually broken or if the problem does reside somewhere else and is just made visible by the timer changes.
I would have expected more problem with completely borked timers ;-)
Quoted 4 lines
Quoted 2 lines
Aside from that - is the whole PSCHED_TICKS2NS/PSCHED_NS2TICKS conversion business purely backward compatibility?
The whole
PSCHED_conversion was to get finer resolution without breaking backward compatibility, I hope.;-)
I haven't seen any problems - just curious ;-)
Andres
David Miller
maintainerRe: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Jarek PoplawskiFrom: Jarek Poplawski <[email protected]>
Date: Fri, 3 Jul 2009 12:03:01 +0000
Quoted 16 lines · Andres Freund
Quoted 15 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
Quoted 14 lines · Andres Freund
...
Quoted 10 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-)
Does anybody of you have an idea where the problem actually resides?
Do you mean possibly broken timers are not enough?
Well, if you look at that commit the bisect pointed to Jarek, it is a change which starts causing a situation which never happened before. Namely, timers added on one cpu can be migrated and fire on another.
So this could be exposing races in the networking that technically always existed.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 25 lines · David Miller
From: Jarek Poplawski <[email protected]>
Date: Fri, 3 Jul 2009 12:03:01 +0000Quoted 22 lines · Andres Freund
Quoted 20 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
Quoted 10 lines · Andres Freund
...
Quoted 7 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
Quoted 6 lines
Quoted 3 lines
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-)
Does anybody of you have an idea where the problem actually resides?
Quoted 8 lines
Quoted 1 line
Do you mean possibly broken timers are not enough?
Well, if you look at that commit the bisect pointed to Jarek, it is a change which starts causing a situation which never happened before. Namely, timers added on one cpu can be migrated and fire on another.
So this could be exposing races in the networking that technically always existed.
I'm not sure I get your point; could you give some example? Actually, I've suspected races in timers code.
Jarek P.
David Miller
maintainerRe: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
From: Jarek Poplawski <[email protected]>
Date: Sat, 4 Jul 2009 00:56:40 +0200
Quoted 10 lines · David Miller
Quoted 6 lines
Well, if you look at that commit the bisect pointed to Jarek, it is a change which starts causing a situation which never happened before. Namely, timers added on one cpu can be migrated and fire on another.
So this could be exposing races in the networking that technically always existed.
I'm not sure I get your point; could you give some example? Actually, I've suspected races in timers code.
Let's say that a particular networking timer always gets re-added on the cpu where the timer fires.
In that case, beforehand, no inter-cpu races could possibly be tested. But with the new timer code, such races could now be potentially triggered.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 14 lines · David Miller
From: Jarek Poplawski <[email protected]>
Date: Sat, 4 Jul 2009 00:56:40 +0200Quoted 10 lines · David Miller
Quoted 6 lines
Well, if you look at that commit the bisect pointed to Jarek, it is a change which starts causing a situation which never happened before. Namely, timers added on one cpu can be migrated and fire on another.
So this could be exposing races in the networking that technically always existed.
I'm not sure I get your point; could you give some example? Actually, I've suspected races in timers code.
Quoted 6 lines
Let's say that a particular networking timer always gets re-added on the cpu where the timer fires.
In that case, beforehand, no inter-cpu races could possibly be tested. But with the new timer code, such races could now be potentially triggered.
Maybe I still miss something, but even if it were possible, lockdep should have reported such things long ago.
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Andres FreundAndres Freund wrote, On 07/03/2009 01:26 PM:
Quoted 14 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
Quoted 13 lines · Andres Freund
...
Quoted 10 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...
Quoted 8 lines
Quoted 2 lines
Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-)
Does anybody of you have an idea where the problem actually resides?
qdisc_watchdog_schedulelooks innocent enough for my uneducated eyes - and the patch/infrastructure from Arun goes over my head...
I will happily test some ideas/patches.
Since there are still no 100% proofs nor suspects, here are some suggestions of additional checking. This bisected commit could probably be additionally verified by applying to 2.6.30 with a preceding one; I attach both of them below.
Another suggestion is to try this without lockdep e.g. by setting /sys/module/lockdep/parameters/lock_stat and prove_locking to 0.
Thanks,
Jarek P.
--------------->
commit 597d0275736dad9c3bda6f0a00a1c477dc0f37b1
Author: Arun R Bharadwaj <[email protected]> Date: Thu Apr 16 12:13:26 2009 +0530
timers: Framework for identifying pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch creates a new framework for identifying cpu-pinned timers and hrtimers.
This framework is needed because pinned timers are expected to fire on the same CPU on which they are queued. So it is essential to identify these and not migrate them, in case there are any.
For regular timers, the currently existing add_timer_on() can be used queue pinned timers and subsequently mod_timer_pinned() can be used to modify the 'expires' field.
For hrtimers, new modes HRTIMER_ABS_PINNED and HRTIMER_REL_PINNED are added to queue cpu-pinned hrtimer.
[ tglx: use .._PINNED mode argument instead of creating tons of new functions ]
include/linux/hrtimer.h +5 -2
@@ -30,8 +30,11 @@ struct hrtimer_cpu_base;* Mode arguments of xxx_hrtimer functions: */ enum hrtimer_mode { -HRTIMER_MODE_ABS ,/* Time value is absolute */ -HRTIMER_MODE_REL ,/* Time value is relative to now */ +HRTIMER_MODE_ABS =0x0 ,/* Time value is absolute */ +HRTIMER_MODE_REL =0x1 ,/* Time value is relative to now */ +HRTIMER_MODE_PINNED =0x02 ,/* Timer is bound to CPU */ +HRTIMER_MODE_ABS_PINNED =0x02 , +HRTIMER_MODE_REL_PINNED =0x03 , };/*
include/linux/timer.h +3 -0
@@ -163,7 +163,10 @@ extern void add_timer_on(struct timer_list *timer, int cpu);extern int del_timer (struct timer_list * timer);extern int mod_timer (struct timer_list *timer,unsigned long expires);extern int mod_timer_pending (struct timer_list *timer,unsigned long expires); +extern int mod_timer_pinned (struct timer_list *timer,unsigned long expires); +#define TIMER_NOT_PINNED 0 +#define TIMER_PINNED 1/* * The jiffies value which is added to now, when there is no timer * in the timer wheel:
kernel/hrtimer.c +4 -3
@@ -193,7 +193,8 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,* Switch the timer base to the current CPU when possible. */ static inline struct hrtimer_clock_base * -switch_hrtimer_base (struct hrtimer *timer,struct hrtimer_clock_base *base) +switch_hrtimer_base (struct hrtimer *timer,struct hrtimer_clock_base *base, +int pinned) {struct hrtimer_clock_base *new_base;struct hrtimer_cpu_base *new_cpu_base;
@@ -907,9 +908,9 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, ret =remove_hrtimer (timer, base);/* Switch the timer base, if necessary: */ - new_base =switch_hrtimer_base (timer, base); + new_base =switch_hrtimer_base (timer, base, mode &HRTIMER_MODE_PINNED ); -if (mode ==HRTIMER_MODE_REL ) { +if (mode &HRTIMER_MODE_REL ) { tim =ktime_add_safe (tim, new_base->get_time ());/* * CONFIG_TIME_LOW_RES is a temporary way for architectures
kernel/timer.c +27 -4
@@ -604,7 +604,8 @@ static struct tvec_base *lock_timer_base(struct timer_list *timer, }static inline int -__mod_timer (struct timer_list *timer,unsigned long expires,bool pending_only) +__mod_timer (struct timer_list *timer,unsigned long expires, +bool pending_only,int pinned) {struct tvec_base *base, *new_base;unsigned long flags;
@@ -668,7 +669,7 @@ out_unlock:*/ int mod_timer_pending (struct timer_list *timer,unsigned long expires) { -return __mod_timer (timer, expires, true); +return __mod_timer (timer, expires, true,TIMER_NOT_PINNED ); }EXPORT_SYMBOL (mod_timer_pending);
@@ -702,11 +703,33 @@ int mod_timer(struct timer_list *timer, unsigned long expires)if (timer->expires == expires &&timer_pending (timer))return 1 ; -return __mod_timer (timer, expires, false); +return __mod_timer (timer, expires, false,TIMER_NOT_PINNED ); }EXPORT_SYMBOL (mod_timer);/** +* mod_timer_pinned - modify a timer's timeout +* @timer: the timer to be modified +* @expires: new timeout in jiffies +* +* mod_timer_pinned() is a way to update the expire field of an +* active timer (if the timer is inactive it will be activated) +* and not allow the timer to be migrated to a different CPU. +* +* mod_timer_pinned(timer, expires) is equivalent to: +* +* del_timer(timer); timer->expires = expires; add_timer(timer); +*/ +int mod_timer_pinned (struct timer_list *timer,unsigned long expires) +{ +if (timer->expires == expires &&timer_pending (timer)) +return 1 ; + +return __mod_timer (timer, expires, false,TIMER_PINNED ); +} +EXPORT_SYMBOL (mod_timer_pinned); + +/** * add_timer - start a timer * @timer: the timer to be added *
@@ -1356,7 +1379,7 @@ signed long __sched schedule_timeout(signed long timeout) expire = timeout + jiffies;setup_timer_on_stack (&timer, process_timeout, (unsigned long )current); -__mod_timer (&timer, expire, false); +__mod_timer (&timer, expire, false,TIMER_NOT_PINNED );schedule ();del_singleshot_timer_sync (&timer);
commit eea08f32adb3f97553d49a4f79a119833036000a
Author: Arun R Bharadwaj <[email protected]> Date: Thu Apr 16 12:16:41 2009 +0530
timers: Logic to move non pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch migrates all non pinned timers and hrtimers to the current idle load balancer, from all the idle CPUs. Timers firing on busy CPUs are not migrated.
While migrating hrtimers, care should be taken to check if migrating a hrtimer would result in a latency or not. So we compare the expiry of the hrtimer with the next timer interrupt on the target cpu and migrate the hrtimer only if it expires *after* the next interrupt on the target cpu. So, added a clockevents_get_next_event() helper function to return the next_event on the target cpu's clock_event_device.
[ tglx: cleanups and simplifications ]
include/linux/clockchips.h +9 -0
@@ -143,3 +143,12 @@ extern void clockevents_notify(unsigned long reason, void *arg);#endif #endif + +#ifdef CONFIG_GENERIC_CLOCKEVENTS +extern ktime_t clockevents_get_next_event (int cpu); +#else +static inline ktime_t clockevents_get_next_event (int cpu) +{ +return (ktime_t ) { .tv64 =KTIME_MAX }; +} +#endif
include/linux/sched.h +12 -0
@@ -257,6 +257,7 @@ extern void task_rq_unlock_wait(struct task_struct *p);extern cpumask_var_t nohz_cpu_mask;#if defined(CONFIG_SMP ) && defined(CONFIG_NO_HZ )extern int select_nohz_load_balancer (int cpu); +extern int get_nohz_load_balancer (void );#else static inline int select_nohz_load_balancer (int cpu) {
@@ -1772,6 +1773,17 @@ int sched_nr_latency_handler(struct ctl_table *table, int write, struct file *file, void __user *buffer, size_t *length, loff_t *ppos);#endif +#ifdef CONFIG_SCHED_DEBUG +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return sysctl_timer_migration; +} +#else +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return 1 ; +} +#endif extern unsigned int sysctl_sched_rt_period;extern int sysctl_sched_rt_runtime;
kernel/hrtimer.c +49 -2
76 lines not on this page · raw message
kernel/sched.c +5 -0
@@ -4244,6 +4244,11 @@ static struct { .load_balancer = ATOMIC_INIT(-1), }; +int get_nohz_load_balancer (void ) +{ +return atomic_read (&nohz.load_balancer); +} +/* * This routine will try to nominate the ilb (idle load balancing) * owner among the cpus whose ticks are stopped. ilb owner will do the idle
kernel/time/clockevents.c +12 -0
@@ -18,6 +18,7 @@#include <linux/notifier.h> #include <linux/smp.h> #include <linux/sysdev.h> +#include <linux/tick.h> /* The registered clock event devices */ static LIST_HEAD (clockevent_devices);
@@ -251,4 +252,15 @@ void clockevents_notify(unsigned long reason, void *arg) spin_unlock(&clockevents_lock); }EXPORT_SYMBOL_GPL (clockevents_notify); + +ktime_t clockevents_get_next_event (int cpu) +{ +struct tick_device *td; +struct clock_event_device *dev; + + td = &per_cpu (tick_cpu_device, cpu); + dev = td->evtdev; + +return dev->next_event; +}#endif
kernel/timer.c +14 -3
@@ -37,6 +37,7 @@#include <linux/delay.h> #include <linux/tick.h> #include <linux/kallsyms.h> +#include <linux/sched.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -609,9 +610,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, {struct tvec_base *base, *new_base;unsigned long flags; -int ret; - - ret =0 ; +int ret =0 , cpu;timer_stats_timer_set_start_info (timer);BUG_ON (!timer->function);
@@ -630,6 +629,18 @@ __mod_timer(struct timer_list *timer, unsigned long expires, new_base =__get_cpu_var (tvec_bases); + cpu =smp_processor_id (); + +#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +if (!pinned &&get_sysctl_timer_migration () &&idle_cpu (cpu)) { +int preferred_cpu =get_nohz_load_balancer (); + +if (preferred_cpu >=0 ) + cpu = preferred_cpu; + } +#endif + new_base =per_cpu (tvec_bases, cpu); +if (base != new_base) {/* * We are trying to schedule the timer on the local CPU.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Hello
System freezes immediatly after grub, no init processing at all, after applying those patches on top of vanilla 2.6.30 on my box.
Also, 2nd patch, this piece:
+#ifdef CONFIG_SCHED_DEBUG
+static inline unsigned int get_sysctl_timer_migration(void) +{
+ return sysctl_timer_migration;
+}
+#else
+static inline unsigned int get_sysctl_timer_migration(void) +{
+ return 1;
+}
+#endif
doesnt work on top of 2.6.30. It complains, while compiling, that sysctl_timer_migration is not defined. So i just replaced that call with return 1, like on the not debug case. Hope this doesnt defeat your test case, but it wouldnt compile otherwise. Probably that was just introduced after 2.6.30?
(Have also tried latest .31-rc2, original bug still exists.)
Thank you for your time,
Joao Correia
Centro de Informatica
Universidade da Beira Interior
Portugal
Quoted 434 lines · Jarek Poplawski
Andres Freund wrote, On 07/03/2009 01:26 PM:
Quoted 14 lines · On Friday 03 July 2009 08:12:13 Jarek Poplawski wrote:
Quoted 13 lines · Andres Freund
...
Quoted 10 lines
Ok. I finally see the light. I bisected the issue down to
eea08f32adb3f97553d49a4f79a119833036000a: timers: Logic to move non pinned timersDisabling timer migration like provided in the earlier commit stops the issue from occuring.
That it is related to timers is sensible in the light of my findings, that I could trigger the issue only when using delay in netem - that is the codepath using
qdisc_watchdog...Quoted 8 lines
Quoted 2 lines
Andres, thanks for your work and time. It saved me a lot of searching, because I wasn't able to trigger this on my old box.
Thanks. It allowed me to go through some of my remaining paperwork ;-)
Does anybody of you have an idea where the problem actually resides?
qdisc_watchdog_schedulelooks innocent enough for my uneducated eyes - and the patch/infrastructure from Arun goes over my head...
I will happily test some ideas/patches.Since there are still no 100% proofs nor suspects, here are some suggestions of additional checking. This bisected commit could probably be additionally verified by applying to 2.6.30 with a preceding one; I attach both of them below.
Another suggestion is to try this without lockdep e.g. by setting
/sys/module/lockdep/parameters/lock_statandprove_lockingto 0.Thanks,
Jarek P.--------------->
commit597d0275736dad9c3bda6f0a00a1c477dc0f37b1
Author: Arun R Bharadwaj <[email protected]>
Date: Thu Apr 16 12:13:26 2009 +0530timers: Framework for identifying pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch creates a new framework for identifying cpu-pinned timers and hrtimers.
This framework is needed because pinned timers are expected to fire on the same CPU on which they are queued. So it is essential to identify these and not migrate them, in case there are any.
For regular timers, the currently existing
add_timer_on()can be used queue pinned timers and subsequentlymod_timer_pinned()can be used to modify the 'expires' field.For hrtimers, new modes
HRTIMER_ABS_PINNEDandHRTIMER_REL_PINNEDare added to queue cpu-pinned hrtimer.[ tglx: use .._PINNED mode argument instead of creating tons of new functions ]
Signed-off-by Arun R Bharadwaj <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>include/linux/hrtimer.h +5
-2@@ -30,8 +30,11 @@ struct hrtimer_cpu_base;* Mode arguments of xxx_hrtimer functions: */ enum hrtimer_mode { - HRTIMER_MODE_ABS, /* Time value is absolute */ - HRTIMER_MODE_REL, /* Time value is relative to now */ + HRTIMER_MODE_ABS = 0x0, /* Time value is absolute */ + HRTIMER_MODE_REL = 0x1, /* Time value is relative to now */ + HRTIMER_MODE_PINNED = 0x02, /* Timer is bound to CPU */ + HRTIMER_MODE_ABS_PINNED = 0x02, + HRTIMER_MODE_REL_PINNED = 0x03, }; /*include/linux/timer.h +3
-0@@ -163,7 +163,10 @@ extern void add_timer_on(struct timer_list *timer, int cpu); extern int del_timer(struct timer_list * timer); extern int mod_timer(struct timer_list *timer, unsigned long expires); extern int mod_timer_pending(struct timer_list *timer, unsigned long expires); +extern int mod_timer_pinned (struct timer_list *timer,unsigned long expires); +#define TIMER_NOT_PINNED 0 +#define TIMER_PINNED 1 /** The jiffies value which is added to now, when there is no timer * in the timer wheel: kernel/hrtimer.c +0
-0@@ -193,7 +193,8 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,* Switch the timer base to the current CPU when possible. */ static inline struct
hrtimer_clock_base*kernel/hrtimer.c +2
-1-switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base) +switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, + int pinned){
structhrtimer_clock_base*new_base;
structhrtimer_cpu_base*new_cpu_base;kernel/hrtimer.c +2
-2@@ -907,9 +908,9 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, ret = remove_hrtimer(timer, base); /* Switch the timer base, if necessary: */ - new_base = switch_hrtimer_base(timer, base); + new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); - if (mode == HRTIMER_MODE_REL) { + if (mode & HRTIMER_MODE_REL) { tim = ktime_add_safe(tim, new_base->get_time()); /** CONFIG_TIME_LOW_RES is a temporary way for architectures kernel/timer.c +0
-0@@ -604,7 +604,8 @@ static struct tvec_base *lock_timer_base(struct timer_list *timer, }static inline int
kernel/timer.c +2
-1-__mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only) +__mod_timer(struct timer_list *timer, unsigned long expires, + bool pending_only, int pinned){
structtvec_base*base,*new_base;
unsigned long flags;kernel/timer.c +25
-3@@ -668,7 +669,7 @@ out_unlock:*/ int mod_timer_pending(struct timer_list *timer, unsigned long expires) { - return __mod_timer(timer, expires, true); + return __mod_timer(timer, expires, true, TIMER_NOT_PINNED); } EXPORT_SYMBOL(mod_timer_pending);@@ -702,11 +703,33 @@ int mod_timer(struct timer_list *timer, unsigned long expires) if (timer->expires == expires && timer_pending(timer)) return 1; - return __mod_timer(timer, expires, false); + return __mod_timer(timer, expires, false, TIMER_NOT_PINNED); } EXPORT_SYMBOL(mod_timer); /** +* mod_timer_pinned - modify a timer's timeout +* @timer: the timer to be modified +* @expires: new timeout in jiffies +* +* mod_timer_pinned() is a way to update the expire field of an +* active timer (if the timer is inactive it will be activated) +* and not allow the timer to be migrated to a different CPU. +* +* mod_timer_pinned(timer, expires) is equivalent to: +* +* del_timer(timer); timer->expires = expires; add_timer(timer); +*/ +int mod_timer_pinned (struct timer_list *timer,unsigned long expires) +{ + if (timer->expires == expires && timer_pending(timer)) + return 1; + + return __mod_timer(timer, expires, false, TIMER_PINNED); +} +EXPORT_SYMBOL (mod_timer_pinned); + +/** * add_timer - start a timer * @timer: the timer to be added * @@ -1356,7 +1379,7 @@ signed long __sched schedule_timeout(signed long timeout) expire = timeout + jiffies; setup_timer_on_stack(&timer, process_timeout, (unsigned long)current); - __mod_timer(&timer, expire, false); + __mod_timer(&timer, expire, false, TIMER_NOT_PINNED); schedule(); del_singleshot_timer_sync(&timer);commit
eea08f32adb3f97553d49a4f79a119833036000a
Author: Arun R Bharadwaj <[email protected]>
Date: Thu Apr 16 12:16:41 2009 +0530timers: Logic to move non pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch migrates all non pinned timers and hrtimers to the current idle load balancer, from all the idle CPUs. Timers firing on busy CPUs are not migrated.
While migrating hrtimers, care should be taken to check if migrating a hrtimer would result in a latency or not. So we compare the expiry of the hrtimer with the next timer interrupt on the target cpu and migrate the hrtimer only if it expires *after* the next interrupt on the target cpu. So, added a
clockevents_get_next_event()helper function to return thenext_eventon the target cpu'sclock_event_device.[ tglx: cleanups and simplifications ]
Signed-off-by Arun R Bharadwaj <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>include/linux/clockchips.h +9
-0@@ -143,3 +143,12 @@ extern void clockevents_notify(unsigned long reason, void *arg); #endif #endif + +#ifdef CONFIG_GENERIC_CLOCKEVENTS +extern ktime_t clockevents_get_next_event (int cpu); +#else +static inline ktime_t clockevents_get_next_event (int cpu) +{ + return (ktime_t) { .tv64 = KTIME_MAX }; +} +#endif include/linux/sched.h +12
-0@@ -257,6 +257,7 @@ extern void task_rq_unlock_wait(struct task_struct *p); extern cpumask_var_t nohz_cpu_mask; #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ) extern int select_nohz_load_balancer(int cpu); +extern int get_nohz_load_balancer (void ); #else static inline int select_nohz_load_balancer(int cpu) {@@ -1772,6 +1773,17 @@ int sched_nr_latency_handler(struct ctl_table *table, int write, struct file *file, void __user *buffer, size_t *length, loff_t *ppos); #endif +#ifdef CONFIG_SCHED_DEBUG +static inline unsigned int get_sysctl_timer_migration (void ) +{ + return sysctl_timer_migration; +} +#else +static inline unsigned int get_sysctl_timer_migration (void ) +{ + return 1; +} +#endif extern unsigned int sysctl_sched_rt_period; extern int sysctl_sched_rt_runtime;kernel/hrtimer.c +49
-2@@ -43,6 +43,8 @@ #include <linux/seq_file.h> #include <linux/err.h> #include <linux/debugobjects.h> +#include <linux/sched.h> +#include <linux/timer.h> #include <asm/uaccess.h>@@ -198,8 +200,19 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, { struct hrtimer_clock_base *new_base; struct hrtimer_cpu_base *new_cpu_base; + int cpu, preferred_cpu = -1; + + cpu = smp_processor_id(); +#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) + if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) { + preferred_cpu = get_nohz_load_balancer(); + if (preferred_cpu >= 0) + cpu = preferred_cpu; + } +#endif - new_cpu_base = &__get_cpu_var(hrtimer_bases); +again: + new_cpu_base = &per_cpu(hrtimer_bases, cpu); new_base = &new_cpu_base->clock_base[base->index]; if (base != new_base) {@@ -219,6 +232,40 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, timer->base = NULL; spin_unlock(&base->cpu_base->lock); spin_lock(&new_base->cpu_base->lock); + + /* Optimized away for NOHZ=n SMP=n */ + if (cpu == preferred_cpu) { + /* Calculate clock monotonic expiry time */ +#ifdef CONFIG_HIGH_RES_TIMERS + ktime_t expires = ktime_sub(hrtimer_get_expires(timer), + new_base->offset); +#else + ktime_t expires = hrtimer_get_expires(timer); +#endif + + /* + * Get the next event on target cpu from the + * clock events layer. + * This covers the highres=off nohz=on case as well. + */ + ktime_t next = clockevents_get_next_event(cpu); + + ktime_t delta = ktime_sub(expires, next); + + /* + * We do not migrate the timer when it is expiring + * before the next event on the target cpu because + * we cannot reprogram the target cpu hardware and + * we would cause it to fire late. + */ + if (delta.tv64 < 0) { + cpu = smp_processor_id(); + spin_unlock(&new_base->cpu_base->lock); + spin_lock(&base->cpu_base->lock); + timer->base = base; + goto again; + } + } timer->base = new_base; } return new_base;@@ -236,7 +283,7 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) return base; } -# define switch_hrtimer_base (t, b) (b) +# define switch_hrtimer_base (t, b, p) (b) #endif /* !CONFIG_SMP */kernel/sched.c +5
-0@@ -4244,6 +4244,11 @@ static struct { .load_balancer = ATOMIC_INIT(-1), }; +int get_nohz_load_balancer (void ) +{ + return atomic_read(&nohz.load_balancer); +} + /** This routine will try to nominate the ilb (idle load balancing) * owner among the cpus whose ticks are stopped. ilb owner will do the idle kernel/time/clockevents.c +12
-0@@ -18,6 +18,7 @@ #include <linux/notifier.h> #include <linux/smp.h> #include <linux/sysdev.h> +#include <linux/tick.h> /* The registered clock event devices */ static LIST_HEAD(clockevent_devices);@@ -251,4 +252,15 @@ void clockevents_notify(unsigned long reason, void *arg) spin_unlock(&clockevents_lock); } EXPORT_SYMBOL_GPL(clockevents_notify); + +ktime_t clockevents_get_next_event (int cpu) +{ + struct tick_device *td; + struct clock_event_device *dev; + + td = &per_cpu(tick_cpu_device, cpu); + dev = td->evtdev; + + return dev->next_event; +} #endifkernel/timer.c +14
-3@@ -37,6 +37,7 @@ #include <linux/delay.h> #include <linux/tick.h> #include <linux/kallsyms.h> +#include <linux/sched.h> #include <asm/uaccess.h> #include <asm/unistd.h>@@ -609,9 +610,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, { struct tvec_base *base, *new_base; unsigned long flags; - int ret; - - ret = 0; + int ret = 0 , cpu; timer_stats_timer_set_start_info(timer); BUG_ON(!timer->function);@@ -630,6 +629,18 @@ __mod_timer(struct timer_list *timer, unsigned long expires, new_base = __get_cpu_var(tvec_bases); + cpu = smp_processor_id(); + +#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) + if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) { + int preferred_cpu = get_nohz_load_balancer(); + + if (preferred_cpu >= 0) + cpu = preferred_cpu; + } +#endif + new_base = per_cpu(tvec_bases, cpu); + if (base != new_base) { /** We are trying to schedule the timer on the local CPU.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 1 line · Joao Correia
Hello
Hi,
Quoted 17 lines
System freezes immediatly after grub, no init processing at all, after applying those patches on top of vanilla 2.6.30 on my box.
Also, 2nd patch, this piece:
include/linux/sched.h +11
-0+#ifdef CONFIG_SCHED_DEBUG +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return sysctl_timer_migration; +} +#else +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return 1 ; +} +#endif
Quoted 5 lines
doesnt work on top of 2.6.30. It complains, while compiling, that
sysctl_timer_migrationis not defined. So i just replaced that call with return 1, like on the not debug case. Hope this doesnt defeat your test case, but it wouldnt compile otherwise. Probably that was just introduced after 2.6.30?
Yes, it would be too easy if it had worked just like this... (I only test-compiled it, without such warnings, but without CONFIG_SCHED_DEBUG.) I'll look at this again.
Quoted 2 lines
(Have also tried latest .31-rc2, original bug still exists.)
Btw., could you send your .config? Do you have lockdep enabled (if so did you try without it)? Is it 'a real' box or something virtual?
Thanks,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Hello
.config is attached. This is a real box, a fedora 11 with rawhide updates applied. Its a quad core system (amd phenom 9600) with 4gb ddr2 ram. The board is an asus m3a-h/hdmi. We have a couple of these boxes just to test run linux before dropping into production, hence the availability for tests.
Haven't tried without lockdep, will try later and let you know if any difference.
Thank you for your time,
Joao Correia
Centro de Informatica
Universidade da Beira Interior
Portugal
Quoted 40 lines · Jarek Poplawski
Quoted 1 line · Joao Correia
Hello
Hi,
Quoted 17 lines
System freezes immediatly after grub, no init processing at all, after applying those patches on top of vanilla 2.6.30 on my box.
Also, 2nd patch, this piece:
include/linux/sched.h +11
-0+#ifdef CONFIG_SCHED_DEBUG +static inline unsigned int get_sysctl_timer_migration (void ) +{ + return sysctl_timer_migration; +} +#else +static inline unsigned int get_sysctl_timer_migration (void ) +{ + return 1; +} +#endif Quoted 5 lines
doesnt work on top of 2.6.30. It complains, while compiling, that
sysctl_timer_migrationis not defined. So i just replaced that call with return 1, like on the not debug case. Hope this doesnt defeat your test case, but it wouldnt compile otherwise. Probably that was just introduced after 2.6.30?Yes, it would be too easy if it had worked just like this... (I only test-compiled it, without such warnings, but without
CONFIG_SCHED_DEBUG.) I'll look at this again.Quoted 2 lines
(Have also tried latest .31-rc2, original bug still exists.)
Btw., could you send your .config? Do you have lockdep enabled (if so did you try without it)? Is it 'a real' box or something virtual?
Thanks,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Joao CorreiaQuoted 4 lines · Joao Correia
Hello
System freezes immediatly after grub, no init processing at all, after applying those patches on top of vanilla 2.6.30 on my box.
...
Quoted 5 lines
doesnt work on top of 2.6.30. It complains, while compiling, that
sysctl_timer_migrationis not defined. So i just replaced that call with return 1, like on the not debug case. Hope this doesnt defeat your test case, but it wouldnt compile otherwise. Probably that was just introduced after 2.6.30?
Yes, my bad, sorry. I've found 2 more patches from this series; can't guarantee that's all, but seems to work & migrate within my one and only core without any problems ;-)
Jarek P.
commit 597d0275736dad9c3bda6f0a00a1c477dc0f37b1
Author: Arun R Bharadwaj <[email protected]> Date: Thu Apr 16 12:13:26 2009 +0530
timers: Framework for identifying pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch creates a new framework for identifying cpu-pinned timers and hrtimers.
This framework is needed because pinned timers are expected to fire on the same CPU on which they are queued. So it is essential to identify these and not migrate them, in case there are any.
For regular timers, the currently existing add_timer_on() can be used queue pinned timers and subsequently mod_timer_pinned() can be used to modify the 'expires' field.
For hrtimers, new modes HRTIMER_ABS_PINNED and HRTIMER_REL_PINNED are added to queue cpu-pinned hrtimer.
[ tglx: use .._PINNED mode argument instead of creating tons of new functions ]
include/linux/hrtimer.h +5 -2
@@ -30,8 +30,11 @@ struct hrtimer_cpu_base;* Mode arguments of xxx_hrtimer functions: */ enum hrtimer_mode { -HRTIMER_MODE_ABS ,/* Time value is absolute */ -HRTIMER_MODE_REL ,/* Time value is relative to now */ +HRTIMER_MODE_ABS =0x0 ,/* Time value is absolute */ +HRTIMER_MODE_REL =0x1 ,/* Time value is relative to now */ +HRTIMER_MODE_PINNED =0x02 ,/* Timer is bound to CPU */ +HRTIMER_MODE_ABS_PINNED =0x02 , +HRTIMER_MODE_REL_PINNED =0x03 , };/*
include/linux/timer.h +3 -0
@@ -163,7 +163,10 @@ extern void add_timer_on(struct timer_list *timer, int cpu);extern int del_timer (struct timer_list * timer);extern int mod_timer (struct timer_list *timer,unsigned long expires);extern int mod_timer_pending (struct timer_list *timer,unsigned long expires); +extern int mod_timer_pinned (struct timer_list *timer,unsigned long expires); +#define TIMER_NOT_PINNED 0 +#define TIMER_PINNED 1/* * The jiffies value which is added to now, when there is no timer * in the timer wheel:
kernel/hrtimer.c +4 -3
@@ -193,7 +193,8 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,* Switch the timer base to the current CPU when possible. */ static inline struct hrtimer_clock_base * -switch_hrtimer_base (struct hrtimer *timer,struct hrtimer_clock_base *base) +switch_hrtimer_base (struct hrtimer *timer,struct hrtimer_clock_base *base, +int pinned) {struct hrtimer_clock_base *new_base;struct hrtimer_cpu_base *new_cpu_base;
@@ -907,9 +908,9 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, ret =remove_hrtimer (timer, base);/* Switch the timer base, if necessary: */ - new_base =switch_hrtimer_base (timer, base); + new_base =switch_hrtimer_base (timer, base, mode &HRTIMER_MODE_PINNED ); -if (mode ==HRTIMER_MODE_REL ) { +if (mode &HRTIMER_MODE_REL ) { tim =ktime_add_safe (tim, new_base->get_time ());/* * CONFIG_TIME_LOW_RES is a temporary way for architectures
kernel/timer.c +27 -4
@@ -604,7 +604,8 @@ static struct tvec_base *lock_timer_base(struct timer_list *timer, }static inline int -__mod_timer (struct timer_list *timer,unsigned long expires,bool pending_only) +__mod_timer (struct timer_list *timer,unsigned long expires, +bool pending_only,int pinned) {struct tvec_base *base, *new_base;unsigned long flags;
@@ -668,7 +669,7 @@ out_unlock:*/ int mod_timer_pending (struct timer_list *timer,unsigned long expires) { -return __mod_timer (timer, expires, true); +return __mod_timer (timer, expires, true,TIMER_NOT_PINNED ); }EXPORT_SYMBOL (mod_timer_pending);
@@ -702,11 +703,33 @@ int mod_timer(struct timer_list *timer, unsigned long expires)if (timer->expires == expires &&timer_pending (timer))return 1 ; -return __mod_timer (timer, expires, false); +return __mod_timer (timer, expires, false,TIMER_NOT_PINNED ); }EXPORT_SYMBOL (mod_timer);/** +* mod_timer_pinned - modify a timer's timeout +* @timer: the timer to be modified +* @expires: new timeout in jiffies +* +* mod_timer_pinned() is a way to update the expire field of an +* active timer (if the timer is inactive it will be activated) +* and not allow the timer to be migrated to a different CPU. +* +* mod_timer_pinned(timer, expires) is equivalent to: +* +* del_timer(timer); timer->expires = expires; add_timer(timer); +*/ +int mod_timer_pinned (struct timer_list *timer,unsigned long expires) +{ +if (timer->expires == expires &&timer_pending (timer)) +return 1 ; + +return __mod_timer (timer, expires, false,TIMER_PINNED ); +} +EXPORT_SYMBOL (mod_timer_pinned); + +/** * add_timer - start a timer * @timer: the timer to be added *
@@ -1356,7 +1379,7 @@ signed long __sched schedule_timeout(signed long timeout) expire = timeout + jiffies;setup_timer_on_stack (&timer, process_timeout, (unsigned long )current); -__mod_timer (&timer, expire, false); +__mod_timer (&timer, expire, false,TIMER_NOT_PINNED );schedule ();del_singleshot_timer_sync (&timer);
commit 5c333864a6ba811052d52ef14fbed056b9ac3512
Author: Arun R Bharadwaj <[email protected]> Date: Thu Apr 16 12:14:37 2009 +0530
timers: Identifying the existing pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
The following pinned hrtimers have been identified and marked:
1)sched_rt_period_timer
2)tick_sched_timer
3)stack_trace_timer_fn
[ tglx: fixup the hrtimer pinned mode ]
arch/x86/kernel/apic/x2apic_uv_x.c +1 -1
@@ -463,7 +463,7 @@ static void uv_heartbeat(unsigned long ignored)uv_set_scir_bits (bits);/* enable next timer period */ -mod_timer (timer, jiffies +SCIR_CPU_HB_INTERVAL ); +mod_timer_pinned (timer, jiffies +SCIR_CPU_HB_INTERVAL ); }static void __cpuinit uv_heartbeat_enable (int cpu)
kernel/sched.c +2 -2
@@ -244,7 +244,7 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b) hard =hrtimer_get_expires (&rt_b->rt_period_timer); delta =ktime_to_ns (ktime_sub (hard, soft));__hrtimer_start_range_ns (&rt_b->rt_period_timer, soft, delta, -HRTIMER_MODE_ABS ,0 ); +HRTIMER_MODE_ABS_PINNED ,0 ); }spin_unlock (&rt_b->rt_runtime_lock); }
@@ -1154,7 +1154,7 @@ static __init void init_hrtick(void)static void hrtick_start (struct rq *rq,u64 delay) {__hrtimer_start_range_ns (&rq->hrtick_timer,ns_to_ktime (delay),0 , -HRTIMER_MODE_REL ,0 ); +HRTIMER_MODE_REL_PINNED ,0 ); }static inline void init_hrtick (void )
kernel/time/tick-sched.c +4 -3
@@ -349,7 +349,7 @@ void tick_nohz_stop_sched_tick(int inidle)if (ts->nohz_mode ==NOHZ_MODE_HIGHRES ) {hrtimer_start (&ts->sched_timer, expires, -HRTIMER_MODE_ABS ); +HRTIMER_MODE_ABS_PINNED );/* Check, if the timer was already in the past */ if (hrtimer_active (&ts->sched_timer)) goto out;
@@ -395,7 +395,7 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)if (ts->nohz_mode ==NOHZ_MODE_HIGHRES ) {hrtimer_start_expires (&ts->sched_timer, -HRTIMER_MODE_ABS ); +HRTIMER_MODE_ABS_PINNED );/* Check, if the timer was already in the past */ if (hrtimer_active (&ts->sched_timer))break ;
@@ -698,7 +698,8 @@ void tick_setup_sched_timer(void)for (;;) {hrtimer_forward (&ts->sched_timer, now, tick_period); -hrtimer_start_expires (&ts->sched_timer,HRTIMER_MODE_ABS ); +hrtimer_start_expires (&ts->sched_timer, +HRTIMER_MODE_ABS_PINNED );/* Check, if the timer was already in the past */ if (hrtimer_active (&ts->sched_timer))break ;
kernel/trace/trace_sysprof.c +2 -1
@@ -203,7 +203,8 @@ static void start_stack_timer(void *unused)hrtimer_init (hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); hrtimer->function = stack_trace_timer_fn; -hrtimer_start (hrtimer,ns_to_ktime (sample_period),HRTIMER_MODE_REL ); +hrtimer_start (hrtimer,ns_to_ktime (sample_period), +HRTIMER_MODE_REL_PINNED ); }static void start_stack_timers (void )
commit cd1bb94b4a0531e8211a3774f17de831f8285f76
Author: Arun R Bharadwaj <[email protected]> Date: Thu Apr 16 12:15:34 2009 +0530
timers: /proc/sys sysctl hook to enable timer migration
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch creates the /proc/sys sysctl interface at /proc/sys/kernel/timer_migration
Timer migration is enabled by default.
To disable timer migration, when CONFIG_SCHED_DEBUG = y,
echo 0 > /proc/sys/kernel/timer_migration
include/linux/sched.h +1 -0
@@ -1766,6 +1766,7 @@ extern unsigned int sysctl_sched_child_runs_first;extern unsigned int sysctl_sched_features;extern unsigned int sysctl_sched_migration_cost;extern unsigned int sysctl_sched_nr_migrate; +extern unsigned int sysctl_timer_migration; int sched_nr_latency_handler(struct ctl_table *table, int write, struct file *file, void __user *buffer, size_t *length,
kernel/sched.c +2 -0
@@ -8731,6 +8731,8 @@ void __init sched_init_smp(void) }#endif /* CONFIG_SMP */ +const_debug unsigned int sysctl_timer_migration = 1; +int in_sched_functions (unsigned long addr) { return in_lock_functions(addr) ||
kernel/sysctl.c +8 -0
@@ -324,6 +324,14 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "timer_migration", + .data = &sysctl_timer_migration, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = &proc_dointvec, + },#endif { .ctl_name = CTL_UNNUMBERED,
commit eea08f32adb3f97553d49a4f79a119833036000a
Author: Arun R Bharadwaj <[email protected]> Date: Thu Apr 16 12:16:41 2009 +0530
timers: Logic to move non pinned timers
* Arun R Bharadwaj <[email protected]> [2009-04-16 12:11:36]:
This patch migrates all non pinned timers and hrtimers to the current idle load balancer, from all the idle CPUs. Timers firing on busy CPUs are not migrated.
While migrating hrtimers, care should be taken to check if migrating a hrtimer would result in a latency or not. So we compare the expiry of the hrtimer with the next timer interrupt on the target cpu and migrate the hrtimer only if it expires *after* the next interrupt on the target cpu. So, added a clockevents_get_next_event() helper function to return the next_event on the target cpu's clock_event_device.
[ tglx: cleanups and simplifications ]
include/linux/clockchips.h +9 -0
@@ -143,3 +143,12 @@ extern void clockevents_notify(unsigned long reason, void *arg);#endif #endif + +#ifdef CONFIG_GENERIC_CLOCKEVENTS +extern ktime_t clockevents_get_next_event (int cpu); +#else +static inline ktime_t clockevents_get_next_event (int cpu) +{ +return (ktime_t ) { .tv64 =KTIME_MAX }; +} +#endif
include/linux/sched.h +12 -0
@@ -257,6 +257,7 @@ extern void task_rq_unlock_wait(struct task_struct *p);extern cpumask_var_t nohz_cpu_mask;#if defined(CONFIG_SMP ) && defined(CONFIG_NO_HZ )extern int select_nohz_load_balancer (int cpu); +extern int get_nohz_load_balancer (void );#else static inline int select_nohz_load_balancer (int cpu) {
@@ -1772,6 +1773,17 @@ int sched_nr_latency_handler(struct ctl_table *table, int write, struct file *file, void __user *buffer, size_t *length, loff_t *ppos);#endif +#ifdef CONFIG_SCHED_DEBUG +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return sysctl_timer_migration; +} +#else +static inline unsigned int get_sysctl_timer_migration (void ) +{ +return 1 ; +} +#endif extern unsigned int sysctl_sched_rt_period;extern int sysctl_sched_rt_runtime;
kernel/hrtimer.c +49 -2
76 lines not on this page · raw message
kernel/sched.c +5 -0
@@ -4244,6 +4244,11 @@ static struct { .load_balancer = ATOMIC_INIT(-1), }; +int get_nohz_load_balancer (void ) +{ +return atomic_read (&nohz.load_balancer); +} +/* * This routine will try to nominate the ilb (idle load balancing) * owner among the cpus whose ticks are stopped. ilb owner will do the idle
kernel/time/clockevents.c +12 -0
@@ -18,6 +18,7 @@#include <linux/notifier.h> #include <linux/smp.h> #include <linux/sysdev.h> +#include <linux/tick.h> /* The registered clock event devices */ static LIST_HEAD (clockevent_devices);
@@ -251,4 +252,15 @@ void clockevents_notify(unsigned long reason, void *arg) spin_unlock(&clockevents_lock); }EXPORT_SYMBOL_GPL (clockevents_notify); + +ktime_t clockevents_get_next_event (int cpu) +{ +struct tick_device *td; +struct clock_event_device *dev; + + td = &per_cpu (tick_cpu_device, cpu); + dev = td->evtdev; + +return dev->next_event; +}#endif
kernel/timer.c +14 -3
@@ -37,6 +37,7 @@#include <linux/delay.h> #include <linux/tick.h> #include <linux/kallsyms.h> +#include <linux/sched.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -609,9 +610,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, {struct tvec_base *base, *new_base;unsigned long flags; -int ret; - - ret =0 ; +int ret =0 , cpu;timer_stats_timer_set_start_info (timer);BUG_ON (!timer->function);
@@ -630,6 +629,18 @@ __mod_timer(struct timer_list *timer, unsigned long expires, new_base =__get_cpu_var (tvec_bases); + cpu =smp_processor_id (); + +#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +if (!pinned &&get_sysctl_timer_migration () &&idle_cpu (cpu)) { +int preferred_cpu =get_nohz_load_balancer (); + +if (preferred_cpu >=0 ) + cpu = preferred_cpu; + } +#endif + new_base =per_cpu (tvec_bases, cpu); +if (base != new_base) {/* * We are trying to schedule the timer on the local CPU.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 6 lines · On Monday 06 July 2009 16:19:16 Jarek Poplawski wrote:
Quoted 4 lines · Joao Correia
Hello
System freezes immediatly after grub, no init processing at all, after applying those patches on top of vanilla 2.6.30 on my box.
Quoted 7 lines
...
Quoted 5 lines
doesnt work on top of 2.6.30. It complains, while compiling, that
sysctl_timer_migrationis not defined. So i just replaced that call with return 1, like on the not debug case. Hope this doesnt defeat your test case, but it wouldnt compile otherwise. Probably that was just introduced after 2.6.30?
I stupidly sent two emails in private to Jarek. Reposting here:
Jarek:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yes, my bad, sorry. I've found 2 more patches from this series;
can't
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
guarantee that's all, but seems to work & migrate within my one and only core without any problems ;-)
Andres:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I have some doubt that this will give us new information:
The commit i bisected the failure to:eea08f32adb3f97553d49a4f79a119833036000a
Is just 2.6.30-rc4 + the four commits you listed...
Jarek:
Quoted 1 line
Quoted 1 line
Quoted 1 line
I guess, you mean 2.6.31-rc1?
Andres:
Quoted 3 lines
Quoted 3 lines
No - I tested the timer development branch to exclude its a problem caused by some other change between 2.6.30 and 2.6.31-git
And that branch is based on rc4...
Jarek:
Quoted 1 line
I misunderstood, sorry! That's just what I needed to know!
Andres:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
And I seperately tested eea08f32adb3f97553d49a4f79a119833036000a^ to be sure. So I am pretty sure its those commits which trigger the problem - whats causing it is another matter.
Jarek:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
It might be true, but it isn't 100% proof. This patchset is special:
by moving timers to other cores it generates much more SMP concurrency, so it could trigger some hidden races, which otherwise need much more time to show up. So I'm trying to establish if this could be the case. Btw., I guess there is nothing to hide from the lists, plus somebody could verify this idea?
Andres:
Quoted 7 lines
Quoted 4 lines
No, absolutely not. Just hit the wrong key. Sorry.
Btw, I ran netem with delay for more than 48h on around 80mbit... That does not exclude such a rarely triggered race, but makes it a bit more unlikely. (With migration thats around 3sec or so)This is a very important information: it should give timers' guys some incentive to start looking for this, and me less incentive to verify network code ;-)
Jarek:
Quoted 3 lines
Btw., there were some strange traces of lockdep and stack overruning; did you try if without lockdep maybe there are some more readable warnings?
Lockdep was not enabled at first. Actually I think most if not all of the traces I posted at first were without.
Will verify.
Quoted 2 lines
And once again, consider resending this to the public, please. (At least Joao might be interested.)
Sorry once more.
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
On Mon, Jul 06, 2009 at 06:13:29PM +0200, Andres Freund wrote:
...
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Btw, I ran netem with delay for more than 48h on around 80mbit... That does not exclude such a rarely triggered race, but makes it a bit more unlikely. (With migration thats around 3sec or so)
...
Quoted 1 line
Sorry once more.
Andres, the bisection + the above - you did 'the whole lotta work' and you shouldn't be sorry at all! ;-)
Thanks again,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Hello
Since i already had the kernel compiled and ready to boot when i read this, i gave it a go anyway :-).
I can reproduce the freeze with those 4 patches applied, so i can confirm that its, at least, related to, or exposed by, those patches. There must be something else too, or its just too much fuzziness, but the freeze takes a bit more time (approximately five minutes, give or take) compared to the instant freeze before, but its there with the patches, and without them, no freeze.
I assume there isnt a "safe" way to get them out of current .31-rc's, right?
Thank you very much for your time,
Joao Correia
Quoted 14 lines · Jarek Poplawski
On Mon, Jul 06, 2009 at 06:13:29PM +0200, Andres Freund wrote:
...Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Btw, I ran netem with delay for more than 48h on around 80mbit... That does not exclude such a rarely triggered race, but makes it a bit more unlikely. (With migration thats around 3sec or so)
...
Quoted 1 line
Sorry once more.
Andres, the bisection + the above - you did 'the whole lotta work' and you shouldn't be sorry at all! ;-)
Thanks again,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Jarek PoplawskiQuoted 7 lines · On Monday 06 July 2009 18:31:06 Jarek Poplawski wrote:
Quoted 4 lines · Andres Freund
Quoted 3 lines
Quoted 3 lines
Btw, I ran netem with delay for more than 48h on around 80mbit... That does not exclude such a rarely triggered race, but makes it a bit more unlikely. (With migration thats around 3sec or so)
Sorry once more.
Andres, the bisection + the above - you did 'the whole lotta work' and you shouldn't be sorry at all! ;-)
To be fair I have to admit I did run netem for 48hours for other reasons ;-) I also ran my modified netem, but all it currently does is adjusing delay/jitter by other means, so that should have no influence.
I am trying to produce artificial loss patterns similar to really occuring network loss.
I just switched mail client btw ;-)
ATM I have no further ideas except maybe trying different timers or a lower timer resolution?
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Joao CorreiaQuoted 12 lines · On Monday 06 July 2009 19:23:18 Joao Correia wrote:
Hello
Since i already had the kernel compiled and ready to boot when i read this, i gave it a go anyway :-).
I can reproduce the freeze with those 4 patches applied, so i can confirm that its, at least, related to, or exposed by, those patches. There must be something else too, or its just too much fuzziness, but the freeze takes a bit more time (approximately five minutes, give or take) compared to the instant freeze before, but its there with the patches, and without them, no freeze.
Quoted 2 lines
I assume there isnt a "safe" way to get them out of current .31-rc's, right?
echo 0 > /proc/sys/kernel/timer_migration should mitigate the problem.
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 13 lines · Andres Freund
Quoted 12 lines · On Monday 06 July 2009 19:23:18 Joao Correia wrote:
Hello
Since i already had the kernel compiled and ready to boot when i read this, i gave it a go anyway :-).
I can reproduce the freeze with those 4 patches applied, so i can confirm that its, at least, related to, or exposed by, those patches. There must be something else too, or its just too much fuzziness, but the freeze takes a bit more time (approximately five minutes, give or take) compared to the instant freeze before, but its there with the patches, and without them, no freeze.
Quoted 3 lines
Quoted 2 lines
I assume there isnt a "safe" way to get them out of current .31-rc's, right?
echo 0 > /proc/sys/kernel/timer_migrationshould mitigate the problem.
I guess it should fix it entirely. Btw., here is a patch disabling the timers' part, so to make it hrtimers only. Could you try?
Thanks,
Jarek P.
---
kernel/timer.c +1 -1
@@ -634,7 +634,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, cpu =smp_processor_id (); -#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +#if 0 if (!pinned &&get_sysctl_timer_migration () &&idle_cpu (cpu)) {int preferred_cpu =get_nohz_load_balancer ();
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
I am now running 2.6.31-rc2 for a couple of hours, no freeze.
Let me know what/if i can help with tracking down the original source of the problem.
Thank you very much for your time,
Joao Correia
Quoted 39 lines · Jarek Poplawski
Quoted 13 lines · Andres Freund
Quoted 12 lines · On Monday 06 July 2009 19:23:18 Joao Correia wrote:
Hello
Since i already had the kernel compiled and ready to boot when i read this, i gave it a go anyway :-).
I can reproduce the freeze with those 4 patches applied, so i can confirm that its, at least, related to, or exposed by, those patches. There must be something else too, or its just too much fuzziness, but the freeze takes a bit more time (approximately five minutes, give or take) compared to the instant freeze before, but its there with the patches, and without them, no freeze.
Quoted 3 lines
Quoted 2 lines
I assume there isnt a "safe" way to get them out of current .31-rc's, right?
echo 0 > /proc/sys/kernel/timer_migrationshould mitigate the problem.I guess it should fix it entirely. Btw., here is a patch disabling the timers' part, so to make it hrtimers only. Could you try?
Thanks,
Jarek P.
---kernel/timer.c +1
-1@@ -634,7 +634,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, cpu = smp_processor_id(); -#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +#if 0 if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) { int preferred_cpu = get_nohz_load_balancer();
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 4 lines · On Tuesday 07 July 2009 12:40:16 Joao Correia wrote:
I am now running 2.6.31-rc2 for a couple of hours, no freeze.
Let me know what/if i can help with tracking down the original source of the problem.
You dont see the problem anymore with the echo 0 > /proc/sys/kernel/timer_migration change (or equivalently with the patch from Jarek) or has the problem vanished completely?
Andres
Fwd: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to a message not in the archiveCC'ing the list and other listeners, that were left out in the previous email.
Joao Correia
---------- Forwarded message ----------
From: Joao Correia <[email protected]>
Date: Tue, Jul 7, 2009 at 12:03 PM
Subject: Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
To: Andres Freund <[email protected]>
I dont see the problem with the patch from Jarek. (sorry for not being clear about this).
With vanilla 31-rc2 it is still there.
Joao Correia
Quoted 11 lines · Andres Freund
Quoted 4 lines · On Tuesday 07 July 2009 12:40:16 Joao Correia wrote:
I am now running 2.6.31-rc2 for a couple of hours, no freeze.
Let me know what/if i can help with tracking down the original source of the problem.
You dont see the problem anymore with the
echo 0 > /proc/sys/kernel/timer_migrationchange (or equivalently with the patch from Jarek) or has the problem vanished completely?Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Joao CorreiaQuoted 4 lines · Joao Correia
I am now running 2.6.31-rc2 for a couple of hours, no freeze.
Let me know what/if i can help with tracking down the original source of the problem.
OK, so we know it's only about timers. Here is another tiny patch (the previous one should be removed), which could tell (with oops) if there's something while migrating. Anyway, the bug should be back :-(
Thanks,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Joao CorreiaSorry, here is this tiny patch!
Quoted 4 lines · Joao Correia
I am now running 2.6.31-rc2 for a couple of hours, no freeze.
Let me know what/if i can help with tracking down the original source of the problem.
OK, so we know it's only about timers. Here is another tiny patch (the previous one should be removed), which could tell (with oops) if there's something while migrating. Anyway, the bug should be back :-(
Thanks,
Jarek P.
---
kernel/timer.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/timer.c +1 -0
@@ -658,6 +658,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires,spin_unlock (&base->lock); base = new_base;spin_lock (&base->lock); +BUG_ON (tbase_get_base (timer->base));timer_set_base (timer, base); } }
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Jarek PoplawskiQuoted 7 lines · On Tuesday 07 July 2009 15:18:03 Jarek Poplawski wrote:
Quoted 3 lines · Joao Correia
I am now running 2.6.31-rc2 for a couple of hours, no freeze. Let me know what/if i can help with tracking down the original source of the problem.
OK, so we know it's only about timers. Here is another tiny patch (the previous one should be removed), which could tell (with oops) if there's something while migrating. Anyway, the bug should be back :-(
How do we know this? It still could be a race uncovered by timer migration, right?
Andres
PS: You forgot the patch ;-)
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 10 lines · Andres Freund
Quoted 7 lines · On Tuesday 07 July 2009 15:18:03 Jarek Poplawski wrote:
Quoted 3 lines · Joao Correia
I am now running 2.6.31-rc2 for a couple of hours, no freeze. Let me know what/if i can help with tracking down the original source of the problem.
OK, so we know it's only about timers. Here is another tiny patch (the previous one should be removed), which could tell (with oops) if there's something while migrating. Anyway, the bug should be back :-(
How do we know this? It still could be a race uncovered by timer migration, right?
Right. But (rather) not by or in hrtimers.
Quoted 1 line
PS: You forgot the patch ;-)
Yes, I hope you got it already ;-)
Thanks,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 7 lines · On Tuesday 07 July 2009 15:29:37 Jarek Poplawski wrote:
Quoted 6 lines · Andres Freund
Quoted 5 lines · On Tuesday 07 July 2009 15:18:03 Jarek Poplawski wrote:
Quoted 3 lines · Joao Correia
I am now running 2.6.31-rc2 for a couple of hours, no freeze. Let me know what/if i can help with tracking down the original source of the problem.
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
OK, so we know it's only about timers. Here is another tiny patch (the previous one should be removed), which could tell (with oops) if there's something while migrating. Anyway, the bug should be back :-(
PS: You forgot the patch ;-)
Yes, I hope you got it already ;-)
Yes. Can't reboot that machine right now, will test later.
Testing wether its triggerable inside a vm might be interesting...
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
On Tue, Jul 07, 2009 at 03:34:07PM +0200, Andres Freund wrote:
...
Quoted 1 line
Testing wether its triggerable inside a vm might be interesting...
Probably similarly to testing without this patch or even less. Maybe I should've warned you but this type of bugs in -rc with possible memory or stack overwrites might be fatal for your data (at least).
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 6 lines · On Tuesday 07 July 2009 15:57:42 Jarek Poplawski wrote:
On Tue, Jul 07, 2009 at 03:34:07PM +0200, Andres Freund wrote:
...Quoted 1 line
Testing wether its triggerable inside a vm might be interesting...
Probably similarly to testing without this patch or even less. Maybe I should've warned you but this type of bugs in -rc with possible memory or stack overwrites might be fatal for your data (at least).
Fortunately all the data on that machine should either be replaceable or regularly backuped.
Will test later today if that patch bugs.
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 11 lines · Andres Freund
Quoted 6 lines · On Tuesday 07 July 2009 15:57:42 Jarek Poplawski wrote:
On Tue, Jul 07, 2009 at 03:34:07PM +0200, Andres Freund wrote:
...Quoted 1 line
Testing wether its triggerable inside a vm might be interesting...
Probably similarly to testing without this patch or even less. Maybe I should've warned you but this type of bugs in -rc with possible memory or stack overwrites might be fatal for your data (at least).
Fortunately all the data on that machine should either be replaceable or regularly backuped.
Will test later today if that patch bugs.
If you didn't start yet, it would be nice to use this, btw:
CONFIG_HOTPLUG_CPU = NCONFIG_DEBUG_OBJECTS = YCONFIG_DEBUG_OBJECTS_TIMERS = Y
Thanks,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 14 lines · On Wednesday 08 July 2009 10:08:52 Jarek Poplawski wrote:
Quoted 13 lines · Andres Freund
Quoted 8 lines · On Tuesday 07 July 2009 15:57:42 Jarek Poplawski wrote:
On Tue, Jul 07, 2009 at 03:34:07PM +0200, Andres Freund wrote:
...Quoted 1 line
Testing wether its triggerable inside a vm might be interesting...
Probably similarly to testing without this patch or even less. Maybe I should've warned you but this type of bugs in -rc with possible memory or stack overwrites might be fatal for your data (at least).
Fortunately all the data on that machine should either be replaceable or regularly backuped.
Quoted 7 lines
Quoted 1 line
Will test later today if that patch bugs.
If you didn't start yet, it would be nice to use this, btw:
CONFIG_HOTPLUG_CPU= NCONFIG_DEBUG_OBJECTS= YCONFIG_DEBUG_OBJECTS_TIMERS= Y
So I should test with a single cpu? Or is there a config where HOTPLUG_CPU does not imply !SMP?
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 17 lines · Andres Freund
Quoted 16 lines · On Wednesday 08 July 2009 10:08:52 Jarek Poplawski wrote:
Quoted 14 lines · Andres Freund
Quoted 8 lines · On Tuesday 07 July 2009 15:57:42 Jarek Poplawski wrote:
On Tue, Jul 07, 2009 at 03:34:07PM +0200, Andres Freund wrote:
...Quoted 1 line
Testing wether its triggerable inside a vm might be interesting...
Probably similarly to testing without this patch or even less. Maybe I should've warned you but this type of bugs in -rc with possible memory or stack overwrites might be fatal for your data (at least).
Fortunately all the data on that machine should either be replaceable or regularly backuped.
Will test later today if that patch bugs.
Quoted 7 lines
Quoted 5 lines
If you didn't start yet, it would be nice to use this, btw:
CONFIG_HOTPLUG_CPU= NCONFIG_DEBUG_OBJECTS= YCONFIG_DEBUG_OBJECTS_TIMERS= YSo I should test with a single cpu? Or is there a config where
HOTPLUG_CPUdoes not imply !SMP?
No, my single cpu should be enough ;-) There is something wrong I guess. I can see in my menuconfig:
SMP [=y]
...
HOTPLUG [=n]
...HOTPUG_CPU [=y]
...
Depends on SMP && HOTPLUG
So, let it be HOTPLUG_CPU = Y for now...
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Hello again
Quoted 5 lines · Andres Freund
Quoted 4 lines · On Tuesday 07 July 2009 12:40:16 Joao Correia wrote:
I am now running 2.6.31-rc2 for a couple of hours, no freeze.
Let me know what/if i can help with tracking down the original source of the problem.
Quoted 8 lines
You dont see the problem anymore with the
echo 0 > /proc/sys/kernel/timer_migrationchange (or equivalently with the patch from Jarek) or has the problem vanished completely?Andres
Quoted 1 line · On Tuesday 07 July 2009 13:03:50 Joao Correia wrote:
I dont see the problem with the patch from Jarek
I have to correct this information.
I had inserted echo 0 >> /proc/sys/kernel/timer_migration into rc.local, and i left it there when i applied your first patch.
Im talking about this patch:
kernel/timer.c +1 -1
@@ -634,7 +634,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, cpu =smp_processor_id (); -#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +#if 0
After removing the line from rc.local, and leaving only the patch, the freeze still happens. The patch -does not- prevent the freeze. It was my mistake saying it does, i totally forgot i had added that line to rc.local.
So again, the only thing that stops that freeze is echo 0 >> /proc/sys/kernel/timer_migration. Apologies for pointing you in the wrong direction.
I also tried the other patch provided:
kernel/timer.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/timer.c +1 -0
@@ -658,6 +658,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires,spin_unlock (&base->lock); base = new_base;spin_lock (&base->lock); +BUG_ON (tbase_get_base (timer->base));timer_set_base (timer, base); } }
but the OPS never triggers, either with your first patch or with the echo 0 > proc[...]
I was under the impression that disabling the entry in /proc or applying the first patch would provide the same result, but alas, it does not.
Joao Correia
[PS Im providing the patches in this email to contextualize this so that people dont get lost]
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 1 line · Joao Correia
Hello again
Hello!
...
Quoted 3 lines
So again, the only thing that stops that freeze is
echo 0 >> /proc/sys/kernel/timer_migration. Apologies for pointing you in the wrong direction.
No problem: the direction is almost right, we only need one U-turn ;-) In case you're not bored or too bored, one little patch to check the other side (after reverting the previous patch).
Thanks,
Jarek P.
---
kernel/hrtimer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/hrtimer.c +1 -1
@@ -203,7 +203,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,int cpu, preferred_cpu =-1 ; cpu =smp_processor_id (); -#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +#if 0 if (!pinned &&get_sysctl_timer_migration () &&idle_cpu (cpu)) { preferred_cpu =get_nohz_load_balancer ();if (preferred_cpu >=0 )
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Jarek PoplawskiQuoted 14 lines · On Wednesday 08 July 2009 10:08:52 Jarek Poplawski wrote:
Quoted 13 lines · Andres Freund
Quoted 8 lines · On Tuesday 07 July 2009 15:57:42 Jarek Poplawski wrote:
On Tue, Jul 07, 2009 at 03:34:07PM +0200, Andres Freund wrote:
...Quoted 1 line
Testing wether its triggerable inside a vm might be interesting...
Probably similarly to testing without this patch or even less. Maybe I should've warned you but this type of bugs in -rc with possible memory or stack overwrites might be fatal for your data (at least).
Fortunately all the data on that machine should either be replaceable or regularly backuped.
Quoted 6 lines
Quoted 1 line
Will test later today if that patch bugs.
If you didn't start yet, it would be nice to use this, btw:
CONFIG_HOTPLUG_CPU= NCONFIG_DEBUG_OBJECTS= YCONFIG_DEBUG_OBJECTS_TIMERS= Y
Unfortunately this just yields the same backtraces during softlockup and not earlier.
I did not test without lockdep yet, but that should not have stopped the BUG from appearing, right?
Andres
[ 207.233011] BUG: soft lockup - CPU#0 stuck for 61s! [openvpn:4232] [ 207.233011] Modules linked in: sch_netem sbs sbshc snd_hda_codec_conexant pcmcia snd_hda_intel snd_hda_codec iwlagn thinkpad_acpi yenta_socket rsrc_nonstatic pcmcia_core btusb snd_hwdep ehci_hcd uhci_hcd [ 207.233011] irq event stamp: 158057 [ 207.233011] hardirqs last enabled at (158056): [<ffffffff81036a10>] restore_args+0x0/0x30 [ 207.233011] hardirqs last disabled at (158057): [<ffffffff81035d3a>] save_args+0x6a/0x70 [ 207.233011] softirqs last enabled at (27750): [<ffffffff8155837d>] lock_sock_nested+0x8d/0x130 [ 207.233011] softirqs last disabled at (27756): [<ffffffff81568278>] dev_queue_xmit+0x58/0x4b0 [ 207.233011] CPU 0: [ 207.233011] Modules linked in: sch_netem sbs sbshc snd_hda_codec_conexant pcmcia snd_hda_intel snd_hda_codec iwlagn thinkpad_acpi yenta_socket rsrc_nonstatic pcmcia_core btusb snd_hwdep ehci_hcd uhci_hcd [ 207.233011] Pid: 4232, comm: openvpn Not tainted 2.6.31-rc2-andres-00151-gf3060b0-dirty #83 208252G [ 207.233011] RIP: 0010:[<ffffffff812a9eb1>] [<ffffffff812a9eb1>] delay_tsc+0x51/0x80 [ 207.233011] RSP: 0018:ffff88012984f938 EFLAGS: 00000202 [ 207.233011] RAX: 000000007086c4e9 RBX: ffff88012984f958 RCX: 000000007086c4e9 [ 207.233011] RDX: 000000007086c4e9 RSI: 0000000000006238 RDI: 0000000000000001 [ 207.233011] RBP: ffffffff81036b6e R08: ffffffff82189460 R09: 0000000000000002 [ 207.233011] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000003fda [ 207.233011] R13: ffff88002ee00000 R14: ffff88012984e000 R15: 0000000000000000 [ 207.233011] FS: 00007f518d51a6f0(0000) GS:ffff88002ee00000(0000) knlGS:0000000000000000 [ 207.233011] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 207.233011] CR2: 00007f46fb78600c CR3: 000000012bc8f000 CR4: 00000000000026f0 [ 207.233011] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 207.233011] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 207.233011] Call Trace: [ 207.233011] [<ffffffff812a9eaa>] ? delay_tsc+0x4a/0x80 [ 207.233011] [<ffffffff812a9d9a>] ? __delay+0xa/0x10 [ 207.233011] [<ffffffff812ae578>] ? _raw_spin_lock+0xd8/0x150 [ 207.233011] [<ffffffff816f0431>] ? _spin_lock+0x51/0x70 [ 207.233011] [<ffffffff81568306>] ? dev_queue_xmit+0xe6/0x4b0 [ 207.233011] [<ffffffff81568306>] ? dev_queue_xmit+0xe6/0x4b0 [ 207.233011] [<ffffffff81568273>] ? dev_queue_xmit+0x53/0x4b0 [ 207.233011] [<ffffffff8159a67c>] ? ip_finish_output+0x13c/0x320 [ 207.233011] [<ffffffff8159a8db>] ? ip_output+0x7b/0xd0 [ 207.233011] [<ffffffff81598b98>] ? ip_generic_getfrag+0x88/0xa0 [ 207.233011] [<ffffffff815996c0>] ? ip_local_out+0x20/0x30 [ 207.233011] [<ffffffff81599957>] ? ip_push_pending_frames+0x287/0x410 [ 207.233011] [<ffffffff815bae18>] ? udp_push_pending_frames+0x168/0x3d0 [ 207.233011] [<ffffffff815bcd07>] ? udp_sendmsg+0x457/0x760 [ 207.233011] [<ffffffff815c4144>] ? inet_sendmsg+0x24/0x60 [ 207.233011] [<ffffffff81555556>] ? sock_sendmsg+0x126/0x140 [ 207.233011] [<ffffffff81097f60>] ? autoremove_wake_function+0x0/0x40 [ 207.233011] [<ffffffff810ab6e7>] ? mark_held_locks+0x67/0x90 [ 207.233011] [<ffffffff816f01fb>] ? _spin_unlock_irqrestore+0x3b/0x70 [ 207.233011] [<ffffffff810ab9fd>] ? trace_hardirqs_on_caller+0x14d/0x190 [ 207.233011] [<ffffffff81556490>] ? sys_sendto+0xf0/0x130 [ 207.233011] [<ffffffff810aba4d>] ? trace_hardirqs_on+0xd/0x10 [ 207.233011] [<ffffffff810a21f7>] ? getnstimeofday+0x57/0xe0 [ 207.233011] [<ffffffff8109c1f1>] ? ktime_get_ts+0x51/0x70 [ 207.233011] [<ffffffff81035ec2>] ? system_call_fastpath+0x16/0x1bx
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Jarek PoplawskiQuoted 26 lines · Jarek Poplawski
Quoted 1 line · Joao Correia
Hello again
Hello!
...
Quoted 3 lines
So again, the only thing that stops that freeze is
echo 0 >> /proc/sys/kernel/timer_migration. Apologies for pointing you in the wrong direction.No problem: the direction is almost right, we only need one U-turn ;-) In case you're not bored or too bored, one little patch to check the other side (after reverting the previous patch).
Thanks,
Jarek P.
---kernel/hrtimer.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)kernel/hrtimer.c +0
-0
kernel/hrtimer.c switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, · line 209
Quoted 8 lines
kernel/hrtimer.c +1
-1@@ -203,7 +203,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, int cpu, preferred_cpu = -1; cpu = smp_processor_id(); -#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +#if 0 if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) { preferred_cpu = get_nohz_load_balancer(); if (preferred_cpu >= 0)
(this time i triple-checked :-) )
So, with only this last patch applied, no freeze. No need to disable anything through /proc.
Where should i put the BUG_ON?
Joao Correia
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 38 lines · Joao Correia
Quoted 26 lines · Jarek Poplawski
Quoted 1 line · Joao Correia
Hello again
Hello!
...
Quoted 3 lines
So again, the only thing that stops that freeze is
echo 0 >> /proc/sys/kernel/timer_migration. Apologies for pointing you in the wrong direction.No problem: the direction is almost right, we only need one U-turn ;-) In case you're not bored or too bored, one little patch to check the other side (after reverting the previous patch).
Thanks,
Jarek P.
---kernel/hrtimer.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)kernel/hrtimer.c +0
-0kernel/hrtimer.c switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, · line 209
Quoted 8 lines
kernel/hrtimer.c +1
-1@@ -203,7 +203,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base, int cpu, preferred_cpu = -1; cpu = smp_processor_id(); -#if defined(CONFIG_NO_HZ ) && defined(CONFIG_SMP ) +#if 0 if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) { preferred_cpu = get_nohz_load_balancer(); if (preferred_cpu >= 0)(this time i triple-checked :-) )
Quoted 4 lines
So, with only this last patch applied, no freeze. No need to disable anything through /proc.
Where should i put the
BUG_ON?
Hmm... Not so fast! I've looked in timers till now; "tomorrow" I'll "change resolution". ;-)
Thanks again,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 5 lines
Quoted 5 lines
(this time i triple-checked :-) )
So, with only this last patch applied, no freeze. No need to disable anything through /proc.
Quoted 8 lines
Quoted 1 line
Where should i put the
BUG_ON?Hmm... Not so fast! I've looked in timers till now; "tomorrow" I'll "change resolution". ;-)
Thanks again,
Jarek P.
Of course :-)
Thanks for looking into this.
Joao Correia
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Andres FreundOn Thu, Jul 09, 2009 at 12:23:17AM +0200, Andres Freund wrote:
...
Quoted 4 lines
Unfortunately this just yields the same backtraces during softlockup and not earlier.
I did not test without lockdep yet, but that should not have stopped the BUG from appearing, right?
Since it looks like hrtimers now, these changes in timers shouldn't matter. Let's wait for new ideas.
Thanks for testing anyway,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 9 lines · Jarek Poplawski
On Thu, Jul 09, 2009 at 12:23:17AM +0200, Andres Freund wrote:
...Quoted 4 lines
Unfortunately this just yields the same backtraces during softlockup and not earlier.
I did not test without lockdep yet, but that should not have stopped the BUG from appearing, right?Since it looks like hrtimers now, these changes in timers shouldn't matter. Let's wait for new ideas.
Some background:
Up to 2.6.30 hrtimer_start() and add_timer() enqueue (hr)timers on the CPU on which the functions are called. There is one exception when the timer callback is currently running on another CPU then it is enqueued on that other CPU.
The migration patches change that behaviour and enqeue the timer on the nohz.idle_balancer CPU when parts of the system are idle.
With the migration code disabled (via sysctl or the #if 0 patch) the timer is always enqeued on the same CPU, i.e. you get the 2.6.30 behaviour back.
As you found out it is probably related to hrtimers. Checking the network code the only hrtimer users are in net/sched/sch_api.c and net/sched/sch_cbq.c . There is some in net/can as well, but that's probably irrelevant for the problem at hand.
I'm not familiar with that code, so I have no clue which problems might pop up due to enqueueing the timer on another CPU, but there is one pretty suspicios code sequence in cbq_ovl_delay()
expires = ktime_set(0, 0); expires = ktime_add_ns(expires, PSCHED_US2NS(sched)); if (hrtimer_try_to_cancel(&q->delay_timer) && ktime_to_ns(ktime_sub( hrtimer_get_expires(&q->delay_timer), expires)) > 0) hrtimer_set_expires(&q->delay_timer, expires); hrtimer_restart(&q->delay_timer);
So we set the expiry value of the timer only when the timer was active (hrtimer_try_to_cancel() returned != 0) and the new expiry time is before the expiry time which was in the active timer. If the timer was inactive we start the timer with the last expiry time which is probably already in the past.
I'm quite sure that this is not causing the migration problem, because we do not enqueue it on a different CPU when the timer is already expired.
For completeness: hrtimer_try_to_cancel() can return -1 when the timer callback is running. So in that case we also fiddle with the expiry value and restart the timer while the callback code itself might do the same. There is no serializiation of that code and the callback it seems. The watchdog timer callback in sch_api.c is not serialized either.
There is another oddity in cbq_undelay() which is the hrtimer callback function:
if (delay) {
ktime_t time;
time = ktime_set(0, 0);
time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay));
hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS);The canocial way to restart a hrtimer from the callback function is to set the expiry value and return HRTIMER_RESTART.
} sch->flags &= ~TCQ_F_THROTTLED; __netif_schedule(qdisc_root(sch)); return HRTIMER_NORESTART;
Again, this should not cause the timer to be enqueued on another CPU as we do not enqueue on a different CPU when the callback is running, but see above ...
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
Thanks,
tglx
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 12 lines · Thomas Gleixner
Quoted 9 lines · Jarek Poplawski
On Thu, Jul 09, 2009 at 12:23:17AM +0200, Andres Freund wrote:
...Quoted 4 lines
Unfortunately this just yields the same backtraces during softlockup and not earlier.
I did not test without lockdep yet, but that should not have stopped the BUG from appearing, right?Since it looks like hrtimers now, these changes in timers shouldn't matter. Let's wait for new ideas.
Some background:
...
Quoted 10 lines
There is another oddity in
cbq_undelay()which is the hrtimer callback function:if (delay) { ktime_t time; time = ktime_set(0, 0); time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay)); hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS);
Quoted 2 lines
The canocial way to restart a hrtimer from the callback function is to set the expiry value and return
HRTIMER_RESTART.
OK, that's for later because we didn't use cbq here.
Quoted 7 lines
} sch->flags &= ~TCQ_F_THROTTLED; __netif_schedule(qdisc_root(sch)); return HRTIMER_NORESTART;
Quoted 7 lines
Again, this should not cause the timer to be enqueued on another CPU as we do not enqueue on a different CPU when the callback is running, but see above ...
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
As a matter of fact, I've just looked at this __netif_schedule(), which really is cpu bound, so you might be 100% right.
Thanks for your help,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 7 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.
So the watchdog is the one which causes the trouble. The patch below should fix this.
Thanks,
tglx
---
net/sched/sch_api.c +1 -1
@@ -485,7 +485,7 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) wd->qdisc->flags |=TCQ_F_THROTTLED ; time =ktime_set (0 ,0 ); time =ktime_add_ns (time,PSCHED_TICKS2NS (expires)); -hrtimer_start (&wd->timer, time,HRTIMER_MODE_ABS ); +hrtimer_start (&wd->timer, time,HRTIMER_MODE_ABS_PINNED ); }EXPORT_SYMBOL (qdisc_watchdog_schedule);
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 11 lines · Thomas Gleixner
Quoted 7 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.So the watchdog is the one which causes the trouble. The patch below should fix this.
I hope so. On the other hand it seems it should work with this migration yet, so it probably needs additional debugging.
Thanks,
Jarek P.
Quoted 15 lines
---
net/sched/sch_api.c +1
-1@@ -485,7 +485,7 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) wd->qdisc->flags |=TCQ_F_THROTTLED ; time =ktime_set (0 ,0 ); time =ktime_add_ns (time,PSCHED_TICKS2NS (expires)); -hrtimer_start (&wd->timer, time,HRTIMER_MODE_ABS ); +hrtimer_start (&wd->timer, time,HRTIMER_MODE_ABS_PINNED ); }EXPORT_SYMBOL (qdisc_watchdog_schedule);
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 7 lines · Jarek Poplawski
Quoted 6 lines · Thomas Gleixner
Quoted 5 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.So the watchdog is the one which causes the trouble. The patch below should fix this.
I hope so. On the other hand it seems it should work with this migration yet, so it probably needs additional debugging.
Right. I just provided the patch to narrow down the problem, but please test the fix of the hrtimer migration code which I sent out a bit earlier: http://lkml.org/lkml/2009/7/9/150
It fixes a possible endless loop in the timer code which is related to the migration changes. Looking at the backtraces of the spinlock lockup I think that is what you hit.
spin_lock(root_lock);
qdisc_run(q);
__qdisc_run(q);
dequeue_skb(q);
q->dequeue(q);
qdisc_watchdog_schedule();
hrtimer_start();
switch_hrtimer_base(); <- loops foreverNow the other CPU is stuck in dev_xmit() spin_lock(root_lock)
Thanks,
tglx
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 17 lines · Thomas Gleixner
Quoted 7 lines · Jarek Poplawski
Quoted 6 lines · Thomas Gleixner
Quoted 5 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.So the watchdog is the one which causes the trouble. The patch below should fix this.
I hope so. On the other hand it seems it should work with this migration yet, so it probably needs additional debugging.
Quoted 7 lines
Right. I just provided the patch to narrow down the problem, but please test the fix of the hrtimer migration code which I sent out a bit earlier: http://lkml.org/lkml/2009/7/9/150
It fixes a possible endless loop in the timer code which is related to the migration changes. Looking at the backtraces of the spinlock lockup I think that is what you hit.
Actually, Andres and Joao hit this, and I hope they'll try these two patches.
Thanks,
Jarek P.
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 26 lines · Jarek Poplawski
Quoted 17 lines · Thomas Gleixner
Quoted 7 lines · Jarek Poplawski
Quoted 6 lines · Thomas Gleixner
Quoted 5 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.So the watchdog is the one which causes the trouble. The patch below should fix this.
I hope so. On the other hand it seems it should work with this migration yet, so it probably needs additional debugging.
Quoted 7 lines
Right. I just provided the patch to narrow down the problem, but please test the fix of the hrtimer migration code which I sent out a bit earlier: http://lkml.org/lkml/2009/7/9/150
It fixes a possible endless loop in the timer code which is related to the migration changes. Looking at the backtraces of the spinlock lockup I think that is what you hit.
Quoted 6 lines
Actually, Andres and Joao hit this, and I hope they'll try these two patches.
Thanks,
Jarek P.
I can only try later on today. Will post back as soon as i do it.
Joao Correia
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
In reply to Jarek PoplawskiQuoted 22 lines · Jarek Poplawski
Quoted 21 lines · Thomas Gleixner
Quoted 7 lines · Jarek Poplawski
Quoted 6 lines · Thomas Gleixner
Quoted 5 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.So the watchdog is the one which causes the trouble. The patch below should fix this.
I hope so. On the other hand it seems it should work with this migration yet, so it probably needs additional debugging.
Right. I just provided the patch to narrow down the problem, but please test the fix of the hrtimer migration code which I sent out a bit earlier: http://lkml.org/lkml/2009/7/9/150
Quoted 6 lines
Quoted 3 lines
It fixes a possible endless loop in the timer code which is related to the migration changes. Looking at the backtraces of the spinlock lockup I think that is what you hit.
Actually, Andres and Joao hit this, and I hope they'll try these two patches.
Please test them separate from each other. The one I sent in this thread was just for narrowing down the issue, but I'm now quite sure that they really hit the issue which is addressed by the hrtimer patch.
Thanks,
tglx
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Hi,
Quoted 27 lines · On Thursday 09 July 2009 16:28:05 Thomas Gleixner wrote:
Quoted 26 lines · Jarek Poplawski
Quoted 24 lines · Thomas Gleixner
Quoted 7 lines · Jarek Poplawski
Quoted 6 lines · Thomas Gleixner
Quoted 5 lines · Jarek Poplawski
Quoted 4 lines
I have the feeling that the code relies on some implicit cpu boundness, which is not longer guaranteed with the timer migration changes, but that's a question for the network experts.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As a matter of fact, I've just looked at this
__netif_schedule(), which really is cpu bound, so you might be 100% right.So the watchdog is the one which causes the trouble. The patch below should fix this.
I hope so. On the other hand it seems it should work with this migration yet, so it probably needs additional debugging.
Right. I just provided the patch to narrow down the problem, but please test the fix of the hrtimer migration code which I sent out a bit earlier: http://lkml.org/lkml/2009/7/9/150
It fixes a possible endless loop in the timer code which is related to the migration changes. Looking at the backtraces of the spinlock lockup I think that is what you hit.
Quoted 7 lines
Quoted 2 lines
Actually, Andres and Joao hit this, and I hope they'll try these two patches.
Please test them separate from each other. The one I sent in this thread was just for narrowing down the issue, but I'm now quite sure that they really hit the issue which is addressed by the hrtimer patch.
No crash yet. 15min running (seconds to a minute before).
Will let it run for some hours to be sure.
Nice!
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Andres,
Quoted 8 lines · Andres Freund
Quoted 4 lines · On Thursday 09 July 2009 16:28:05 Thomas Gleixner wrote:
Please test them separate from each other. The one I sent in this thread was just for narrowing down the issue, but I'm now quite sure that they really hit the issue which is addressed by the hrtimer patch.
No crash yet. 15min running (seconds to a minute before).
Will let it run for some hours to be sure.
Which one of the patches are you testing ?
Thanks,
tglx
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 9 lines · On Thursday 09 July 2009 18:01:56 Thomas Gleixner wrote:
Andres,
Quoted 6 lines · Andres Freund
Quoted 4 lines · On Thursday 09 July 2009 16:28:05 Thomas Gleixner wrote:
Please test them separate from each other. The one I sent in this thread was just for narrowing down the issue, but I'm now quite sure that they really hit the issue which is addressed by the hrtimer patch.
Quoted 5 lines
Quoted 3 lines
No crash yet. 15min running (seconds to a minute before).
Will let it run for some hours to be sure.
Which one of the patches are you testing ?
Your "real" one, i.e. de907e8432b08f2d5966c36e0747e97c0e596810
1h30m now...
Andres
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Andres,
Quoted 10 lines · Andres Freund
Quoted 9 lines · On Thursday 09 July 2009 18:01:56 Thomas Gleixner wrote:
Andres,
Quoted 6 lines · Andres Freund
Quoted 4 lines · On Thursday 09 July 2009 16:28:05 Thomas Gleixner wrote:
Please test them separate from each other. The one I sent in this thread was just for narrowing down the issue, but I'm now quite sure that they really hit the issue which is addressed by the hrtimer patch.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
No crash yet. 15min running (seconds to a minute before).
Will let it run for some hours to be sure.
Which one of the patches are you testing ?
Your "real" one, i.e.
de907e8432b08f2d5966c36e0747e97c0e5968101h30m now...
Looks like I hit the nail on the head. Queueing it up for Linus.
Thanks,
tglx
Re: Soft-Lockup/Race in networking in 2.6.31-rc1+195 ( possibly?caused by netem)
Quoted 21 lines · Thomas Gleixner
Andres,
Quoted 17 lines · Andres Freund
Quoted 9 lines · On Thursday 09 July 2009 18:01:56 Thomas Gleixner wrote:
Andres,
Quoted 6 lines · Andres Freund
Quoted 4 lines · On Thursday 09 July 2009 16:28:05 Thomas Gleixner wrote:
Please test them separate from each other. The one I sent in this thread was just for narrowing down the issue, but I'm now quite sure that they really hit the issue which is addressed by the hrtimer patch.
Quoted 5 lines
Quoted 3 lines
No crash yet. 15min running (seconds to a minute before).
Will let it run for some hours to be sure.
Which one of the patches are you testing ?
Your "real" one, i.e.
de907e8432b08f2d5966c36e0747e97c0e596810
Quoted 8 lines
Quoted 1 line
1h30m now...
Looks like I hit the nail on the head. Queueing it up for Linus.
Thanks,
tglx
Confirmed working from me as well.
Thank you for your time,
Joao Correia