lkml.org 
[lkml]   [2005]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    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 21:11    [W:5.364 / U:0.456 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site