Kevin Corry <kevcorry@xxxxxxxxxx> wrote: > > > Yes, idr is the one to use. That linear search you have in there becomes > > logarithmic. Will speed up the registration of 100,000 minors no end ;) > > I've got a patch that switches from a bit-set to an IDR structure. The only > thing I'm slightly uncertain about is the case where we're trying to create > a device with a specific minor number (when creating a DM device, you have > the choice to specify a minor number or have DM find the first available > one). To do this, I call idr_find() with the desired minor. If that returns > NULL (meaning it's not already in use), then I call idr_get_new_above() with > that same desired minor. In the cases I've tested, this always chooses the > desired minor, but can we depend on that behavior? Yes, that has to work - you're holding the lock throughout. It would be sensible to make that a part of the idr API though.