mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: James Morris <jmorris@namei.org>
Cc: linux-kernel@vger.kernel.org, sds@epoch.ncsc.mil
Subject: Re: [PATCH] SELinux - convert to kzalloc
Date: Tue, 13 Sep 2005 12:07:07 -0700	[thread overview]
Message-ID: <20050913120707.74a19800.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.63.0509131116280.3479@excalibur.intercode>

James Morris <jmorris@namei.org> wrote:
>
>  This patch converts SELinux code from kmalloc/memset to the new kazalloc 
>  function.  On i386, this results in a text saving of over 1K.
> 
>  Before:
>  text    data     bss     dec     hex filename
>  86319    4642   15236  106197   19ed5 security/selinux/built-in.o
>      
>  After:
>  text    data     bss     dec     hex filename
>  85278    4642   15236  105156   19ac4 security/selinux/built-in.o
> 

That's a nice size reduction.  If we had kzalloc_gfp_kernel(size_t) we
could drop an argument and save even more, but I suspect Linus would come
after me with a cattle prod.

Note that the use of kzalloc() will nullify kmalloc's compile-time
optimisation where it determines which slab to use at compile time -
kzalloc() won't know the size and will have to do the table search.  But
the performance benefit from text size reductions will balance that.

SELinux seems to do a lot of kzalloc(a * b, flags):

 +	mysids = kzalloc(maxnel*sizeof(*mysids), GFP_ATOMIC);
 +	*names = (char**)kzalloc(sizeof(char*) * *len, GFP_ATOMIC);
 +	mysids2 = kzalloc(maxnel*sizeof(*mysids2), GFP_ATOMIC);

Consider using kcalloc() here.

  reply	other threads:[~2005-09-13 19:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13 15:18 James Morris
2005-09-13 19:07 ` Andrew Morton [this message]
2005-09-13 20:37   ` James Morris
2005-09-14  1:43   ` Roland Dreier
2005-09-14  5:09     ` [PATCH] Create __kzalloc_gfp_kernel() Roland Dreier
2005-09-14  5:35       ` Andrew Morton
2005-09-14 18:39         ` [PATCH] Move GFP_KERNEL use out of line to shrink text Roland Dreier
2005-09-15  5:13           ` Denis Vlasenko
2005-09-15 11:42             ` Paulo Marques
2005-09-14  5:06 ` [PATCH] SELinux - convert to kzalloc Denis Vlasenko

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=20050913120707.74a19800.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sds@epoch.ncsc.mil \
    /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®