Author: jhb
Date: Mon Nov 24 19:55:45 2014
New Revision: 274976
URL: https://svnweb.freebsd.org/changeset/base/274976

Log:
  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

Modified:
  head/sys/kern/subr_bus.c
  head/sys/sys/bus.h

Modified: head/sys/kern/subr_bus.c
==============================================================================
--- head/sys/kern/subr_bus.c    Mon Nov 24 19:50:01 2014        (r274975)
+++ head/sys/kern/subr_bus.c    Mon Nov 24 19:55:45 2014        (r274976)
@@ -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)

Modified: head/sys/sys/bus.h
==============================================================================
--- head/sys/sys/bus.h  Mon Nov 24 19:50:01 2014        (r274975)
+++ head/sys/sys/bus.h  Mon Nov 24 19:55:45 2014        (r274976)
@@ -392,6 +392,7 @@ int bus_activate_resource(device_t dev, 
 int    bus_deactivate_resource(device_t dev, int type, int rid,
                                struct resource *r);
 bus_dma_tag_t bus_get_dma_tag(device_t dev);
+int    bus_get_domain(device_t dev, int *domain);
 int    bus_release_resource(device_t dev, int type, int rid,
                             struct resource *r);
 int    bus_free_resource(device_t dev, int type, struct resource *r);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to