lkml.org 
[lkml]   [2012]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper
Date
From
> this_cpu_read
> |-----_this_cpu_generic_read
>
> #define _this_cpu_generic_read(pcp) \
> ({ typeof(pcp) ret__; \
> preempt_disable(); \
> ret__ = *this_cpu_ptr(&(pcp)); \
> preempt_enable(); \
> ret__; \
> })
>
>
> this_cpu_read operations locate per-cpu variable with preemption safe, not
> disable interrupts. why is it atomic vs interrupts?

Hmmm... what effect do those preemt_dis/enable() actually have?
Since a pre-empt can happen either side of them, the value
the caller sees can be for the wrong cpu anyway.

The only time I could see them being necessary is if
*this_cpu_ptr() itself needs mutex protection in order to
function correctly - and that is likely to be port specific.
On i386/amd64 where (I guess) it is an access offset by fs/gs
this isn't necessary and just wastes cpu cycles.

If the caller cares which cpu the value comes from (eg to
increment a counter) then the caller would need to disable
pre-emption across the whole operation.

David

\
 
 \ /
  Last update: 2012-11-01 17:21    [W:0.044 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site