Re: [PATCH] Add SELinux module to 2.5.74-bk1

From: Andrew Morton (
Date: Tue Jul 08 2003 - 05:09:31 EST

James Morris <> wrote:
> +int hashtab_replace(struct hashtab *h, void *key, void *datum,
> + void (*destroy)(void *k, void *d, void *args),
> + void *args)
> +{
> ...
> + newnode = kmalloc(sizeof(*newnode), GFP_KERNEL);

>From an API perspective, the GFP_KERNEL is a problem. Particularly as this
code seems to require that the caller perform the locking?

The GFP_KERNEL means that the locking _has_ to be via a sleeping lock
rather than a spinlock, and interrupt-time insertions are not possible.

Would be better to pass in the gfp_flags.

Comparing the complexity (size) of this code with the q-n-d hash tables
which are currently used one does wonder how useful it all will be. The
additional indirections are not needed with q-n-d hashes.

But if it doesn't significantly add to the overall selinux patch then I
guess it makes sense.

A slab cache for hashtab_nodes would probably save a bit of space.

otoh: It would be faster and more space-efficient to require that the
clients of ths code embed a hastab_node inside their structures and just
pass the address of that hastab_node into here. When they do a lookup they
retreive their original struct with container_of. That fixes the GFP_KERNEL
thing too.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Tue Jul 15 2003 - 22:00:26 EST