lkml.org 
[lkml]   [2008]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 04/41] cpu ops: Core piece for generic atomic per cpu operations
On Thu, 29 May 2008, Andrew Morton wrote:

> > area. It requies disabling of interrupts etc.
>
> No it doesn't. Look:
>
> static inline void local_inc(local_t *l)
> {
> asm volatile(_ASM_INC "%0"
> : "+m" (l->a.counter));
> }
>
> > Its not atomic (wrt
> > interrupts) because of that.
> >
>
> Yes it is.

No its not! In order to increment a per cpu value you need to calculate
the per cpu pointer address in the current per cpu segment. local_t
cannot do that in an atomic (wrt interrupt/preempt fashion) fashion. cpu
ops can use a segment prefix and thus the insructions can calculate the
per cpu adress and perform the atomic inc without disabling preempt or
interrupts.

local_t is only useful when you disable interrupt or premption otherwise.
But then you could also use a regular increment.

> > But then its related to percpu operations and relies extensively on the
> > various percpu.h files in asm-generic and asm-arch and include/linux
>
> Well that should be fixed. We should never have mixed the
> alloc_percpu() and DEFINE_PER_CPU things inthe same header. They're
> different.

With cpu_alloc they are the same. They allocate from the same per cpu
area.



\
 
 \ /
  Last update: 2008-05-30 08:15    [W:0.118 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site