public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use raw_smp_processor_id() in rcu_random()
@ 2007-10-12  9:20 Gautham R Shenoy
  2007-10-12  9:39 ` Josh Triplett
  2007-10-12 19:21 ` Paul E. McKenney
  0 siblings, 2 replies; 3+ messages in thread
From: Gautham R Shenoy @ 2007-10-12  9:20 UTC (permalink / raw)
  To: Paul E McKenney, josh
  Cc: linux-kernel, Andrew Morton, Oleg Nesterov, Dipankar Sarma,
	rostedt


With CONFIG_PREEMPT=y on 2.6.23-rc8-mm2, rcu_random() calls 
smp_processor_id() from a preemptible context, triggering the
following kernel error.

BUG: using smp_processor_id() in preemptible [00000001] code: rcu_torture_fak/5155
caller is rcu_random+0x16/0x39 [rcutorture]
 [<c010612f>] dump_trace+0x68/0x1d2
 [<c01062b1>] show_trace_log_lvl+0x18/0x2c
 [<c0106c23>] show_trace+0xf/0x11
 [<c0106d33>] dump_stack+0x12/0x14
 [<c02a0a25>] debug_smp_processor_id+0xa1/0xb4
 [<f887064c>] rcu_random+0x16/0x39 [rcutorture]
 [<f8870cdf>] <3>BUG: using smp_processor_id() in preemptible [00000001] code: rcu_torture_fak/5156
rcu_torture_fakewriter+0x4d/0xc5 [rcutorture]
 [<c0139b32>] caller is rcu_random+0x16/0x39 [rcutorture]
kthread+0x38/0x5e
 [<c0105ca7>] kernel_thread_helper+0x7/0x10
 =======================
 [<c010612f>] dump_trace+0x68/0x1d2
 [<c01062b1>] show_trace_log_lvl+0x18/0x2c
 [<c0106c23>] show_trace+0xf/0x11
 [<c0106d33>] dump_stack+0x12/0x14
 [<c02a0a25>] debug_smp_processor_id+0xa1/0xb4
 [<f887064c>] rcu_random+0x16/0x39 [rcutorture]
 [<f8870cdf>] rcu_torture_fakewriter+0x4d/0xc5 [rcutorture]

rcu_random() can do with raw_smp_processor_id() as a parameter to cpu_clock()
in this particular context.

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>

---
 kernel/rcutorture.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.23-rc8/kernel/rcutorture.c
