Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Aug 2021 17:28:58 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 453e51048a83 - stable/13 - devclass_alloc_unit: move "at" hint test to after device-in-use test
Message-ID:  <202108261728.17QHSwF2010973@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=453e51048a83b8b73706a8f8520ad7ce193c0f51

commit 453e51048a83b8b73706a8f8520ad7ce193c0f51
Author:     Adam Fenn <adam@fenn.io>
AuthorDate: 2021-08-02 16:27:17 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-08-26 17:28:38 +0000

    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
    
    (cherry picked from commit 8ca384eb1d429aae866f53abfadafc71ab009dc6)
---
 sys/kern/subr_bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index f0198a0e1fa3..5bd3a4f3d450 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -1640,15 +1640,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;
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108261728.17QHSwF2010973>