Re: [BK PATCH] SCSI host num allocation improvement

From: Andrew Morton
Date: Thu Feb 26 2004 - 20:24:03 EST


Ben Collins <bcollins@xxxxxxxxxx> wrote:
>
> +next_host_num_try:
> + list_for_each_entry(cdev, &class->children, node) {
> + shost = class_to_shost(cdev);
> + if (shost->host_no == host_num) {
> + host_num++;
> + goto next_host_num_try;

yitch. I realise this is called rarely, for realtively small numbers of N
(which gets squared), but.

This allocate-me-the-lowest-available-number is a common idiom in the
kernel and we really should do it better. Seems we need to convert the
dynamic pty allocation to do it as well - it has yet another open-coded
ad-hoc allocator.

The lib/idr.c code is a bit clumsy but it does do the job relatively
efficiently. If it needs some helper wrappers or API simplification then
let's add those.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/