hw/pci: add support for NUMA nodes
PCI root buses can be attached to a specific NUMA node. PCI buses are not attached by default to a NUMA node. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
0639b00d05
commit
6a3042b23b
11
hw/pci/pci.c
11
hw/pci/pci.c
|
@ -101,6 +101,11 @@ static int pcibus_num(PCIBus *bus)
|
||||||
return bus->parent_dev->config[PCI_SECONDARY_BUS];
|
return bus->parent_dev->config[PCI_SECONDARY_BUS];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t pcibus_numa_node(PCIBus *bus)
|
||||||
|
{
|
||||||
|
return NUMA_NODE_UNASSIGNED;
|
||||||
|
}
|
||||||
|
|
||||||
static void pci_bus_class_init(ObjectClass *klass, void *data)
|
static void pci_bus_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
BusClass *k = BUS_CLASS(klass);
|
BusClass *k = BUS_CLASS(klass);
|
||||||
|
@ -115,6 +120,7 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
|
||||||
|
|
||||||
pbc->is_root = pcibus_is_root;
|
pbc->is_root = pcibus_is_root;
|
||||||
pbc->bus_num = pcibus_num;
|
pbc->bus_num = pcibus_num;
|
||||||
|
pbc->numa_node = pcibus_numa_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo pci_bus_info = {
|
static const TypeInfo pci_bus_info = {
|
||||||
|
@ -402,6 +408,11 @@ int pci_bus_num(PCIBus *s)
|
||||||
return PCI_BUS_GET_CLASS(s)->bus_num(s);
|
return PCI_BUS_GET_CLASS(s)->bus_num(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pci_bus_numa_node(PCIBus *bus)
|
||||||
|
{
|
||||||
|
return PCI_BUS_GET_CLASS(bus)->numa_node(bus);
|
||||||
|
}
|
||||||
|
|
||||||
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
|
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
|
||||||
{
|
{
|
||||||
PCIDevice *s = container_of(pv, PCIDevice, config);
|
PCIDevice *s = container_of(pv, PCIDevice, config);
|
||||||
|
|
|
@ -382,6 +382,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
|
||||||
PCIDevice *pci_vga_init(PCIBus *bus);
|
PCIDevice *pci_vga_init(PCIBus *bus);
|
||||||
|
|
||||||
int pci_bus_num(PCIBus *s);
|
int pci_bus_num(PCIBus *s);
|
||||||
|
int pci_bus_numa_node(PCIBus *bus);
|
||||||
void pci_for_each_device(PCIBus *bus, int bus_num,
|
void pci_for_each_device(PCIBus *bus, int bus_num,
|
||||||
void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
|
void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
|
@ -15,6 +15,7 @@ typedef struct PCIBusClass {
|
||||||
|
|
||||||
bool (*is_root)(PCIBus *bus);
|
bool (*is_root)(PCIBus *bus);
|
||||||
int (*bus_num)(PCIBus *bus);
|
int (*bus_num)(PCIBus *bus);
|
||||||
|
uint16_t (*numa_node)(PCIBus *bus);
|
||||||
} PCIBusClass;
|
} PCIBusClass;
|
||||||
|
|
||||||
struct PCIBus {
|
struct PCIBus {
|
||||||
|
|
|
@ -137,6 +137,7 @@ extern const char *mem_path;
|
||||||
extern int mem_prealloc;
|
extern int mem_prealloc;
|
||||||
|
|
||||||
#define MAX_NODES 128
|
#define MAX_NODES 128
|
||||||
|
#define NUMA_NODE_UNASSIGNED MAX_NODES
|
||||||
|
|
||||||
/* The following shall be true for all CPUs:
|
/* The following shall be true for all CPUs:
|
||||||
* cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS
|
* cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS
|
||||||
|
|
Loading…
Reference in New Issue