From: Mike Galbraith <efault@gmx.de>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: net/sched: latent livelock in dev_deactivate_many() due to yield() usage
Date: Wed, 05 Apr 2017 05:20:29 +0200 [thread overview]
Message-ID: <1491362429.4536.77.camel@gmx.de> (raw)
In-Reply-To: <CAM_iQpWGMkDaoV2k0DEghqeqb9k=MbpBtT8zH3tvENxLUCefkQ@mail.gmail.com>
On Tue, 2017-04-04 at 15:39 -0700, Cong Wang wrote:
> Thanks for the report! Looks like a quick solution here is to replace
> this yield() with cond_resched(), it is harder to really wait for
> all qdisc's to transmit all packets.
No, cond_resched() won't help. What I did is below, but I suspect net
wizards will do something better.
---
net/sched/sch_generic.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/swait.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
@@ -901,6 +902,7 @@ static bool some_qdisc_is_busy(struct ne
*/
void dev_deactivate_many(struct list_head *head)
{
+ DECLARE_SWAIT_QUEUE_HEAD_ONSTACK(swait);
struct net_device *dev;
bool sync_needed = false;
@@ -924,8 +926,7 @@ void dev_deactivate_many(struct list_hea
/* Wait for outstanding qdisc_run calls. */
list_for_each_entry(dev, head, close_list)
- while (some_qdisc_is_busy(dev))
- yield();
+ swait_event_timeout(swait, !some_qdisc_is_busy(dev), 1);
}
void dev_deactivate(struct net_device *dev)
next prev parent reply other threads:[~2017-04-05 3:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-02 4:28 net/sched: latent livelock in dev_deactivate_many() due to yield() usage Mike Galbraith
2017-04-04 22:39 ` Cong Wang
2017-04-05 3:20 ` Mike Galbraith [this message]
2017-04-05 5:25 ` Cong Wang
2017-04-05 6:12 ` Mike Galbraith
2017-04-05 23:55 ` Cong Wang
2017-04-06 1:08 ` Mike Galbraith
2017-04-06 10:26 ` Peter Zijlstra
2017-04-06 0:31 ` Stephen Hemminger
2017-04-06 1:28 ` Mike Galbraith
2017-04-06 10:28 ` Peter Zijlstra
2017-04-06 11:08 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491362429.4536.77.camel@gmx.de \
--to=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.