lkml.org 
[lkml]   [2005]   [Sep]   [13]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateTue, 13 Sep 2005 12:07:07 -0700
FromAndrew Morton <>
SubjectRe: [PATCH] SELinux - convert to kzalloc
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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-09-13 19:11    [from the cache]
©2003-2008