[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-ff960a731788a7408b6f66ec4fd772ff18833211@git.kernel.org>
Date: Tue, 4 Nov 2014 08:09:20 -0800
From: tip-bot for Peter Zijlstra <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: mingo@...nel.org, edumazet@...gle.com, david@...son.dropbear.id.au,
linux-kernel@...r.kernel.org, peterz@...radead.org,
tglx@...utronix.de, jhs@...atatu.com, teg@...m.no,
nicolas.dichtel@...nd.com, cwang@...pensource.com,
vyasevic@...hat.com, ebiederm@...ssion.com, jiri@...nulli.us,
vfalico@...il.com, oleg@...hat.com, torvalds@...ux-foundation.org,
hkchu@...gle.com, stephen@...workplumber.org,
john.fastabend@...il.com, therbert@...gle.com,
fengguang.wu@...el.com, sfeldma@...ulusnetworks.com,
davem@...emloft.net, hpa@...or.com
Subject: [tip:sched/core] netdev, sched/wait:
Fix sleeping inside wait event
Commit-ID: ff960a731788a7408b6f66ec4fd772ff18833211
Gitweb: http://git.kernel.org/tip/ff960a731788a7408b6f66ec4fd772ff18833211
Author: Peter Zijlstra <peterz@...radead.org>
AuthorDate: Wed, 29 Oct 2014 17:04:56 +0100
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Tue, 4 Nov 2014 07:17:48 +0100
netdev, sched/wait: Fix sleeping inside wait event
rtnl_lock_unregistering*() take rtnl_lock() -- a mutex -- inside a
wait loop. The wait loop relies on current->state to function, but so
does mutex_lock(), nesting them makes for the inner to destroy the
outer state.
Fix this using the new wait_woken() bits.
Reported-by: Fengguang Wu <fengguang.wu@...el.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Acked-by: David S. Miller <davem@...emloft.net>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Cong Wang <cwang@...pensource.com>
Cc: David Gibson <david@...son.dropbear.id.au>
Cc: Eric Biederman <ebiederm@...ssion.com>
Cc: Eric Dumazet <edumazet@...gle.com>
Cc: Jamal Hadi Salim <jhs@...atatu.com>
Cc: Jerry Chu <hkchu@...gle.com>
Cc: Jiri Pirko <jiri@...nulli.us>
Cc: John Fastabend <john.fastabend@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Nicolas Dichtel <nicolas.dichtel@...nd.com>
Cc: sfeldma@...ulusnetworks.com <sfeldma@...ulusnetworks.com>
Cc: stephen hemminger <stephen@...workplumber.org>
Cc: Tom Gundersen <teg@...m.no>
Cc: Tom Herbert <therbert@...gle.com>
Cc: Veaceslav Falico <vfalico@...il.com>
Cc: Vlad Yasevich <vyasevic@...hat.com>
Cc: netdev@...r.kernel.org
Link: http://lkml.kernel.org/r/20141029173110.GE15602@worktop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
net/core/dev.c | 10 +++++-----
net/core/rtnetlink.c | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index b793e35..c5a9d73 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7196,11 +7196,10 @@ static void __net_exit rtnl_lock_unregistering(struct list_head *net_list)
*/
struct net *net;
bool unregistering;
- DEFINE_WAIT(wait);
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ add_wait_queue(&netdev_unregistering_wq, &wait);
for (;;) {
- prepare_to_wait(&netdev_unregistering_wq, &wait,
- TASK_UNINTERRUPTIBLE);
unregistering = false;
rtnl_lock();
list_for_each_entry(net, net_list, exit_list) {
@@ -7212,9 +7211,10 @@ static void __net_exit rtnl_lock_unregistering(struct list_head *net_list)
if (!unregistering)
break;
__rtnl_unlock();
- schedule();
+
+ wait_woken(&wait, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
}
- finish_wait(&netdev_unregistering_wq, &wait);
+ remove_wait_queue(&netdev_unregistering_wq, &wait);
}
static void __net_exit default_device_exit_batch(struct list_head *net_list)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a688268..b095296 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -365,11 +365,10 @@ static void rtnl_lock_unregistering_all(void)
{
struct net *net;
bool unregistering;
- DEFINE_WAIT(wait);
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ add_wait_queue(&netdev_unregistering_wq, &wait);
for (;;) {
- prepare_to_wait(&netdev_unregistering_wq, &wait,
- TASK_UNINTERRUPTIBLE);
unregistering = false;
rtnl_lock();
for_each_net(net) {
@@ -381,9 +380,10 @@ static void rtnl_lock_unregistering_all(void)
if (!unregistering)
break;
__rtnl_unlock();
- schedule();
+
+ wait_woken(&wait, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
}
- finish_wait(&netdev_unregistering_wq, &wait);
+ remove_wait_queue(&netdev_unregistering_wq, &wait);
}
/**
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists