From: clameter@sgi.com
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org
Subject: [patch 04/10] SLUB: Conform more to SLABs SLAB_HWCACHE_ALIGN behavior
Date: Thu, 26 Apr 2007 21:26:59 -0700 [thread overview]
Message-ID: <20070427042908.236098804@sgi.com> (raw)
In-Reply-To: <20070427042655.019305162@sgi.com>
[-- Attachment #1: slub_hwalign --]
[-- Type: text/plain, Size: 2932 bytes --]
Currently SLUB is using a strict L1_CACHE_BYTES alignment if
SLAB_HWCACHE_ALIGN is specified. SLAB does not align to a cacheline if the
object is smaller than half of a cacheline. Small objects are then aligned
by SLAB to a fraction of a cacheline.
Make SLUB just forget about the alignment requirement if the object size
is less than L1_CACHE_BYTES. It seems that fractional alignments are no
good because they grow the object and reduce the object density in a cache
line needlessly causing additional cache line fetches.
If we are already throwing the user suggestion of a cache line alignment
away then lets do the best we can. Maybe SLAB_HWCACHE_ALIGN also needs
to be tossed given its wishy-washy handling but doing so would require
an audit of all kmem_cache_allocs throughout the kernel source.
In any case one needs to explictly specify an alignment during
kmem_cache_create to either slab allocator in order to ensure that the
objects are cacheline aligned.
[Patch has a nice memory compaction effect on 32 bit platforms]
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Index: linux-2.6.21-rc7-mm2/mm/slub.c
===================================================================
--- linux-2.6.21-rc7-mm2.orig/mm/slub.c 2007-04-26 11:41:15.000000000 -0700
+++ linux-2.6.21-rc7-mm2/mm/slub.c 2007-04-26 11:41:43.000000000 -0700
@@ -1483,9 +1483,19 @@ static int calculate_order(int size)
* various ways of specifying it.
*/
static unsigned long calculate_alignment(unsigned long flags,
- unsigned long align)
+ unsigned long align, unsigned long size)
{
- if (flags & SLAB_HWCACHE_ALIGN)
+ /*
+ * If the user wants hardware cache aligned objects then
+ * follow that suggestion if the object is sufficiently
+ * large.
+ *
+ * The hardware cache alignment cannot override the
+ * specified alignment though. If that is greater
+ * then use it.
+ */
+ if ((flags & SLAB_HWCACHE_ALIGN) &&
+ size > L1_CACHE_BYTES / 2)
return max_t(unsigned long, align, L1_CACHE_BYTES);
if (align < ARCH_SLAB_MINALIGN)
@@ -1674,7 +1684,7 @@ static int calculate_sizes(struct kmem_c
* user specified (this is unecessarily complex due to the attempt
* to be compatible with SLAB. Should be cleaned up some day).
*/
- align = calculate_alignment(flags, align);
+ align = calculate_alignment(flags, align, s->objsize);
/*
* SLUB stores one object immediately after another beginning from
@@ -2251,7 +2261,7 @@ static struct kmem_cache *find_mergeable
return NULL;
size = ALIGN(size, sizeof(void *));
- align = calculate_alignment(flags, align);
+ align = calculate_alignment(flags, align, size);
size = ALIGN(size, align);
list_for_each(h, &slab_caches) {
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-04-27 4:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-27 4:26 [patch 00/10] SLUB patches against 2.6.21-rc7-mm2 clameter
2007-04-27 4:26 ` [patch 01/10] SLUB: Remove duplicate VM_BUG_ON clameter
2007-04-27 4:26 ` [patch 02/10] SLUB: Fix sysfs directory handling clameter
2007-04-27 6:31 ` Andrew Morton
2007-04-27 7:02 ` Christoph Lameter
2007-04-27 7:10 ` Andrew Morton
2007-04-27 4:26 ` [patch 03/10] SLUB: debug printk cleanup clameter
2007-04-27 6:32 ` Andrew Morton
2007-04-27 4:26 ` clameter [this message]
2007-04-27 4:27 ` [patch 05/10] SLUB: Add MIN_PARTIAL clameter
2007-04-27 4:27 ` [patch 06/10] SLUB: Free slabs and sort partial slab lists in kmem_cache_shrink clameter
2007-04-27 4:27 ` [patch 07/10] SLUB: Major slabinfo update clameter
2007-04-27 4:27 ` [patch 08/10] SLUB: Reduce the order of allocations to avoid fragmentation clameter
2007-04-27 4:27 ` [patch 09/10] SLUB: Exploit page mobility to increase allocation order clameter
2007-04-27 6:32 ` Andrew Morton
2007-04-27 7:04 ` Christoph Lameter
2007-04-27 11:14 ` Mel Gorman
2007-04-27 17:15 ` Christoph Lameter
2007-04-27 4:27 ` [patch 10/10] SLUB: i386 support clameter
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=20070427042908.236098804@sgi.com \
--to=clameter@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
/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