lkml.org 
[lkml]   [2014]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: How do I increment a per-CPU variable without warning?
On Tue, Apr 15, 2014 at 03:17:55PM -0700, Paul E. McKenney wrote:

> My current admittedly crude workaround is as follows:
>
> static inline bool rcu_should_resched(void)
> {
> int t;
>
> #ifdef CONFIG_DEBUG_PREEMPT
> preempt_disable();
> #endif /* #ifdef CONFIG_DEBUG_PREEMPT */
> t = __this_cpu_read(rcu_cond_resched_count) + 1;
> if (t < RCU_COND_RESCHED_LIM) {
> __this_cpu_write(rcu_cond_resched_count, t);
> #ifdef CONFIG_DEBUG_PREEMPT
> preempt_enable();
> #endif /* #ifdef CONFIG_DEBUG_PREEMPT */
> return false;
> }
> #ifdef CONFIG_DEBUG_PREEMPT
> preempt_enable();
> #endif /* #ifdef CONFIG_DEBUG_PREEMPT */
> return true;
> }

Won't using DEBUG_PREEMPT instead of just CONFIG_PREEMPT here make this
silently do the wrong thing if preemption is enabled, but debugging isn't ?

I'm not seeing why you need the ifdefs at all, unless the implied
barrier() is a problem ?

Dave



\
 
 \ /
  Last update: 2014-04-16 00:41    [W:0.070 / U:7.968 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site