* [PATCH] sched/core: Fix rq lock pinning warning after call balance callbacks
@ 2017-03-17 2:45 Wanpeng Li
2017-03-23 9:11 ` [tip:sched/core] " tip-bot for Wanpeng Li
0 siblings, 1 reply; 2+ messages in thread
From: Wanpeng Li @ 2017-03-17 2:45 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Peter Zijlstra, Wanpeng Li, Mike Galbraith, Thomas Gleixner
From: Wanpeng Li <wanpeng.li@hotmail.com>
This can be reproduced by running rt-migrate-test:
WARNING: CPU: 2 PID: 2195 at kernel/locking/lockdep.c:3670 lock_unpin_lock+0x172/0x180
unpinning an unpinned lock
CPU: 2 PID: 2195 Comm: rt-migrate-test Tainted: G W 4.11.0-rc2+ #1
Call Trace:
dump_stack+0x85/0xc2
__warn+0xcb/0xf0
warn_slowpath_fmt+0x5f/0x80
lock_unpin_lock+0x172/0x180
__balance_callback+0x75/0x90
__schedule+0x83f/0xc00
? futex_wait_setup+0x82/0x130
schedule+0x3d/0x90
futex_wait_queue_me+0xd4/0x170
futex_wait+0x119/0x260
? __lock_acquire+0x4c8/0x1900
? stop_one_cpu+0x94/0xc0
do_futex+0x2fe/0xc10
? sched_setaffinity+0x1c1/0x290
SyS_futex+0x81/0x190
? rcu_read_lock_sched_held+0x72/0x80
do_syscall_64+0x73/0x1f0
entry_SYSCALL64_slow_path+0x25/0x25
We utilize balance callbacks to delay the load-balancing operations
{rt,dl}*{push,pull} until we've done all the important work. The
push/pull operations can unlock/lock the current rq for safety acquires
the src's and dest's rq->locks in a fair way. It's safe to drop the
rq lock here, unpin and repin to avoid the splat.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
kernel/sched/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c762f62..cd901f6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2787,7 +2787,9 @@ static void __balance_callback(struct rq *rq)
head->next = NULL;
head = next;
+ rq_unpin_lock(rq, &rf);
func(rq);
+ rq_repin_lock(rq, &rf);
}
rq_unlock_irqrestore(rq, &rf);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:sched/core] sched/core: Fix rq lock pinning warning after call balance callbacks
2017-03-17 2:45 [PATCH] sched/core: Fix rq lock pinning warning after call balance callbacks Wanpeng Li
@ 2017-03-23 9:11 ` tip-bot for Wanpeng Li
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Wanpeng Li @ 2017-03-23 9:11 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, wanpeng.li, hpa, peterz, fengguang.wu, linux-kernel, tglx,
torvalds, efault
Commit-ID: d7921a5ddab8d30e06e321f37eec629f23797486
Gitweb: http://git.kernel.org/tip/d7921a5ddab8d30e06e321f37eec629f23797486
Author: Wanpeng Li <wanpeng.li@hotmail.com>
AuthorDate: Thu, 16 Mar 2017 19:45:19 -0700
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 23 Mar 2017 07:44:51 +0100
sched/core: Fix rq lock pinning warning after call balance callbacks
This can be reproduced by running rt-migrate-test:
WARNING: CPU: 2 PID: 2195 at kernel/locking/lockdep.c:3670 lock_unpin_lock()
unpinning an unpinned lock
...
Call Trace:
dump_stack()
__warn()
warn_slowpath_fmt()
lock_unpin_lock()
__balance_callback()
__schedule()
schedule()
futex_wait_queue_me()
futex_wait()
do_futex()
SyS_futex()
do_syscall_64()
entry_SYSCALL64_slow_path()
Revert the rq_lock_irqsave() usage here, the whole point of the
balance_callback() was to allow dropping rq->lock.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 8a8c69c32778 ("sched/core: Add rq->lock wrappers")
Link: http://lkml.kernel.org/r/1489718719-3951-1-git-send-email-wanpeng.li@hotmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c762f62..ab9f6ac 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2776,9 +2776,9 @@ static void __balance_callback(struct rq *rq)
{
struct callback_head *head, *next;
void (*func)(struct rq *rq);
- struct rq_flags rf;
+ unsigned long flags;
- rq_lock_irqsave(rq, &rf);
+ raw_spin_lock_irqsave(&rq->lock, flags);
head = rq->balance_callback;
rq->balance_callback = NULL;
while (head) {
@@ -2789,7 +2789,7 @@ static void __balance_callback(struct rq *rq)
func(rq);
}
- rq_unlock_irqrestore(rq, &rf);
+ raw_spin_unlock_irqrestore(&rq->lock, flags);
}
static inline void balance_callback(struct rq *rq)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-23 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 2:45 [PATCH] sched/core: Fix rq lock pinning warning after call balance callbacks Wanpeng Li
2017-03-23 9:11 ` [tip:sched/core] " tip-bot for Wanpeng Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.