Re: [PATCH] SELinux - convert to kzalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



James Morris <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux