From 049264c5cce03cdd1a93965acacd377492dabcb3 Mon Sep 17 00:00:00 2001 From: Pawel Biernacki Date: Thu, 18 Jun 2020 21:42:54 +0000 Subject: [PATCH] hw.bus.info: rework handler hw.bus.info was added in r68522 as a node, but there was never anything connected "behind" it. Its only purpose is to return a struct u_businfo. The only in-base consumer are devinfo(3)/devinfo(8). Rewrite the handler as SYSCTL_PROC and mark it as MPSAFE and read-only as there never was a writable path. Reviewed by: kib Approved by: kib (mentor) Sponsored by: Mysterious Code Ltd. Differential Revision: https://reviews.freebsd.org/D25321 --- sys/kern/subr_bus.c | 8 +++++--- sys/sys/sysctl.h | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index b9de605be454..f75ab7df40bb 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -5454,7 +5454,7 @@ print_devclass_list(void) */ static int -sysctl_bus(SYSCTL_HANDLER_ARGS) +sysctl_bus_info(SYSCTL_HANDLER_ARGS) { struct u_businfo ubus; @@ -5463,7 +5463,8 @@ sysctl_bus(SYSCTL_HANDLER_ARGS) return (SYSCTL_OUT(req, &ubus, sizeof(ubus))); } -SYSCTL_NODE(_hw_bus, OID_AUTO, info, CTLFLAG_RW | CTLFLAG_NEEDGIANT, sysctl_bus, +SYSCTL_PROC(_hw_bus, OID_AUTO, info, CTLTYPE_STRUCT | CTLFLAG_RD | + CTLFLAG_MPSAFE, NULL, 0, sysctl_bus_info, "S,u_businfo", "bus-related data"); static int @@ -5555,7 +5556,8 @@ bus_data_generation_check(int generation) void bus_data_generation_update(void) { - bus_data_generation++; + + atomic_add_int(&bus_data_generation, 1); } int diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index fbfd855d7799..08fa64bed407 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1122,7 +1122,6 @@ SYSCTL_DECL(_dev); SYSCTL_DECL(_hw); SYSCTL_DECL(_hw_bus); SYSCTL_DECL(_hw_bus_devices); -SYSCTL_DECL(_hw_bus_info); SYSCTL_DECL(_machdep); SYSCTL_DECL(_machdep_mitigations); SYSCTL_DECL(_user);