]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] PCI: Add sysfs file to map PCI busses to cpus
authorAndi Kleen <ak@suse.de>
Mon, 29 Nov 2004 03:12:54 +0000 (19:12 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 29 Nov 2004 03:12:54 +0000 (19:12 -0800)
Add sysfs file to map PCI busses to cpus

Export the information from pcibus_to_cpumask() to sysfs. This
is useful for some user space programs who want to optimize their IO
using O_DIRECT.

There was some indecision on whether it's more useful to report
cpus or nodes here. In the end cpus was chosen because that is
what the existing macros report.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/pci/pci-sysfs.c

index 84728283f0d54930a51b93df032830fb00c8e367..05576e80472a712a9e390ec68443bb7bbb44a792 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/stat.h>
+#include <linux/topology.h>
 
 #include "pci.h"
 
@@ -42,6 +43,15 @@ pci_config_attr(subsystem_device, "0x%04x\n");
 pci_config_attr(class, "0x%06x\n");
 pci_config_attr(irq, "%u\n");
 
+static ssize_t local_cpus_show(struct device *dev, char *buf)
+{              
+       struct pci_dev *pdev = to_pci_dev(dev);
+       cpumask_t mask = pcibus_to_cpumask(pdev->bus->number);
+       int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
+       strcat(buf,"\n"); 
+       return 1+len;
+}
+
 /* show resources */
 static ssize_t
 resource_show(struct device * dev, char * buf)
@@ -71,6 +81,7 @@ struct device_attribute pci_dev_attrs[] = {
        __ATTR_RO(subsystem_device),
        __ATTR_RO(class),
        __ATTR_RO(irq),
+       __ATTR_RO(local_cpus),
        __ATTR_NULL,
 };