On Wed, 30 Aug 2000, Tigran Aivazian wrote:

> Hi Linus,
> 
> The sock slab cache is critical so one ought to panic if it can't be
> created, like we do for all other slab caches.
> 
> Regards,
> Tigran
> 
> --- linux/net/core/sock.c     Thu Aug 24 08:08:47 2000
> +++ work/net/core/sock.c      Wed Aug 30 13:13:48 2000
> @@ -609,7 +609,9 @@
>  {
>       sk_cachep = kmem_cache_create("sock", sizeof(struct sock), 0,
>                                     SLAB_HWCACHE_ALIGN, 0, 0);
> -     
> +     if (!sk_cachep)
> +             panic("Cannot create sock SLAB cache");
> +
>       if (num_physpages <= 4096) {
>               sysctl_wmem_max = 32767;
>               sysctl_rmem_max = 32767;

Just a little suggestion, because lots of patches similar to this have
been floating around recently.

Wouldn't it be better if we move the null pointer test and the panic()
inside kmem_cache_create() similar to this

------------
kmem_cache_t *kmem_cache_create(...)
{
...
opps:

        if (!cachep) {
                sprintf(panic_msg, "Cannot create %.20s SLAB cache",
                        name);
                panic(panic_msg);
        }

        return cachep;
}

------------

A quick check showed that we have over 50 calls to kmem_cache_create().
Doing the above would save a reasonable amount of code and text segment
space.

Regards,

        Matze

-- 
Matthias Hanisch    mailto:[EMAIL PROTECTED]    phone: +49 8137 935-219

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to