New sysctl to disable NOMATCH until devmatch runs

Introduce hw.bus.devctl_nomatch_enabled and use it to suppress NOMATCH
until devmatch runs

There's a lot of NOMATCH events generated at boot. We also run devmatch
once during early boot to load unmatched devices. To avoid redundant
work, don't start generating NOMATCH events until after devmatch runs.
Set hw.bus.devctl_nomatch_enabled=1 just before we run devmatch. The
kernel will suppress NOMATCH events until this is set to true.

This saves about 170ms from the boot on aarch64 running atop Apple
M-series processors and the VMWare Fusion hypervisor.

Reviewed by:    imp, cperciva
MFC after:      3 days
Sponsored by:   Google Summer of Code
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1213
This commit is contained in:
Isaac Cilia Attard 2024-04-29 22:44:27 +02:00 committed by Colin Percival
parent 8c2f6c3be0
commit 6437872c1d
2 changed files with 6 additions and 1 deletions

View File

@ -46,6 +46,7 @@ devmatch_start()
if [ -n "$one_nomatch" ]; then
list=$(devmatch -p "${one_nomatch}" | sort -u)
else
sysctl hw.bus.devctl_nomatch_enabled=1
list=$(devmatch | sort -u)
fi

View File

@ -89,6 +89,9 @@ static int sysctl_devctl_queue(SYSCTL_HANDLER_ARGS);
static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN;
SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RWTUN |
CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_queue, "I", "devctl queue length");
static bool nomatch_enabled = false;
SYSCTL_BOOL(_hw_bus, OID_AUTO, devctl_nomatch_enabled, CTLFLAG_RWTUN,
&nomatch_enabled, 0, "enable nomatch events");
static void devctl_attach_handler(void *arg __unused, device_t dev);
static void devctl_detach_handler(void *arg __unused, device_t dev,
@ -208,7 +211,8 @@ devctl_detach_handler(void *arg __unused, device_t dev, enum evhdev_detach state
static void
devctl_nomatch_handler(void *arg __unused, device_t dev)
{
devaddq("?", "", dev);
if (nomatch_enabled)
devaddq("?", "", dev);
}
static int