On Thu, 20 Jan 2011 11:59:03 +0800 Dennis Ferguson <[email protected]> wrote:
> Hello, > > Is there a way to obtain the correct cache line size for the machine > code is running on, both in the kernel and at user level? I see > there is a compile time constant CACHE_LINE_SIZE in <sys/param.h> > which currently seems to be always be set to 64, but I'm pretty > certain that is not necessarily a correct value. For example, I'm > pretty sure that for the PowerPC 32 and 128 are possibilities, and > the same binary could run on machines with either line size so there > is no correct compile-time answer. You probably won't find many processors with cache lines greater than 64 bytes. If you're optimising for a particular processor, read technical manuals to find out the size of cache lines, then simply define CACHE_LINE_SIZE or whatever compile time constant you're using to a different value.
