aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Cilia Attard <iciliaat@gmail.com>2024-04-29 20:44:27 +0000
committerColin Percival <cperciva@FreeBSD.org>2024-05-10 00:56:40 +0000
commit6437872c1d665c2605f54e8ff040b0ba41edad07 (patch)
treef6f5ed66301481fbfd0576e930d828c481668d4f
parent8c2f6c3be0125142d3c1782e4b0ee0634c584b9e (diff)
downloadsrc-6437872c1d665c2605f54e8ff040b0ba41edad07.tar.gz
src-6437872c1d665c2605f54e8ff040b0ba41edad07.zip
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
-rwxr-xr-xlibexec/rc/rc.d/devmatch1
-rw-r--r--sys/kern/kern_devctl.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/libexec/rc/rc.d/devmatch b/libexec/rc/rc.d/devmatch
index 78050cfa4541..67bb14761614 100755
--- a/libexec/rc/rc.d/devmatch
+++ b/libexec/rc/rc.d/devmatch
@@ -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
diff --git a/sys/kern/kern_devctl.c b/sys/kern/kern_devctl.c
index 12d4f9ebfc4d..0dd05a49c9ad 100644
--- a/sys/kern/kern_devctl.c
+++ b/sys/kern/kern_devctl.c
@@ -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