public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xavier Bestel <xavier.bestel@free.fr>
To: linux-kernel@vger.kernel.org
Subject: Re: kmalloc() alignment
Date: 06 Mar 2001 13:10:11 +0100	[thread overview]
Message-ID: <200103061210.NAA17114@microsoft.com> (raw)
In-Reply-To: <200103060831.JAA04492@cave.bitwizard.nl>

Le 06 Mar 2001 09:31:01 +0100, Rogier Wolff a écrit :
> 
> > Followup to:  <20010306000652.A13992@excalibur.research.wombat.ie>
> > By author:    Kenn Humborg <kenn@linux.ie>
> > In newsgroup: linux.dev.kernel
> > >
> > > On Sun, Mar 04, 2001 at 11:41:12PM +0100, Manfred Spraul wrote:
> > > > >
> > > > > Does kmalloc() make any guarantees of the alignment of allocated 
> > > > > blocks? Will the returned block always be 4-, 8- or 16-byte 
> > > > > aligned, for example? 
> > > > >
> > > > 
> > > > 4-byte alignment is guaranteed on 32-bit cpus, 8-byte alignment on
> > > > 64-bit cpus.
> > > 
> > > So, to summarise (for 32-bit CPUs):
> > > 
> > > o  Alan Cox & Manfred Spraul say 4-byte alignment is guaranteed.
> > > 
> > > o  If you need larger alignment, you need to alloc a larger space,
> > >    round as necessary, and keep the original pointer for kfree()
> > > 
> > > Maybe I'll just use get_free_pages, since it's a 64KB chunk that
> > > I need (and it's only a once-off).
> 
> My old kmalloc would actually use n+10 bytes if you request n bytes.
> As memory comes in pools of powers of two, if you request 64k, you
> would acutaly use 128k of memory. If you use "get_free_pages", you'll
> not have the overhead, and actually allocate the 64k you need. 
> 
> I'm not sure what the slab stuff does...

A properly initialised (i.e. default settings) 64k slab would put object
descriptors outside the slab itself, and so use the expected number of
pages for each 64k object, I believe.
Small or non n*512 sized objects are a different story.

Xav


  reply	other threads:[~2001-03-06 12:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-04 22:41 kmalloc() alignment Manfred Spraul
2001-03-06  0:06 ` Kenn Humborg
2001-03-06  0:15   ` H. Peter Anvin
2001-03-06  0:29     ` Kenn Humborg
2001-03-06  2:14       ` Alan Cox
2001-03-06  5:05         ` H. Peter Anvin
2001-03-06  8:31     ` Rogier Wolff
2001-03-06 12:10       ` Xavier Bestel [this message]
2001-03-07  7:53       ` RAID, 2.4.2 and Buslogic Jauder Ho
2001-03-07  8:20         ` Andreas Dilger
  -- strict thread matches above, loose matches on Subject: below --
2003-05-05 22:03 kmalloc alignment Thomas Heinz
2001-03-04 22:17 kmalloc() alignment Kenn Humborg
2001-03-04 22:34 ` Alan Cox
2001-03-05  9:40   ` Rogier Wolff
2001-03-05 13:24     ` Alan Cox
2001-03-05 13:22       ` Rogier Wolff
2001-03-06  8:59   ` Philipp Rumpf
2001-03-06 12:14     ` Alan Cox

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=200103061210.NAA17114@microsoft.com \
    --to=xavier.bestel@free.fr \
    --cc=linux-kernel@vger.kernel.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