Simple #define for cache line size

Bruce Evans brde at optusnet.com.au
Sat Apr 11 14:10:05 PDT 2009


On Sat, 11 Apr 2009, Jason Evans wrote:

> Robert Watson wrote:
>> Index: arm/include/param.h
>> ===================================================================
>> --- arm/include/param.h    (revision 190941)
>> +++ arm/include/param.h    (working copy)
>> @@ -81,6 +81,10 @@
>>  #define    ALIGNBYTES    _ALIGNBYTES
>>  #define    ALIGN(p)    _ALIGN(p)
>> 
>> +#ifndef CACHE_LINE_SIZE
>> +#define    CACHE_LINE_SIZE    64
>> +#endif
>> +
>>  #define    PAGE_SHIFT    12
>>  #define    PAGE_SIZE    (1 << PAGE_SHIFT)    /* Page size */
>>  #define    PAGE_MASK    (PAGE_SIZE - 1)
>> Index: powerpc/include/param.h
>
> It would be helpful to instead do:
>
> #ifndef CACHE_LINE_SHIFT
> #define	CACHE_LINE_SHIFT 6
> #endif
> #define	CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT)
>
> In particular, src/lib/libc/stdlib/malloc.c would benefit.

It shouldn't be ifdefed, since it isn't an option and any override of
the definition would tend to give binary incompatibilities, especially
if it is used in userland (userland can't match kernel options or know
if they are matched).  FreeBSD already has too many non-options like
this.  CACHE_LINE_* is mainly advisory but would still cause binary
incompatibilities when it is used for array sizes.

Bruce


More information about the freebsd-arch mailing list