public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: reassign prev and switch_count when  reacquire_kernel_lock() fail
@ 2010-01-11  6:38 Yong Zhang
  2010-01-12 10:16 ` Peter Zijlstra
  2010-01-21 13:51 ` [tip:sched/urgent] sched: Reassign " tip-bot for Yong Zhang
  0 siblings, 2 replies; 3+ messages in thread
From: Yong Zhang @ 2010-01-11  6:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Peter Zijlstra, Thomas Gleixner

>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>
---
 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())
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: reassign prev and switch_count when  reacquire_kernel_lock() fail
  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
  2010-01-21 13:51 ` [tip:sched/urgent] sched: Reassign " tip-bot for Yong Zhang
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2010-01-12 10:16 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel, Ingo Molnar, Thomas Gleixner

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())



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:sched/urgent] sched: Reassign prev and switch_count when reacquire_kernel_lock() fail
  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
@ 2010-01-21 13:51 ` tip-bot for Yong Zhang
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Yong Zhang @ 2010-01-21 13:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, yong.zhang0, tglx, mingo

Commit-ID:  6d558c3ac9b6508d26fd5cadccce51fc9d726b1c
Gitweb:     http://git.kernel.org/tip/6d558c3ac9b6508d26fd5cadccce51fc9d726b1c
Author:     Yong Zhang <yong.zhang0@gmail.com>
AuthorDate: Mon, 11 Jan 2010 14:21:25 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 21 Jan 2010 13:39:04 +0100

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>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <2674af741001102238w7b0ddcadref00d345e2181d11@mail.gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 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())

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-01-21 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2010-01-21 13:51 ` [tip:sched/urgent] sched: Reassign " tip-bot for Yong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox