All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Pekka J Enberg <penberg@cs.Helsinki.FI>, Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [-mm patch] make kcalloc() a static inline
Date: Tue, 9 Aug 2005 00:38:42 +0200	[thread overview]
Message-ID: <20050808223842.GM4006@stusta.de> (raw)

kcalloc() doesn't do much more than calling kzalloc(), and gcc has 
better optimizing opportunities when it's inlined.

The result of this patch with a fulll kernel compile (roughly equivalent 
to "make allyesconfig") shows a minimal size improvement:

    text           data     bss     dec             hex filename
25864955        5891214 2012840 33769009        2034631 vmlinux-before
25864635        5891206 2012840 33768681        20344e9 vmlinux-staticinline


Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

 include/linux/slab.h |   15 ++++++++++++++-
 mm/slab.c            |   14 --------------
 2 files changed, 14 insertions(+), 15 deletions(-)

--- linux-2.6.13-rc5-mm1-full/include/linux/slab.h.old	2005-08-08 12:28:32.000000000 +0200
+++ linux-2.6.13-rc5-mm1-full/include/linux/slab.h	2005-08-08 12:29:59.000000000 +0200
@@ -103,8 +103,21 @@
 	return __kmalloc(size, flags);
 }
 
-extern void *kcalloc(size_t, size_t, unsigned int __nocast);
 extern void *kzalloc(size_t, unsigned int __nocast);
+
+/**
+ * kcalloc - allocate memory for an array. The memory is set to zero.
+ * @n: number of elements.
+ * @size: element size.
+ * @flags: the type of memory to allocate.
+ */
+static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast flags)
+{
+	if (n != 0 && size > INT_MAX / n)
+		return NULL;
+	return kzalloc(n * size, flags);
+}
+
 extern void kfree(const void *);
 extern unsigned int ksize(const void *);
 
--- linux-2.6.13-rc5-mm1-full/mm/slab.c.old	2005-08-08 12:29:26.000000000 +0200
+++ linux-2.6.13-rc5-mm1-full/mm/slab.c	2005-08-08 12:29:53.000000000 +0200
@@ -3028,20 +3028,6 @@
 EXPORT_SYMBOL(kzalloc);
 
 /**
- * kcalloc - allocate memory for an array. The memory is set to zero.
- * @n: number of elements.
- * @size: element size.
- * @flags: the type of memory to allocate.
- */
-void *kcalloc(size_t n, size_t size, unsigned int __nocast flags)
-{
-	if (n != 0 && size > INT_MAX / n)
-		return NULL;
-	return kzalloc(n * size, flags);
-}
-EXPORT_SYMBOL(kcalloc);
-
-/**
  * kfree - free previously allocated memory
  * @objp: pointer returned by kmalloc.
  *


             reply	other threads:[~2005-08-08 22:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-08 22:38 Adrian Bunk [this message]
2005-08-09  5:09 ` make kcalloc() a static inline Pekka J Enberg
2005-08-15  8:06 ` [-mm patch] " Denis Vlasenko
2005-08-15  8:14   ` Arjan van de Ven
2005-08-15  8:20     ` Denis Vlasenko
2005-08-15  8:28       ` Pekka J Enberg
2005-08-15  9:33         ` Denis Vlasenko
2005-08-15  9:41           ` Arjan van de Ven
2005-08-15 12:17             ` Denis Vlasenko
2005-08-15 12:25               ` Arjan van de Ven
2005-08-15 13:06                 ` Pekka J Enberg
2005-08-15 13:51                   ` Alan Cox
2005-08-15 16:30                   ` Adrian Bunk

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=20050808223842.GM4006@stusta.de \
    --to=bunk@stusta.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.Helsinki.FI \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.