From 4f7992a1d02a02161eec45bf1fa119bd51722729 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 29 Apr 2008 09:52:27 -0700 Subject: [PATCH] one more .25 patch --- ...ed-to-avoid-circular-lock-dependency.patch | 102 ++++++++++++++++++ queue-2.6.25/series | 1 + 2 files changed, 103 insertions(+) create mode 100644 queue-2.6.25/hrtimer-raise-softirq-unlocked-to-avoid-circular-lock-dependency.patch diff --git a/queue-2.6.25/hrtimer-raise-softirq-unlocked-to-avoid-circular-lock-dependency.patch b/queue-2.6.25/hrtimer-raise-softirq-unlocked-to-avoid-circular-lock-dependency.patch new file mode 100644 index 00000000000..d9a2ef7c8fe --- /dev/null +++ b/queue-2.6.25/hrtimer-raise-softirq-unlocked-to-avoid-circular-lock-dependency.patch @@ -0,0 +1,102 @@ +From jejb@kernel.org Tue Apr 29 09:51:24 2008 +From: Thomas Gleixner +Date: Tue, 29 Apr 2008 01:15:10 GMT +Subject: hrtimer: raise softirq unlocked to avoid circular lock dependency +To: jejb@kernel.org, stable@kernel.org +Message-ID: <200804290115.m3T1FAaX028758@hera.kernel.org> + +From: Thomas Gleixner + +commit 0c96c5979a522c3323c30a078a70120e29b5bdbc upstream + +The scheduler hrtimer bits in 2.6.25 introduced a circular lock +dependency in a rare code path: + +======================================================= +[ INFO: possible circular locking dependency detected ] +2.6.25-sched-devel.git-x86-latest.git #19 +------------------------------------------------------- +X/2980 is trying to acquire lock: + (&rq->rq_lock_key#2){++..}, at: [] task_rq_lock+0x56/0xa0 + +but task is already holding lock: + (&cpu_base->lock){++..}, at: [] lock_hrtimer_base+0x31/0x60 + +which lock already depends on the new lock. + +The scenario which leads to this is: + +posix-timer signal is delivered + -> posix-timer is rearmed + timer is already expired in hrtimer_enqueue() + -> softirq is raised + +To prevent this we need to move the raise of the softirq out of the +base->lock protected code path. + +Signed-off-by: Thomas Gleixner +Acked-by: Peter Zijlstra +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/hrtimer.c | 19 +++++++++++++++++-- + 1 file changed, 17 insertions(+), 2 deletions(-) + +--- a/kernel/hrtimer.c ++++ b/kernel/hrtimer.c +@@ -590,7 +590,6 @@ static inline int hrtimer_enqueue_reprog + list_add_tail(&timer->cb_entry, + &base->cpu_base->cb_pending); + timer->state = HRTIMER_STATE_PENDING; +- raise_softirq(HRTIMER_SOFTIRQ); + return 1; + default: + BUG(); +@@ -633,6 +632,11 @@ static int hrtimer_switch_to_hres(void) + return 1; + } + ++static inline void hrtimer_raise_softirq(void) ++{ ++ raise_softirq(HRTIMER_SOFTIRQ); ++} ++ + #else + + static inline int hrtimer_hres_active(void) { return 0; } +@@ -651,6 +655,7 @@ static inline int hrtimer_reprogram(stru + { + return 0; + } ++static inline void hrtimer_raise_softirq(void) { } + + #endif /* CONFIG_HIGH_RES_TIMERS */ + +@@ -850,7 +855,7 @@ hrtimer_start(struct hrtimer *timer, kti + { + struct hrtimer_clock_base *base, *new_base; + unsigned long flags; +- int ret; ++ int ret, raise; + + base = lock_hrtimer_base(timer, &flags); + +@@ -884,8 +889,18 @@ hrtimer_start(struct hrtimer *timer, kti + enqueue_hrtimer(timer, new_base, + new_base->cpu_base == &__get_cpu_var(hrtimer_bases)); + ++ /* ++ * The timer may be expired and moved to the cb_pending ++ * list. We can not raise the softirq with base lock held due ++ * to a possible deadlock with runqueue lock. ++ */ ++ raise = timer->state == HRTIMER_STATE_PENDING; ++ + unlock_hrtimer_base(timer, &flags); + ++ if (raise) ++ hrtimer_raise_softirq(); ++ + return ret; + } + EXPORT_SYMBOL_GPL(hrtimer_start); diff --git a/queue-2.6.25/series b/queue-2.6.25/series index 770b7b3af64..ab1d7c78e19 100644 --- a/queue-2.6.25/series +++ b/queue-2.6.25/series @@ -34,3 +34,4 @@ rdma-nes-fix-adapter-reset-after-pxe-boot.patch scsi-qla2xxx-correct-regression-in-relogin-code.patch alpha-unbreak-osf-1-binaries.patch x86-fix-32-bit-x86-msi-x-allocation-leakage.patch +hrtimer-raise-softirq-unlocked-to-avoid-circular-lock-dependency.patch -- 2.47.3