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:

> > 	local_irq_save(flags);
> > 	/* Calculate address of per processor area */
> > 	p = CPU_PTR(stat, smp_processor_id());
> > 	p->counter++;
> > 	local_irq_restore(flags);
> 
> eh?  That's what local_t is for?

No that is what local_t exactly cannot do.

> > The segment can be replaced by a single atomic CPU operation:
> > 
> > 	CPU_INC(stat->counter);
> 
> hm, I guess this _has_ to be implemented as a macro.  ho hum.  But
> please: "cpu_inc"?

A lowercase macro?

> > The existing methods in use in the kernel cannot utilize the power of
> > these atomic instructions. local_t is not really addressing the issue
> > since the offset calculation performed before the atomic operation. The
> > operation is therefor not atomic. Disabling interrupt or preemption is
> > required in order to use local_t.
> 
> Your terminology is totally confusing here.
> 
> To me, an "atomic operation" is one which is atomic wrt other CPUs:
> atomic_t, for example.
> 
> Here we're talking about atomic-wrt-this-cpu-only, yes?

Right.
 
> > local_t is also very specific to the x86 processor.
> 
> And alpha, m32r, mips and powerpc, methinks.  Probably others, but
> people just haven't got around to it.

No local_t does not do the relocation of the address to the correct percpu 
area. It requies disabling of interrupts etc. Its not atomic (wrt 
interrupts) because of that.
 
> I think I'll need to come back another time to understand all that ;)
> 
> Thanks for writing it up carefully.

Well this stuff is so large in scope that I have difficulties keeping 
everything straight.

> I wonder if all this stuff should be in a new header file.
> 
> We could get lazy and include that header from percpu.h if needed.

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

--
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