From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Arnd Bergmann <arnd@arndb.de>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/2] sched: Drop the need_resched() loop from cond_resched()
Date: Fri, 10 Jul 2009 18:26:21 +0200 [thread overview]
Message-ID: <20090710162620.GD5318@nowhere> (raw)
In-Reply-To: <20090710161141.GC22049@elte.hu>
On Fri, Jul 10, 2009 at 06:11:41PM +0200, Ingo Molnar wrote:
>
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
>
> > On Fri, Jul 10, 2009 at 05:35:29PM +0200, Arnd Bergmann wrote:
> > > On Friday 10 July 2009, Frederic Weisbecker wrote:
> > > > On Fri, Jul 10, 2009 at 05:17:38PM +0200, Arnd Bergmann wrote:
> > > > > On Friday 10 July 2009, Frederic Weisbecker wrote:
> > > > > > --- a/kernel/sched.c
> > > > > > +++ b/kernel/sched.c
> > > > > > @@ -6613,11 +6613,9 @@ static void __cond_resched(void)
> > > > > > * PREEMPT_ACTIVE, which could trigger a second
> > > > > > * cond_resched() call.
> > > > > > */
> > > > > > - do {
> > > > > > - add_preempt_count(PREEMPT_ACTIVE);
> > > > > > - schedule();
> > > > > > - sub_preempt_count(PREEMPT_ACTIVE);
> > > > > > - } while (need_resched());
> > > > > > + add_preempt_count(PREEMPT_ACTIVE);
> > > > > > + schedule();
> > > > > > + sub_preempt_count(PREEMPT_ACTIVE);
> > > > > > }
> > > > > >
> > > > >
> > > > > If you drop the loop, then you should also remove the comment that
> > > > > explains why it was put there.
> > > > >
> > > >
> > > > Hmm, these comments seem to actually explain why we do the PREEMPT_ACTIVE
> > > > trick, which is to prevent from cond_resched() recursion, right?
> > > >
> > >
> > > I think we both misinterpreted the comment, which seemed to refer
> > > to older code added by Ingo in 5bbcfd900 "cond_resched(): fix bogus
> > > might_sleep() warning" and removed by Andrew in e7b384043e2
> > > "cond_resched() fix".
> > >
> > > The original code in Ingos version looked like
> > >
> > > static inline void __cond_resched(void)
> > > {
> > > /*
> > > * The BKS might be reacquired before we have dropped
> > > * PREEMPT_ACTIVE, which could trigger a second
> > > * cond_resched() call.
> > > */
> > > if (unlikely(preempt_count()))
> > > return;
> > > do {
> > > add_preempt_count(PREEMPT_ACTIVE);
> > > schedule();
> > > ...
> > >
> > >
> > > So, it's got nothing to do with the loop, but should still be removed
> > > because the 'if (unlikely(preempt_count()))' is no longer there.
> >
> >
> > Yeah, but the comment still fits the code after this patch, don't
> > you think? :-)
>
> ... except that there's no Big Kernel Semaphore anymore ;-)
>
> Ingo
Ah, I lack some backgrounds about Linux heroic ages :)
I thought it was a mispell of BKL.
I guess the comment should be removed anyway, while reading it
more, it doesn't explain the code that follows it.
next prev parent reply other threads:[~2009-07-10 16:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-10 14:49 [PATCH 1/2] sched: Drop the need_resched() loop from cond_resched() Frederic Weisbecker
2009-07-10 14:49 ` [PATCH 2/2] sched: Move the sleeping while atomic checks early in cond_resched() Frederic Weisbecker
2009-07-10 14:59 ` Peter Zijlstra
2009-07-10 15:08 ` Frederic Weisbecker
2009-07-10 15:12 ` Peter Zijlstra
2009-07-10 16:10 ` Ingo Molnar
2009-07-10 17:14 ` [PATCH] " Frederic Weisbecker
2009-07-10 17:43 ` Peter Zijlstra
2009-07-10 18:08 ` Frederic Weisbecker
2009-07-10 18:13 ` Peter Zijlstra
2009-07-10 18:29 ` Frederic Weisbecker
2009-07-10 15:00 ` [PATCH 1/2] sched: Drop the need_resched() loop from cond_resched() Peter Zijlstra
2009-07-10 15:17 ` Arnd Bergmann
2009-07-10 15:24 ` Frederic Weisbecker
2009-07-10 15:35 ` Arnd Bergmann
2009-07-10 15:50 ` Frederic Weisbecker
2009-07-10 16:11 ` Ingo Molnar
2009-07-10 16:26 ` Frederic Weisbecker [this message]
2009-07-10 17:23 ` [PATCH] sched: Remove obsolete comment in __cond_resched() Frederic Weisbecker
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=20090710162620.GD5318@nowhere \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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.