mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 07:30:53 +07:00
x86/PCI: initialize PCI bus node numbers early
The current mp_bus_to_node array is initialized only by AMD specific code, since AMD platforms have registers that can be used for determining mode numbers. On new Intel platforms it's necessary to initialize this array as well though, otherwise all PCI node numbers will be 0, when in fact they should be -1 (indicating that I/O isn't tied to any particular node). So move the mp_bus_to_node code into the common PCI code, and initialize it early with a default value of -1. This may be overridden later by arch code (e.g. the AMD code). With this change, PCI consistent memory and other node specific allocations (e.g. skbuff allocs) should occur on the "current" node. If, for performance reasons, applications want to be bound to specific nodes, they should open their devices only after being pinned to the CPU where they'll run, for maximum locality. Acked-by: Yinghai Lu <yinghai@kernel.org> Tested-by: Jesse Brandeburg <jesse.brandeburg@gmail.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
eaa959df29
commit
2547089ca2
@ -15,63 +15,6 @@
|
|||||||
* also get peer root bus resource for io,mmio
|
* also get peer root bus resource for io,mmio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
|
||||||
|
|
||||||
#define BUS_NR 256
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
|
|
||||||
static int mp_bus_to_node[BUS_NR];
|
|
||||||
|
|
||||||
void set_mp_bus_to_node(int busnum, int node)
|
|
||||||
{
|
|
||||||
if (busnum >= 0 && busnum < BUS_NR)
|
|
||||||
mp_bus_to_node[busnum] = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_mp_bus_to_node(int busnum)
|
|
||||||
{
|
|
||||||
int node = -1;
|
|
||||||
|
|
||||||
if (busnum < 0 || busnum > (BUS_NR - 1))
|
|
||||||
return node;
|
|
||||||
|
|
||||||
node = mp_bus_to_node[busnum];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* let numa_node_id to decide it later in dma_alloc_pages
|
|
||||||
* if there is no ram on that node
|
|
||||||
*/
|
|
||||||
if (node != -1 && !node_online(node))
|
|
||||||
node = -1;
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* CONFIG_X86_32 */
|
|
||||||
|
|
||||||
static unsigned char mp_bus_to_node[BUS_NR];
|
|
||||||
|
|
||||||
void set_mp_bus_to_node(int busnum, int node)
|
|
||||||
{
|
|
||||||
if (busnum >= 0 && busnum < BUS_NR)
|
|
||||||
mp_bus_to_node[busnum] = (unsigned char) node;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_mp_bus_to_node(int busnum)
|
|
||||||
{
|
|
||||||
int node;
|
|
||||||
|
|
||||||
if (busnum < 0 || busnum > (BUS_NR - 1))
|
|
||||||
return 0;
|
|
||||||
node = mp_bus_to_node[busnum];
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* CONFIG_X86_32 */
|
|
||||||
|
|
||||||
#endif /* CONFIG_NUMA */
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
#ifdef CONFIG_X86_64
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -301,11 +244,6 @@ static int __init early_fill_mp_bus_info(void)
|
|||||||
u64 val;
|
u64 val;
|
||||||
u32 address;
|
u32 address;
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
|
||||||
for (i = 0; i < BUS_NR; i++)
|
|
||||||
mp_bus_to_node[i] = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!early_pci_allowed())
|
if (!early_pci_allowed())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -346,7 +284,7 @@ static int __init early_fill_mp_bus_info(void)
|
|||||||
node = (reg >> 4) & 0x07;
|
node = (reg >> 4) & 0x07;
|
||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
for (j = min_bus; j <= max_bus; j++)
|
for (j = min_bus; j <= max_bus; j++)
|
||||||
mp_bus_to_node[j] = (unsigned char) node;
|
set_mp_bus_to_node(j, node);
|
||||||
#endif
|
#endif
|
||||||
link = (reg >> 8) & 0x03;
|
link = (reg >> 8) & 0x03;
|
||||||
|
|
||||||
|
@ -600,3 +600,72 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
|
|||||||
{
|
{
|
||||||
return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
|
return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NUMA info for PCI busses
|
||||||
|
*
|
||||||
|
* Early arch code is responsible for filling in reasonable values here.
|
||||||
|
* A node id of "-1" means "use current node". In other words, if a bus
|
||||||
|
* has a -1 node id, it's not tightly coupled to any particular chunk
|
||||||
|
* of memory (as is the case on some Nehalem systems).
|
||||||
|
*/
|
||||||
|
#ifdef CONFIG_NUMA
|
||||||
|
|
||||||
|
#define BUS_NR 256
|
||||||
|
|
||||||
|
#ifdef CONFIG_X86_64
|
||||||
|
|
||||||
|
static int mp_bus_to_node[BUS_NR] = {
|
||||||
|
[0 ... BUS_NR - 1] = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
void set_mp_bus_to_node(int busnum, int node)
|
||||||
|
{
|
||||||
|
if (busnum >= 0 && busnum < BUS_NR)
|
||||||
|
mp_bus_to_node[busnum] = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_mp_bus_to_node(int busnum)
|
||||||
|
{
|
||||||
|
int node = -1;
|
||||||
|
|
||||||
|
if (busnum < 0 || busnum > (BUS_NR - 1))
|
||||||
|
return node;
|
||||||
|
|
||||||
|
node = mp_bus_to_node[busnum];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* let numa_node_id to decide it later in dma_alloc_pages
|
||||||
|
* if there is no ram on that node
|
||||||
|
*/
|
||||||
|
if (node != -1 && !node_online(node))
|
||||||
|
node = -1;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* CONFIG_X86_32 */
|
||||||
|
|
||||||
|
static unsigned char mp_bus_to_node[BUS_NR] = {
|
||||||
|
[0 ... BUS_NR - 1] = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
void set_mp_bus_to_node(int busnum, int node)
|
||||||
|
{
|
||||||
|
if (busnum >= 0 && busnum < BUS_NR)
|
||||||
|
mp_bus_to_node[busnum] = (unsigned char) node;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_mp_bus_to_node(int busnum)
|
||||||
|
{
|
||||||
|
int node;
|
||||||
|
|
||||||
|
if (busnum < 0 || busnum > (BUS_NR - 1))
|
||||||
|
return 0;
|
||||||
|
node = mp_bus_to_node[busnum];
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_X86_32 */
|
||||||
|
|
||||||
|
#endif /* CONFIG_NUMA */
|
||||||
|
Loading…
Reference in New Issue
Block a user