Simple #define for cache line size
John Baldwin
jhb at freebsd.org
Tue Apr 14 12:30:54 PDT 2009
On Monday 13 April 2009 7:05:20 pm Max Laier wrote:
> On Saturday 11 April 2009 18:11:55 Robert Watson wrote:
> > Dear all:
> >
> > We have a number of __aligned() qualifiers scattered around the kernel
> > intended to space objects to improve alignment with respect to cache lines.
> > This is important for a number of reasons, not least avoiding cache line
> > thrashing when using arrays of foo[MAXCPU]. What I'd like to do is provide
> > a single compile-time constant, CACHE_LINE_SIZE, defined in
> > machine-dependent param.h, to use for spacing such objects, rather than
> > hard-coding various values around. Here are some examples of existing
> > spacing attempts:
>
> How much does __aligned(FOO) even achieve? If we allocate these structs at
> runtime the alignment requirements have to be passed to the allocator as well
> (eg. uma(9)'s align parameter in uma_zcreate). If my assumption is correct it
> would make sense to have a global symbol that is initialized early in the boot
> process instead of a compile time #define.
>
> In addition it seems that we need to make the define a worst case value to
> assure correctness for static arrays as below.
Actually, we need both the boot-time tunable that UMA has I think and a
worst-case constant for static arrays. UMA already has the tunable and I
think it should remain (though we may want to provide a way for the MD code
to adjust its value). I think the constant is still needed for static arrays
and should also be used to initialize the constant in UMA.
--
John Baldwin
More information about the freebsd-arch
mailing list