From: William Lee Irwin III <wli@holomorphy.com>
To: manfred@colorfullife.com
Cc: mpm@selenic.com, linux-kernel@vger.kernel.org
Subject: slab redzoning
Date: Fri, 21 May 2004 20:49:02 -0700 [thread overview]
Message-ID: <20040522034902.GB2161@holomorphy.com> (raw)
The code does not appear to match the intent for slab redzoning sizing.
It wants to ignore size increases when order 0 allocations are involved,
and otherwise to allow the size increase except when it would make the
size cross a power of 2 boundary.
This actually came under scrutiny during a discussion of fls() usage,
but there appears to be little that can be done there.
The following patch attempts to correct this variation of code from
intent and to document the intent in more detail. Untested.
One thing that could happen is to change or clarify what's trying to
be done to be something other than what I've arranged this to do. The
important point is that the current code doesn't match the intent.
Index: mm4-2.6.6/mm/slab.c
===================================================================
--- mm4-2.6.6.orig/mm/slab.c 2004-05-21 14:30:17.000000000 -0700
+++ mm4-2.6.6/mm/slab.c 2004-05-21 20:13:07.892507000 -0700
@@ -1158,8 +1158,21 @@
* large objects, if the increased size would increase the object size
* above the next power of two: caches with object sizes just above a
* power of two have a significant amount of internal fragmentation.
+ *
+ * The situation we're trying to avoid is there being a power of 2,
+ * 2**n for some n, where size < 2**n <= size + 3*BYTES_PER_WORD,
+ * but excepting anything smaller than a page.
+ * PAGE_SIZE >= 1024 and 3*BYTES_PER_WORD <= 24 so ignore the
+ * case where size would more than double from redzone overhead
+ * in this check; it's taken care of by checking for <= PAGE_SIZE.
+ * 1 << fls(size) is the next power of 2 above size, so then
+ * this checks that size is more than 3*BYTES_PER_WORD below it.
+ * This also special cases the case where size is a power of 2,
+ * where fragmentation would be increased greatly.
*/
- if ((size < 4096 || fls(size-1) == fls(size-1+3*BYTES_PER_WORD)))
+ if (size + 3*BYTES_PER_WORD <= PAGE_SIZE ||
+ ((size & (size - 1)) &&
+ (1 << fls(size)) - size > 3*BYTES_PER_WORD))
flags |= SLAB_RED_ZONE|SLAB_STORE_USER;
flags |= SLAB_POISON;
#endif
next reply other threads:[~2004-05-22 3:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-22 3:49 William Lee Irwin III [this message]
2004-05-22 8:02 ` slab redzoning Manfred Spraul
2004-05-22 8:26 ` William Lee Irwin III
2004-05-22 8:43 ` Manfred Spraul
2004-05-22 8:52 ` William Lee Irwin III
2004-05-22 12:22 ` 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=20040522034902.GB2161@holomorphy.com \
--to=wli@holomorphy.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=mpm@selenic.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