devclass_alloc_unit: move "at" hint test to after device-in-use test
Only perform this expensive operation when the unit number is a potential candidate (i.e. not already in use), thereby reducing device scan time on systems with many devices, unit numbers, and drivers. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #61 Differential Revision: https://reviews.freebsd.org/D31381
This commit is contained in:
parent
9f1db6c555
commit
8ca384eb1d
@ -1638,15 +1638,15 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp)
|
||||
/* Unwired device, find the next available slot for it */
|
||||
unit = 0;
|
||||
for (unit = 0;; unit++) {
|
||||
/* If this device slot is already in use, skip it. */
|
||||
if (unit < dc->maxunit && dc->devices[unit] != NULL)
|
||||
continue;
|
||||
|
||||
/* If there is an "at" hint for a unit then skip it. */
|
||||
if (resource_string_value(dc->name, unit, "at", &s) ==
|
||||
0)
|
||||
continue;
|
||||
|
||||
/* If this device slot is already in use, skip it. */
|
||||
if (unit < dc->maxunit && dc->devices[unit] != NULL)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user