]> mj.ucw.cz Git - pciutils.git/commitdiff
Report NUMA node in lspci -v
authorMatthew Wilcox <willy@linux.intel.com>
Wed, 22 Apr 2015 20:27:21 +0000 (16:27 -0400)
committerMartin Mares <mj@ucw.cz>
Mon, 14 Sep 2015 14:43:15 +0000 (16:43 +0200)
In multi-socket systems, it's useful to see which node a particular
PCI device belongs to.  Linux provides this information through sysfs,
but some users don't like poking through sysfs themselves to find it,
and it's pretty straightforward to report it in lspci.

I should note that when there is no NUMA node for a particular device,
Linux reports -1.  I've chosen to continue that convention in pciutils,
and simply omit the information if the device does not belong to a NUMA
node (eg on single-socket systems, or devices which are not preferentially
attached to a particular node, like Nehalem-based systems).

lib/access.c
lib/pci.h
lib/sysfs.c
lspci.c

index d292085c7374ad96912b738e968996723b0e69f9..a547d2c4eee91aad2ec3c3ab3140f71429cf2e51 100644 (file)
@@ -28,6 +28,7 @@ pci_alloc_dev(struct pci_access *a)
   d->access = a;
   d->methods = a->methods;
   d->hdrtype = -1;
+  d->numa_node = -1;
   if (d->methods->init_dev)
     d->methods->init_dev(d);
   return d;
index bd6f6a171efd89a087a1c54c8766f80497492921..0ccfbe36e995d36ced206c96f065eb33b83a1019 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -127,6 +127,7 @@ struct pci_dev {
   u16 vendor_id, device_id;            /* Identity of the device */
   u16 device_class;                    /* PCI device class */
   int irq;                             /* IRQ number */
+  int numa_node;                       /* NUMA node */
   pciaddr_t base_addr[6];              /* Base addresses including flags in lower bits */
   pciaddr_t size[6];                   /* Region sizes */
   pciaddr_t rom_base_addr;             /* Expansion ROM base address */
index 9f348bbc34a6b98c99704dd52a1092cbb5ad38a7..800fb4e430087afb5fc3a8838789e1570df13c18 100644 (file)
@@ -192,6 +192,7 @@ static void sysfs_scan(struct pci_access *a)
        {
          sysfs_get_resources(d);
          d->irq = sysfs_get_value(d, "irq");
+         d->numa_node = sysfs_get_value(d, "numa_node");
          /*
           *  We could read these faster from the config registers, but we want to give
           *  the kernel a chance to fix up ID's and especially classes of broken devices.
diff --git a/lspci.c b/lspci.c
index 6f161421d64766dbda934491645d22d23c1ba592..a78eb26b21204844e9d91c40347b3af2869ed1b0 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -757,6 +757,8 @@ show_verbose(struct device *d)
        printf(", latency %d", latency);
       if (irq)
        printf(", IRQ " PCIIRQ_FMT, irq);
+      if (p->numa_node != -1)
+       printf(", NUMA node %d", p->numa_node);
       putchar('\n');
     }