lkml.org 
[lkml]   [2009]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 1/2] sched: Drop the need_resched() loop from cond_resched()
    From
    Date
    On Fri, 2009-07-10 at 16:49 +0200, Frederic Weisbecker wrote:
    > The schedule() function is a loop that reschedules the current task
    > while the TIF_NEED_RESCHED flag is set:
    >
    > void schedule(void)
    > {
    > need_resched:
    > /* schedule code */
    > if (need_resched())
    > goto need_resched;
    > }
    >
    > And cond_resched() repeat this loop:
    >
    > do {
    > add_preempt_count(PREEMPT_ACTIVE);
    > schedule();
    > sub_preempt_count(PREEMPT_ACTIVE);
    > } while(need_resched());
    >
    > This loop is needless because schedule() already did the check and
    > nothing can set TIF_NEED_RESCHED between schedule() exit and the loop
    > check in need_resched().
    >
    > Then remove this needless loop.
    >
    > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>

    Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

    > ---
    > kernel/sched.c | 8 +++-----
    > 1 files changed, 3 insertions(+), 5 deletions(-)
    >
    > diff --git a/kernel/sched.c b/kernel/sched.c
    > index 4d1e387..87ecac1 100644
    > --- 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);
    > }
    >
    > int __sched _cond_resched(void)



    \
     
     \ /
      Last update: 2009-07-10 17:03    [W:6.761 / U:0.648 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site