Re: [PATCH 3/3] High-res-timers part 3 (posix to hrposix) take 20

Andrew Morton (akpm@digeo.com)
Sun, 08 Dec 2002 15:34:30 -0800


george anzinger wrote:
>
> --- linux-2.5.50-bk7-kb/include/linux/id_reuse.h Wed Dec 31 16:00:00 1969
> +++ linux/include/linux/id_reuse.h Sat Dec 7 21:37:58 2002

Maybe I'm thick, but this whole id_resue layer seems rather obscure.

As it is being positioned as a general-purpose utility it needs
API documentation as well as a general description.

> +extern inline void update_bitmap(struct idr_layer *p, int bit)

Please use static inline, not extern inline. If only for consistency,
and to lessen the amount of stuff which needs to be fixed up by those
of us who like to use `-fno-inline' occasionally.

> +extern inline void update_bitmap_set(struct idr_layer *p, int bit)

A lot of the functions in this header are too large to be inlined.

> +extern inline void idr_lock(struct idr *idp)
> +{
> + spin_lock(&idp->id_slock);
> +}

Please, just open-code the locking. This simply makes it harder to follow the
main code.

> +
> +static struct idr_layer *id_free;
> +static int id_free_cnt;

hm. We seem to have a global private freelist here. Is the more SMP-friendly
slab not suitable?

> ...
> +static int sub_alloc(struct idr_layer *p, int shift, void *ptr)
> +{
> + int bitmap = p->bitmap;
> + int v, n;
> +
> + n = ffz(bitmap);
> + if (shift == 0) {
> + p->ary[n] = (struct idr_layer *)ptr;
> + __set_bit(n, &p->bitmap);
> + return(n);
> + }
> + if (!p->ary[n])
> + p->ary[n] = alloc_layer();
> + v = sub_alloc(p->ary[n], shift-IDR_BITS, ptr);
> + update_bitmap_set(p, n);
> + return(v + (n << shift));
> +}

Recursion!

> +void idr_init(struct idr *idp)

Please tell us a bit about this id layer: what problems it solves, how it
solves them, why it is needed and why existing kernel facilities are
unsuitable.

Thanks.
-
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/