aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2014-11-24 19:55:45 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2014-11-24 19:55:45 +0000
commita2d751936b21f56962af93a272dd1c998baa2bd2 (patch)
tree3f96fa00831bb6ad6aa20f049336a4c1d907fa63 /sys/kern/subr_bus.c
parent20abb66ede73af231b18b2e86bae45bd71f30158 (diff)
downloadsrc-a2d751936b21f56962af93a272dd1c998baa2bd2.tar.gz
src-a2d751936b21f56962af93a272dd1c998baa2bd2.zip
Add a bus_get_domain() wrapper around BUS_GET_DOMAIN(). Use this to add
a new per-device '%domain' sysctl node that returns the NUMA domain a device is associated with if it is associated with one. Note that this API is still a WIP and might change before 11.0 actually ships. Differential Revision: https://reviews.freebsd.org/D930 Reviewed by: kib, adrian
Notes
Notes: svn path=/head/; revision=274976
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 51d7ca69ac5b..7fbe359cbaf1 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -285,6 +285,7 @@ static void
device_sysctl_init(device_t dev)
{
devclass_t dc = dev->devclass;
+ int domain;
if (dev->sysctl_tree != NULL)
return;
@@ -314,6 +315,10 @@ device_sysctl_init(device_t dev)
OID_AUTO, "%parent", CTLTYPE_STRING | CTLFLAG_RD,
dev, DEVICE_SYSCTL_PARENT, device_sysctl_handler, "A",
"parent device");
+ if (bus_get_domain(dev, &domain) == 0)
+ SYSCTL_ADD_INT(&dev->sysctl_ctx,
+ SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%domain",
+ CTLFLAG_RD, NULL, domain, "NUMA domain");
}
static void
@@ -4542,6 +4547,18 @@ bus_get_dma_tag(device_t dev)
return (BUS_GET_DMA_TAG(parent, dev));
}
+/**
+ * @brief Wrapper function for BUS_GET_DOMAIN().
+ *
+ * This function simply calls the BUS_GET_DOMAIN() method of the
+ * parent of @p dev.
+ */
+int
+bus_get_domain(device_t dev, int *domain)
+{
+ return (BUS_GET_DOMAIN(device_get_parent(dev), dev, domain));
+}
+
/* Resume all devices and then notify userland that we're up again. */
static int
root_resume(device_t dev)