Re: [BK PATCH] SCSI host num allocation improvement

H. Peter Anvin
2004-02-27T18:51:32Z

Followup to: <20040226171928.750f5f6f.akpm@osdl.org>
By author: Andrew Morton <akpm@osdl.org>
In newsgroup: linux.dev.kernel
>
> 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.
>

Well, I actually *didn't* want it to be allocate-the-lowest-available
number. I deliberately went with the same allocation scheme used for
PIDs (continual advance with wraparound and duplication avoidance);
this is a cheap approximation of NRU.

Immediate re-use is *BAD* (in the pty example, it means you're liable
to have "write" write to an unrelated session by mistake, for example)
at least if there is no penalty for expanding into the full allocated
number space. Lowest available number is architecturally mandated for
file descriptors, but it doesn't mean it's a preferred allocation
scheme by any means.

-hpa