public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Yong Zhang <yong.zhang0@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched: reassign prev and switch_count when  reacquire_kernel_lock() fail
Date: Tue, 12 Jan 2010 11:16:23 +0100	[thread overview]
Message-ID: <1263291383.4244.109.camel@laptop> (raw)
In-Reply-To: <2674af741001102238w7b0ddcadref00d345e2181d11@mail.gmail.com>

On Mon, 2010-01-11 at 14:38 +0800, Yong Zhang wrote:
> From 4c04fbbd43f3fef7a3b9471a0000c399c2e045ed Mon Sep 17 00:00:00 2001
> From: Yong Zhang <yong.zhang0@gmail.com>
> Date: Mon, 11 Jan 2010 14:21:25 +0800
> Subject: [PATCH] sched: reassign prev and switch_count when
> reacquire_kernel_lock() fail
> 
> Assume A->B schedule is processing, if B have acquired BKL before and
> it need reschedule this time. Then on B's context, it will go to
> need_resched_nonpreemptible for reschedule. But at this time, prev
> and switch_count are related to A. It's wrong and will lead to
> incorrect scheduler statistics.
> 
> Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>

Looks good, picked it up, thanks!

> ---
>  kernel/sched.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/sched.c b/kernel/sched.c
> index c535cc4..4508fe7 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -5530,8 +5530,11 @@ need_resched_nonpreemptible:
> 
>  	post_schedule(rq);
> 
> -	if (unlikely(reacquire_kernel_lock(current) < 0))
> +	if (unlikely(reacquire_kernel_lock(current) < 0)) {
> +		prev = rq->curr;
> +		switch_count = &prev->nivcsw;
>  		goto need_resched_nonpreemptible;
> +	}
> 
>  	preempt_enable_no_resched();
>  	if (need_resched())



  reply	other threads:[~2010-01-12 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-11  6:38 [PATCH] sched: reassign prev and switch_count when reacquire_kernel_lock() fail Yong Zhang
2010-01-12 10:16 ` Peter Zijlstra [this message]
2010-01-21 13:51 ` [tip:sched/urgent] sched: Reassign " tip-bot for Yong Zhang

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=1263291383.4244.109.camel@laptop \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=yong.zhang0@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