lkml.org 
[lkml]   [2015]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [for-next][PATCH 1/4] ring-buffer: Replace this_cpu_*() with __this_cpu_*()
On Wed, 25 Mar 2015, Steven Rostedt wrote:

> It has come to my attention that this_cpu_read/write are horrible on
> architectures other than x86. Worse yet, they actually disable
> preemption or interrupts! This caused some unexpected tracing results
> on ARM.

This isnt something new and I thought the comment was dropped from the
patch? This is a plain error in using this_cpu_* where __this_cpu_* would
have been sufficient. Code was uselessly disabling preemption twice.

> Which is unacceptable for locations that know they are within preempt
> disabled or interrupt disabled locations.

Well yes. Thats why the __this_cpu ops are there to avoid this
overhead.

> I also changed the recursive_unlock() to use two local variables instead
> of accessing the per_cpu variable twice.

Ok gotta look at that.

> static __always_inline void trace_recursive_unlock(void)
> {
> - unsigned int val = this_cpu_read(current_context);
> + unsigned int val = __this_cpu_read(current_context);
>
> - val--;
> - val &= this_cpu_read(current_context);
> - this_cpu_write(current_context, val);
> + val &= val & (val - 1);
> + __this_cpu_write(current_context, val);
> }

Ummm... This is does not look like an equivalent thing. Should this not
be:

unsigned int val = __this_cpu_read(current_context);
unsigned int newval = val - 1;

newval &= val;
__this_cpu_write(current_context, newval);

or more compact

unsigned int val = __this_cpu_read(current_context);

__this_cpu_write(current_context, val & (val - 1));



\
 
 \ /
  Last update: 2015-03-27 21:01    [W:0.066 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site