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

Re: [PATCH] Cache aligned locks for PPC64

On Tue, May 13, 2003 at 12:56:13PM -0500, Steven Munroe wrote:
> In powerpc the memory reservations used for atomic updates are usually 
> associate with the (L1) cache line. For all current 64-bit 
> implementations this is 128-bytes. Since pthread_* locks are normally 
> smaller (32-56 bytes) than the cache line we can see false sharing 
> between adjacent locks in static and arrays. In extreme cases (100 
> threads contending for 10 mutexes) we can measure degradations of 40-70%.
> One way to address this to apply the __attribute__ ((__aligned__ 
> (__CACHE_ALIGN_SIZE))) to each lock type in 
> sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h. This does not 
> change the sizeof or array stride, but does force 128-byte alignment in 
> static and within containing structs. This insures that adjacent 
> pthread_locks are in different cache lines.
> Powerpc32 is more complicated. Older 32-bit processors have 32-byte 
> cache lines but 32-bit applications will run on 64-bit processors with 
> 128-byte cache line. The compromise is to set __CACHE_ALIGN_SIZE 
> 32-bytes for powerpc32. This correct for 32-bit processors and may 
> reduce some false sharing on 64-bit. The alterative would define 
> __CACHE_ALIGN_SIZE to empty (not attribute) for powerpc32.

Um... this represents an ABI change for PowerPC32.  I don't believe you
can just do this.  Anything with a lock declared in a structure will

> 2003-05-12  Steven Munroe <sjmunroe us ibm com>
> 	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
> 	(__CACHE_ALIGN_SIZE): Define.
> 	(pthread_mutex_t): Add __aligned__ attribute.
> 	(pthread_cond_t): Add __aligned__ attribute.
> 	(pthread_rwlock_t): Add __aligned__ attribute.
> 	(pthread_barrier_t): Add __aligned__ attribute.

Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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