James Morris <firstname.lastname@example.org> 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
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Tue Jul 15 2003 - 22:00:26 EST