From: Manfred Spraul <manfred@colorfullife.com>
To: Mark Hemment <markhe@veritas.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Q: explicit alignment control for the slab allocator
Date: Thu, 01 Mar 2001 22:55:47 +0100 [thread overview]
Message-ID: <3A9EC563.C450FAD3@colorfullife.com> (raw)
In-Reply-To: <Pine.LNX.4.21.0103012011160.11260-100000@alloc>
Mark Hemment wrote:
>
> On Thu, 1 Mar 2001, Manfred Spraul wrote:
>
> > Mark Hemment wrote:
> > >
> > > The original idea behind offset was for objects with a "hot" area
> > > greater than a single L1 cache line. By using offset correctly (and to my
> > > knowledge it has never been used anywhere in the Linux kernel), a SLAB
> > > cache creator (caller of kmem_cache_create()) could ask the SLAB for more
> > > than one colour (space/L1 cache lines) offset between objects.
> > >
> >
> > What's the difference between this definition of 'offset' and alignment?
>
> The positioning of the first object within a slab (at least that is how
> it is suppose to work).
>
> The distance between all objects within a slab is constant, so the
> colouring of objects depends upon the cache line (offset) the first object
> is placed on.
> The alignment is the boundary objects fall upon within a slab. This may
> require 'padding' between the objects so they fall on the correct
> boundaries (ie. they aren't a 'natural' size).
> For kmem_cache_create(), a zero offset means the offset is the same as
> the alignment.
>
> Take the case of offset being 64, and alignment being 32.
> Here, the allocator attempts to place the first object on a 64byte
> boundary (say, at offset 0), and all subsequent objects (within the same
> cache) on a 32byte boundary.
> Now, when it comes to construct the next slab, it tries to place the
> first object 64bytes offset from the first object in the previous
> slab (say, at offset 64). The distance between the objects is still the
> same - ie. they fall on 32byte boundaries.
>
> See the difference?
>
Yes, I see the difference, but I'm not sure that it will work as
intended.
offset must be a multiple of the alignment, everything else won't work.
In which cases an offset > alignment is really a win?
Obviously using offset 32 bytes for a structure with a 64 byte hot zone
means that 2 slabs with a different "color" compete for the same cache
lines [just assuming 32 byte cache lines for simplicity] in 50% of the
cases, but otoh offset==64 halfs the number of possible colors.
--
Manfred
next prev parent reply other threads:[~2001-03-01 21:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-01 17:26 Q: explicit alignment control for the slab allocator Manfred Spraul
2001-03-01 18:09 ` Mark Hemment
2001-03-01 19:55 ` Manfred Spraul
2001-03-01 20:28 ` Mark Hemment
2001-03-01 21:55 ` Manfred Spraul [this message]
2001-03-02 10:59 ` Mark Hemment
2001-03-02 11:51 ` Manfred Spraul
2001-03-02 12:39 ` Mark Hemment
2001-03-02 13:22 ` Manfred Spraul
2001-03-07 20:02 ` Jes Sorensen
2001-03-07 20:32 ` Manfred Spraul
2001-03-08 17:30 ` Jes Sorensen
2001-03-01 19:22 ` David S. Miller
2001-03-01 19:47 ` Manfred Spraul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3A9EC563.C450FAD3@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markhe@veritas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox