Re: [patch 04/41] cpu ops: Core piece for generic atomic per cpu operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux