From: Linus Torvalds <torvalds@linux-foundation.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <clameter@sgi.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Srinivasa Ds <srinivasa@in.ibm.com>,
linux-kernel@vger.kernel.org,
Srivatsa Vaddagiri <vatsa@in.ibm.com>,
Dinakar Guniguntala <dino@in.ibm.com>,
pj@sgi.com, simon.derr@bull.net, clameter@cthulhu.engr.sgi.com,
rientjes@google.com
Subject: Re: [RFC] [PATCH] cpuset operations causes Badness at mm/slab.c:777 warning
Date: Fri, 1 Jun 2007 16:25:13 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.98.0706011615480.3957@woody.linux-foundation.org> (raw)
In-Reply-To: <20070601160241.33b304bf.akpm@linux-foundation.org>
On Fri, 1 Jun 2007, Andrew Morton wrote:
>
> We could store the size of the allocation in the allocated object? Just
> add four bytes to the user's request, then pick the appropriate cache based
> on that, then put the user's `size' at the tail of the resulting allocation?
It should be easy enough to do it for _most_ allocations by just doing it
when there is already "enough slack" to do it (which is likely true most
of the time).
IOW, if you ask for a 42-byte allocation, and we allocate from a 64-byte
slab, you get the slab allocation at address X, you don't actually have to
return "X" at all. Just return "X+8", and then you do:
- at 32-bit word at X+0 you put the "real length"
- at 32-bit word at X+4 you put some good redzone marker
- at 32-bit word at "X + reallen + 8" you put the endzone marker.
And then you say: if the real length was within 12 bytes of the allocation
length, we just don't do this.
So you wouldn't get any redzoning for those allocations that are exactly
sized (or close enough) to fit in an allocation block, but I bet *most*
allocations would get this for free.
And then, if you actually turn on redzoning, you just always add the 12
byte to the allocation size (assuming the alignment rules allow you to).
The nice thing about this is that the freeing path already knows where the
object is *supposed* to start (because it sees the allocation size in the
slub/slab data structures), so the kfree() path can actually figure out on
its own whether it is given a "X" or an "X+8" kind of address.
So you don't actually need any extra information. You literally just need
enough slop in the allocation that you can do this in the first place, so
there is no cost (except for the cost of checking itself, of course).
Hmm?
Linus
next prev parent reply other threads:[~2007-06-01 23:26 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-01 7:27 Srinivasa Ds
2007-06-01 10:50 ` Srinivasa Ds
2007-06-01 18:13 ` Christoph Lameter
2007-06-01 19:11 ` Paul Jackson
2007-06-01 19:18 ` Christoph Lameter
2007-06-01 19:47 ` Paul Jackson
2007-06-01 19:51 ` Christoph Lameter
2007-06-01 20:02 ` Paul Jackson
2007-06-01 20:06 ` Christoph Lameter
2007-06-01 20:19 ` Paul Jackson
2007-06-01 20:43 ` Christoph Lameter
2007-06-01 20:54 ` Paul Jackson
2007-06-01 20:30 ` Jeremy Fitzhardinge
2007-06-01 20:44 ` Paul Jackson
2007-06-01 20:47 ` Christoph Lameter
2007-06-01 20:56 ` Jeremy Fitzhardinge
2007-06-01 20:59 ` Andrew Morton
2007-06-01 21:45 ` Christoph Lameter
2007-06-01 22:16 ` Andrew Morton
2007-06-01 22:20 ` Christoph Lameter
2007-06-01 22:33 ` Andrew Morton
2007-06-01 22:41 ` Christoph Lameter
2007-06-01 23:00 ` Linus Torvalds
2007-06-01 23:29 ` Christoph Lameter
2007-06-01 23:41 ` Linus Torvalds
2007-06-01 23:46 ` Christoph Lameter
2007-06-01 23:57 ` Linus Torvalds
2007-06-02 0:12 ` Christoph Lameter
2007-06-02 0:16 ` Andrew Morton
2007-06-02 0:26 ` Christoph Lameter
2007-06-02 1:04 ` Linus Torvalds
2007-06-02 0:46 ` Jeremy Fitzhardinge
2007-06-02 1:05 ` Valdis.Kletnieks
2007-06-02 1:24 ` Christoph Lameter
2007-06-01 23:02 ` Andrew Morton
2007-06-01 23:16 ` Christoph Lameter
2007-06-01 23:21 ` Christoph Lameter
2007-06-01 23:36 ` Linus Torvalds
2007-06-01 23:42 ` Christoph Lameter
2007-06-01 23:25 ` Linus Torvalds [this message]
2007-06-02 0:41 ` Jeremy Fitzhardinge
2007-06-02 0:43 ` Jeremy Fitzhardinge
2007-06-02 0:51 ` Andrew Morton
2007-06-02 0:59 ` Jeremy Fitzhardinge
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=alpine.LFD.0.98.0706011615480.3957@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=clameter@cthulhu.engr.sgi.com \
--cc=clameter@sgi.com \
--cc=dino@in.ibm.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pj@sgi.com \
--cc=rientjes@google.com \
--cc=simon.derr@bull.net \
--cc=srinivasa@in.ibm.com \
--cc=vatsa@in.ibm.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
all inboxes | Powered by JetHome®