===================================================================
--- linux-2.6.23-rc8.orig/kernel/rcutorture.c
+++ linux-2.6.23-rc8/kernel/rcutorture.c
@@ -170,7 +170,8 @@ static unsigned long
 rcu_random(struct rcu_random_state *rrsp)
 {
 	if (--rrsp->rrs_count < 0) {
-		rrsp->rrs_state += (unsigned long)cpu_clock(smp_processor_id());
+		rrsp->rrs_state +=
+			(unsigned long)cpu_clock(raw_smp_processor_id());
 		rrsp->rrs_count = RCU_RANDOM_REFRESH;
 	}
 	rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
-- 
Gautham R Shenoy
Linux Technology Center
IBM India.
"Freedom comes with a price tag of responsibility, which is still a bargain,
because Freedom is priceless!"

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

* Re: [PATCH] Use raw_smp_processor_id() in rcu_random()
  2007-10-12  9:20 [PATCH] Use raw_smp_processor_id() in rcu_random() Gautham R Shenoy
@ 2007-10-12  9:39 ` Josh Triplett
  2007-10-12 19:21 ` Paul E. McKenney
  1 sibling, 0 replies; 3+ messages in thread
From: Josh Triplett @ 2007-10-12  9:39 UTC (permalink / raw)
  To: ego
  Cc: Paul E McKenney, linux-kernel, Andrew Morton, Oleg Nesterov,
	Dipankar Sarma, rostedt

Gautham R Shenoy wrote:
> With CONFIG_PREEMPT=y on 2.6.23-rc8-mm2, rcu_random() calls 
> smp_processor_id() from a preemptible context, triggering the
> following kernel error.
> 
> BUG: using smp_processor_id() in preemptible [00000001] code: rcu_torture_fak/5155
> caller is rcu_random+0x16/0x39 [rcutorture]
>  [<c010612f>] dump_trace+0x68/0x1d2
>  [<c01062b1>] show_trace_log_lvl+0x18/0x2c
>  [<c0106c23>] show_trace+0xf/0x11
>  [<c0106d33>] dump_stack+0x12/0x14
>  [<c02a0a25>] debug_smp_processor_id+0xa1/0xb4
>  [<f887064c>] rcu_random+0x16/0x39 [rcutorture]
>  [<f8870cdf>] <3>BUG: using smp_processor_id() in preemptible [00000001] code: rcu_torture_fak/5156
> rcu_torture_fakewriter+0x4d/0xc5 [rcutorture]
>  [<c0139b32>] caller is rcu_random+0x16/0x39 [rcutorture]
> kthread+0x38/0x5e
>  [<c0105ca7>] kernel_thread_helper+0x7/0x10
>  =======================
>  [<c010612f>] dump_trace+0x68/0x1d2
>  [<c01062b1>] show_trace_log_lvl+0x18/0x2c
>  [<c0106c23>] show_trace+0xf/0x11
>  [<c0106d33>] dump_stack+0x12/0x14
>  [<c02a0a25>] debug_smp_processor_id+0xa1/0xb4
>  [<f887064c>] rcu_random+0x16/0x39 [rcutorture]
>  [<f8870cdf>] rcu_torture_fakewriter+0x4d/0xc5 [rcutorture]
> 
> rcu_random() can do with raw_smp_processor_id() as a parameter to cpu_clock()
> in this particular context.
> 
> Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>

Looks reasonable to me.

Acked-by: Josh Triplett <josh@kernel.org> 


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

* Re: [PATCH] Use raw_smp_processor_id() in rcu_random()
  2007-10-12  9:20 [PATCH] Use raw_smp_processor_id() in rcu_random() Gautham R Shenoy
  2007-10-12  9:39 ` Josh Triplett
@ 2007-10-12 19:21 ` Paul E. McKenney
  1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2007-10-12 19:21 UTC (permalink / raw)
  To: Gautham R Shenoy
  Cc: josh, linux-kernel, Andrew Morton, Oleg Nesterov, Dipankar Sarma,
	rostedt

On Fri, Oct 12, 2007 at 02:50:44PM +0530, Gautham R Shenoy wrote:
> 
> With CONFIG_PREEMPT=y on 2.6.23-rc8-mm2, rcu_random() calls 
> smp_processor_id() from a preemptible context, triggering the
> following kernel error.
> 
> BUG: using smp_processor_id() in preemptible [00000001] code: rcu_torture_fak/5155
> caller is rcu_random+0x16/0x39 [rcutorture]
>  [<c010612f>] dump_trace+0x68/0x1d2
>  [<c01062b1>] show_trace_log_lvl+0x18/0x2c
>  [<c0106c23>] show_trace+0xf/0x11
>  [<c0106d33>] dump_stack+0x12/0x14
>  [<c02a0a25>] debug_smp_processor_id+0xa1/0xb4
>  [<f887064c>] rcu_random+0x16/0x39 [rcutorture]
>  [<f8870cdf>] <3>BUG: using smp_processor_id() in preemptible [00000001] code: rcu_torture_fak/5156
> rcu_torture_fakewriter+0x4d/0xc5 [rcutorture]
>  [<c0139b32>] caller is rcu_random+0x16/0x39 [rcutorture]
> kthread+0x38/0x5e
>  [<c0105ca7>] kernel_thread_helper+0x7/0x10
>  =======================
>  [<c010612f>] dump_trace+0x68/0x1d2
>  [<c01062b1>] show_trace_log_lvl+0x18/0x2c
>  [<c0106c23>] show_trace+0xf/0x11
>  [<c0106d33>] dump_stack+0x12/0x14
>  [<c02a0a25>] debug_smp_processor_id+0xa1/0xb4
>  [<f887064c>] rcu_random+0x16/0x39 [rcutorture]
>  [<f8870cdf>] rcu_torture_fakewriter+0x4d/0xc5 [rcutorture]
> 
> rcu_random() can do with raw_smp_processor_id() as a parameter to cpu_clock()
> in this particular context.

Good catch!!!

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
> 
> ---
>  kernel/rcutorture.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6.23-rc8/kernel/rcutorture.c
> ===================================================================
> --- linux-2.6.23-rc8.orig/kernel/rcutorture.c
> +++ linux-2.6.23-rc8/kernel/rcutorture.c
> @@ -170,7 +170,8 @@ static unsigned long
>  rcu_random(struct rcu_random_state *rrsp)
>  {
>  	if (--rrsp->rrs_count < 0) {
> -		rrsp->rrs_state += (unsigned long)cpu_clock(smp_processor_id());
> +		rrsp->rrs_state +=
> +			(unsigned long)cpu_clock(raw_smp_processor_id());
>  		rrsp->rrs_count = RCU_RANDOM_REFRESH;
>  	}
>  	rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD;
> -- 
> Gautham R Shenoy
> Linux Technology Center
> IBM India.
> "Freedom comes with a price tag of responsibility, which is still a bargain,
> because Freedom is priceless!"

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

end of thread, other threads:[~2007-10-12 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-12  9:20 [PATCH] Use raw_smp_processor_id() in rcu_random() Gautham R Shenoy
2007-10-12  9:39 ` Josh Triplett
2007-10-12 19:21 ` Paul E. McKenney

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