From: Philipp Rumpf <prumpf@mandrakesoft.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Kenn Humborg <kenn@linux.ie>,
Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: Re: kmalloc() alignment
Date: Tue, 6 Mar 2001 02:59:31 -0600 [thread overview]
Message-ID: <20010306025931.A12655@mandrakesoft.mandrakesoft.com> (raw)
In-Reply-To: <20010304221711.A1023@excalibur.research.wombat.ie> <E14Zh5G-0005tP-00@the-village.bc.nu>
In-Reply-To: <E14Zh5G-0005tP-00@the-village.bc.nu>; from Alan Cox on Sun, Mar 04, 2001 at 10:34:31PM +0000
On Sun, Mar 04, 2001 at 10:34:31PM +0000, Alan Cox 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?
>
> There are people who assume 16byte alignment guarantees. I dont think anyone
> has formally specified the guarantee beyond 4 bytes tho
Userspace malloc is "suitably aligned for any kind of variable", so I think
expecting 8 bytes alignment (long long on 32-bit platforms) should be okay.
>From reading the code it seems as though we actually use L1_CACHE_BYTES,
and I think it might be a good idea to document the current behaviour (as
long as there's no good reason to change it ?)
diff -ur linux/mm/slab.c linux-prumpf/mm/slab.c
--- linux/mm/slab.c Tue Mar 6 00:54:38 2001
+++ linux-prumpf/mm/slab.c Tue Mar 6 01:00:47 2001
@@ -1525,9 +1525,10 @@
* @flags: the type of memory to allocate.
*
* kmalloc is the normal method of allocating memory
- * in the kernel. Note that the @size parameter must be less than or
- * equals to %KMALLOC_MAXSIZE and the caller must ensure this. The @flags
- * argument may be one of:
+ * in the kernel. It returns a pointer (aligned to a hardware cache line
+ * boundary) to the allocated memory, or %NULL in case of failure. Note that
+ * the @size parameter must be less than or equal to %KMALLOC_MAXSIZE and
+ * the caller must ensure this. The @flags argument may be one of:
*
* %GFP_USER - Allocate memory on behalf of user. May sleep.
*
next prev parent reply other threads:[~2001-03-06 9:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-04 22:17 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 [this message]
2001-03-06 12:14 ` Alan Cox
2001-03-04 22:41 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
2003-05-05 22:03 kmalloc alignment Thomas Heinz
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=20010306025931.A12655@mandrakesoft.mandrakesoft.com \
--to=prumpf@mandrakesoft.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=kenn@linux.ie \
--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
all inboxes | Powered by JetHome®