netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Mike Galbraith <efault@gmx.de>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: [Patch net] net_sched: replace yield() with cond_resched()
Date: Thu, 6 Apr 2017 18:13:55 -0400	[thread overview]
Message-ID: <20170406181355.7fc4353a@plumbers-lap.home.lan> (raw)
In-Reply-To: <1491443659.4718.57.camel@gmx.de>

On Thu, 06 Apr 2017 03:54:19 +0200
Mike Galbraith <efault@gmx.de> wrote:

> On Wed, 2017-04-05 at 16:42 -0700, Cong Wang wrote:
> > On Tue, Apr 4, 2017 at 10:56 PM, Mike Galbraith <efault@gmx.de> wrote:  
> > > On Tue, 2017-04-04 at 22:19 -0700, Cong Wang wrote:  
> > > > On Tue, Apr 4, 2017 at 8:55 PM, Mike Galbraith <efault@gmx.de> wrote:  
> > >   
> > > > > That won't help, cond_resched() has the same impact upon a lone
> > > > > SCHED_FIFO task as yield() does.. none.  
> > > > 
> > > > Hmm? In the comment you quote:
> > > > 
> > > >  * If you want to use yield() to wait for something, use wait_event().
> > > >  * If you want to use yield() to be 'nice' for others, use cond_resched().
> > > > 
> > > > So if cond_resched() doesn't help, why this misleading comment?  
> > > 
> > > This is not an oh let's be nice guys thing, it's a perfect match of...
> > > 
> > > 
> > >  * while (!event)
> > >  *      yield();  
> > > (/copy/paste>  
> > > 
> > > ..get off the CPU until this happens thing.  With nobody to yield the C
> > > PU to, some_qdisc_is_busy() will remain true forever more.  
> > 
> > 
> > This is exactly the misleading part, a while-loop waiting for an event
> > can always be a be-nice-for-others thing, because if not we can just
> > spin as a spinlock.  
> 
> Ah, but the kworker _is_ spinning on a 'lock' or sorts, starving the
> 'owner', ergo this polling loop fails the 'may be nice' litmus test. 
>  No polling loop is safe without a guarantee that the polling thread
> cannot block the loop breaking event.
> 
> 	-Mike

Why not replace yield with msleep(1) which gets rid of the inversion
issues?

  reply	other threads:[~2017-04-06 22:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05  1:52 [Patch net] net_sched: replace yield() with cond_resched() Cong Wang
2017-04-05  3:55 ` Mike Galbraith
2017-04-05  5:19   ` Cong Wang
2017-04-05  5:56     ` Mike Galbraith
2017-04-05 23:42       ` Cong Wang
2017-04-06  1:54         ` Mike Galbraith
2017-04-06 22:13           ` Stephen Hemminger [this message]
2017-04-07  3:59             ` Mike Galbraith

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=20170406181355.7fc4353a@plumbers-lap.home.lan \
    --to=stephen@networkplumber.org \
    --cc=efault@gmx.de \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).