2019-05-27 14:55:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* acpi_numa.c - ACPI NUMA support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Takayoshi Kochi <t-kochi@bq.jp.nec.com>
|
|
|
|
*/
|
2016-05-25 06:35:31 +08:00
|
|
|
|
|
|
|
#define pr_fmt(fmt) "ACPI: " fmt
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/acpi.h>
|
2016-05-25 06:35:41 +08:00
|
|
|
#include <linux/memblock.h>
|
2009-11-18 06:27:32 +08:00
|
|
|
#include <linux/numa.h>
|
acpi: Add acpi_map_pxm_to_online_node()
The kernel initializes CPU & memory's NUMA topology from ACPI
SRAT table. Some other ACPI tables, such as NFIT and DMAR, also
contain proximity IDs for their device's NUMA topology. This
information can be used to improve performance of these devices.
This patch introduces acpi_map_pxm_to_online_node(), which is
similar to acpi_map_pxm_to_node(), but always returns an online
node. When the mapped node from a given proximity ID is offline,
it looks up the node distance table and returns the nearest
online node.
ACPI device drivers, which are called after the NUMA initialization
has completed in the kernel, can call this interface to obtain their
device NUMA topology from ACPI tables. Such drivers do not have to
deal with offline nodes. A node may be offline when a device
proximity ID is unique, SRAT memory entry does not exist, or NUMA is
disabled, ex. "numa=off" on x86.
This patch also moves the pxm range check from acpi_get_node() to
acpi_map_pxm_to_node().
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2015-06-20 07:14:15 +08:00
|
|
|
#include <linux/nodemask.h>
|
|
|
|
#include <linux/topology.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-06-23 17:03:19 +08:00
|
|
|
static nodemask_t nodes_found_map = NODE_MASK_NONE;
|
|
|
|
|
|
|
|
/* maps to convert between proximity domain and logical node ID */
|
2007-12-13 16:32:26 +08:00
|
|
|
static int pxm_to_node_map[MAX_PXM_DOMAINS]
|
2009-11-18 06:27:32 +08:00
|
|
|
= { [0 ... MAX_PXM_DOMAINS - 1] = NUMA_NO_NODE };
|
2007-12-13 16:32:26 +08:00
|
|
|
static int node_to_pxm_map[MAX_NUMNODES]
|
2009-11-18 06:27:32 +08:00
|
|
|
= { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
|
2006-06-23 17:03:19 +08:00
|
|
|
|
2012-01-17 17:18:02 +08:00
|
|
|
unsigned char acpi_srat_revision __initdata;
|
2020-10-14 07:48:57 +08:00
|
|
|
static int acpi_numa __initdata;
|
|
|
|
|
|
|
|
void __init disable_srat(void)
|
|
|
|
{
|
|
|
|
acpi_numa = -1;
|
|
|
|
}
|
2012-01-17 17:18:02 +08:00
|
|
|
|
2007-05-17 13:11:06 +08:00
|
|
|
int pxm_to_node(int pxm)
|
2006-06-23 17:03:19 +08:00
|
|
|
{
|
2020-08-18 22:24:25 +08:00
|
|
|
if (pxm < 0 || pxm >= MAX_PXM_DOMAINS || numa_off)
|
2009-11-18 06:27:32 +08:00
|
|
|
return NUMA_NO_NODE;
|
2006-06-23 17:03:19 +08:00
|
|
|
return pxm_to_node_map[pxm];
|
|
|
|
}
|
2020-05-07 22:01:27 +08:00
|
|
|
EXPORT_SYMBOL(pxm_to_node);
|
2006-06-23 17:03:19 +08:00
|
|
|
|
2007-05-17 13:11:06 +08:00
|
|
|
int node_to_pxm(int node)
|
2006-06-23 17:03:19 +08:00
|
|
|
{
|
|
|
|
if (node < 0)
|
|
|
|
return PXM_INVAL;
|
|
|
|
return node_to_pxm_map[node];
|
|
|
|
}
|
|
|
|
|
2014-01-25 06:48:01 +08:00
|
|
|
static void __acpi_map_pxm_to_node(int pxm, int node)
|
2007-07-21 23:10:32 +08:00
|
|
|
{
|
2010-03-26 07:33:04 +08:00
|
|
|
if (pxm_to_node_map[pxm] == NUMA_NO_NODE || node < pxm_to_node_map[pxm])
|
|
|
|
pxm_to_node_map[pxm] = node;
|
|
|
|
if (node_to_pxm_map[node] == PXM_INVAL || pxm < node_to_pxm_map[node])
|
|
|
|
node_to_pxm_map[node] = pxm;
|
2007-07-21 23:10:32 +08:00
|
|
|
}
|
|
|
|
|
2007-05-25 04:57:40 +08:00
|
|
|
int acpi_map_pxm_to_node(int pxm)
|
2006-06-23 17:03:19 +08:00
|
|
|
{
|
acpi: Add acpi_map_pxm_to_online_node()
The kernel initializes CPU & memory's NUMA topology from ACPI
SRAT table. Some other ACPI tables, such as NFIT and DMAR, also
contain proximity IDs for their device's NUMA topology. This
information can be used to improve performance of these devices.
This patch introduces acpi_map_pxm_to_online_node(), which is
similar to acpi_map_pxm_to_node(), but always returns an online
node. When the mapped node from a given proximity ID is offline,
it looks up the node distance table and returns the nearest
online node.
ACPI device drivers, which are called after the NUMA initialization
has completed in the kernel, can call this interface to obtain their
device NUMA topology from ACPI tables. Such drivers do not have to
deal with offline nodes. A node may be offline when a device
proximity ID is unique, SRAT memory entry does not exist, or NUMA is
disabled, ex. "numa=off" on x86.
This patch also moves the pxm range check from acpi_get_node() to
acpi_map_pxm_to_node().
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2015-06-20 07:14:15 +08:00
|
|
|
int node;
|
|
|
|
|
2016-12-13 12:18:29 +08:00
|
|
|
if (pxm < 0 || pxm >= MAX_PXM_DOMAINS || numa_off)
|
acpi: Add acpi_map_pxm_to_online_node()
The kernel initializes CPU & memory's NUMA topology from ACPI
SRAT table. Some other ACPI tables, such as NFIT and DMAR, also
contain proximity IDs for their device's NUMA topology. This
information can be used to improve performance of these devices.
This patch introduces acpi_map_pxm_to_online_node(), which is
similar to acpi_map_pxm_to_node(), but always returns an online
node. When the mapped node from a given proximity ID is offline,
it looks up the node distance table and returns the nearest
online node.
ACPI device drivers, which are called after the NUMA initialization
has completed in the kernel, can call this interface to obtain their
device NUMA topology from ACPI tables. Such drivers do not have to
deal with offline nodes. A node may be offline when a device
proximity ID is unique, SRAT memory entry does not exist, or NUMA is
disabled, ex. "numa=off" on x86.
This patch also moves the pxm range check from acpi_get_node() to
acpi_map_pxm_to_node().
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2015-06-20 07:14:15 +08:00
|
|
|
return NUMA_NO_NODE;
|
|
|
|
|
|
|
|
node = pxm_to_node_map[pxm];
|
2006-06-23 17:03:19 +08:00
|
|
|
|
2013-08-30 09:25:40 +08:00
|
|
|
if (node == NUMA_NO_NODE) {
|
2006-06-23 17:03:19 +08:00
|
|
|
if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
|
2009-11-18 06:27:32 +08:00
|
|
|
return NUMA_NO_NODE;
|
2006-06-23 17:03:19 +08:00
|
|
|
node = first_unset_node(nodes_found_map);
|
2007-07-21 23:10:32 +08:00
|
|
|
__acpi_map_pxm_to_node(pxm, node);
|
2006-06-23 17:03:19 +08:00
|
|
|
node_set(node, nodes_found_map);
|
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
2018-11-10 04:43:07 +08:00
|
|
|
EXPORT_SYMBOL(acpi_map_pxm_to_node);
|
2006-06-23 17:03:19 +08:00
|
|
|
|
2007-07-21 23:09:56 +08:00
|
|
|
static void __init
|
|
|
|
acpi_table_print_srat_entry(struct acpi_subtable_header *header)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
switch (header->type) {
|
2007-02-03 00:48:22 +08:00
|
|
|
case ACPI_SRAT_TYPE_CPU_AFFINITY:
|
2005-08-05 12:44:28 +08:00
|
|
|
{
|
2007-02-03 00:48:22 +08:00
|
|
|
struct acpi_srat_cpu_affinity *p =
|
|
|
|
(struct acpi_srat_cpu_affinity *)header;
|
2016-05-25 06:35:32 +08:00
|
|
|
pr_debug("SRAT Processor (id[0x%02x] eid[0x%02x]) in proximity domain %d %s\n",
|
|
|
|
p->apic_id, p->local_sapic_eid,
|
|
|
|
p->proximity_domain_lo,
|
|
|
|
(p->flags & ACPI_SRAT_CPU_ENABLED) ?
|
|
|
|
"enabled" : "disabled");
|
2005-08-05 12:44:28 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
|
2005-08-05 12:44:28 +08:00
|
|
|
{
|
2007-02-03 00:48:22 +08:00
|
|
|
struct acpi_srat_mem_affinity *p =
|
|
|
|
(struct acpi_srat_mem_affinity *)header;
|
ACPI: NUMA: Use correct type for printing addresses on i386-PAE
The addresses of NUMA nodes are not printed correctly on i386-PAE
which is misleading.
Here is a debian9-32bit with PAE in a QEMU guest having more than 4G
of memory:
qemu-system-i386 \
-hda /var/lib/libvirt/images/debian32.qcow2 \
-m 5G \
-enable-kvm \
-smp 10 \
-numa node,mem=512M,nodeid=0,cpus=0 \
-numa node,mem=512M,nodeid=1,cpus=1 \
-numa node,mem=512M,nodeid=2,cpus=2 \
-numa node,mem=512M,nodeid=3,cpus=3 \
-numa node,mem=512M,nodeid=4,cpus=4 \
-numa node,mem=512M,nodeid=5,cpus=5 \
-numa node,mem=512M,nodeid=6,cpus=6 \
-numa node,mem=512M,nodeid=7,cpus=7 \
-numa node,mem=512M,nodeid=8,cpus=8 \
-numa node,mem=512M,nodeid=9,cpus=9 \
-serial stdio
Because of the wrong value type, it prints as below:
[ 0.021049] ACPI: SRAT Memory (0x0 length 0xa0000) in proximity domain 0 enabled
[ 0.021740] ACPI: SRAT Memory (0x100000 length 0x1ff00000) in proximity domain 0 enabled
[ 0.022425] ACPI: SRAT Memory (0x20000000 length 0x20000000) in proximity domain 1 enabled
[ 0.023092] ACPI: SRAT Memory (0x40000000 length 0x20000000) in proximity domain 2 enabled
[ 0.023764] ACPI: SRAT Memory (0x60000000 length 0x20000000) in proximity domain 3 enabled
[ 0.024431] ACPI: SRAT Memory (0x80000000 length 0x20000000) in proximity domain 4 enabled
[ 0.025104] ACPI: SRAT Memory (0xa0000000 length 0x20000000) in proximity domain 5 enabled
[ 0.025791] ACPI: SRAT Memory (0x0 length 0x20000000) in proximity domain 6 enabled
[ 0.026412] ACPI: SRAT Memory (0x20000000 length 0x20000000) in proximity domain 7 enabled
[ 0.027118] ACPI: SRAT Memory (0x40000000 length 0x20000000) in proximity domain 8 enabled
[ 0.027802] ACPI: SRAT Memory (0x60000000 length 0x20000000) in proximity domain 9 enabled
The upper half of the start address of the NUMA domains between 6
and 9 inclusive was cut, so the printed values are incorrect.
Fix the value type, to get the correct values in the log as follows:
[ 0.023698] ACPI: SRAT Memory (0x0 length 0xa0000) in proximity domain 0 enabled
[ 0.024325] ACPI: SRAT Memory (0x100000 length 0x1ff00000) in proximity domain 0 enabled
[ 0.024981] ACPI: SRAT Memory (0x20000000 length 0x20000000) in proximity domain 1 enabled
[ 0.025659] ACPI: SRAT Memory (0x40000000 length 0x20000000) in proximity domain 2 enabled
[ 0.026317] ACPI: SRAT Memory (0x60000000 length 0x20000000) in proximity domain 3 enabled
[ 0.026980] ACPI: SRAT Memory (0x80000000 length 0x20000000) in proximity domain 4 enabled
[ 0.027635] ACPI: SRAT Memory (0xa0000000 length 0x20000000) in proximity domain 5 enabled
[ 0.028311] ACPI: SRAT Memory (0x100000000 length 0x20000000) in proximity domain 6 enabled
[ 0.028985] ACPI: SRAT Memory (0x120000000 length 0x20000000) in proximity domain 7 enabled
[ 0.029667] ACPI: SRAT Memory (0x140000000 length 0x20000000) in proximity domain 8 enabled
[ 0.030334] ACPI: SRAT Memory (0x160000000 length 0x20000000) in proximity domain 9 enabled
Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
[ rjw: Subject & changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-12-26 11:34:50 +08:00
|
|
|
pr_debug("SRAT Memory (0x%llx length 0x%llx) in proximity domain %d %s%s%s\n",
|
|
|
|
(unsigned long long)p->base_address,
|
|
|
|
(unsigned long long)p->length,
|
2016-05-25 06:35:32 +08:00
|
|
|
p->proximity_domain,
|
|
|
|
(p->flags & ACPI_SRAT_MEM_ENABLED) ?
|
|
|
|
"enabled" : "disabled",
|
|
|
|
(p->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) ?
|
|
|
|
" hot-pluggable" : "",
|
|
|
|
(p->flags & ACPI_SRAT_MEM_NON_VOLATILE) ?
|
|
|
|
" non-volatile" : "");
|
2005-08-05 12:44:28 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2009-03-31 05:55:30 +08:00
|
|
|
case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
|
|
|
|
{
|
|
|
|
struct acpi_srat_x2apic_cpu_affinity *p =
|
|
|
|
(struct acpi_srat_x2apic_cpu_affinity *)header;
|
2016-05-25 06:35:32 +08:00
|
|
|
pr_debug("SRAT Processor (x2apicid[0x%08x]) in proximity domain %d %s\n",
|
|
|
|
p->apic_id,
|
|
|
|
p->proximity_domain,
|
|
|
|
(p->flags & ACPI_SRAT_CPU_ENABLED) ?
|
|
|
|
"enabled" : "disabled");
|
2009-03-31 05:55:30 +08:00
|
|
|
}
|
|
|
|
break;
|
2016-05-25 06:35:32 +08:00
|
|
|
|
2016-06-17 11:53:02 +08:00
|
|
|
case ACPI_SRAT_TYPE_GICC_AFFINITY:
|
|
|
|
{
|
|
|
|
struct acpi_srat_gicc_affinity *p =
|
|
|
|
(struct acpi_srat_gicc_affinity *)header;
|
|
|
|
pr_debug("SRAT Processor (acpi id[0x%04x]) in proximity domain %d %s\n",
|
|
|
|
p->acpi_processor_uid,
|
|
|
|
p->proximity_domain,
|
|
|
|
(p->flags & ACPI_SRAT_GICC_ENABLED) ?
|
|
|
|
"enabled" : "disabled");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-09-30 22:05:42 +08:00
|
|
|
case ACPI_SRAT_TYPE_GENERIC_AFFINITY:
|
|
|
|
{
|
|
|
|
struct acpi_srat_generic_affinity *p =
|
|
|
|
(struct acpi_srat_generic_affinity *)header;
|
|
|
|
|
|
|
|
if (p->device_handle_type == 0) {
|
|
|
|
/*
|
|
|
|
* For pci devices this may be the only place they
|
|
|
|
* are assigned a proximity domain
|
|
|
|
*/
|
|
|
|
pr_debug("SRAT Generic Initiator(Seg:%u BDF:%u) in proximity domain %d %s\n",
|
|
|
|
*(u16 *)(&p->device_handle[0]),
|
|
|
|
*(u16 *)(&p->device_handle[2]),
|
|
|
|
p->proximity_domain,
|
|
|
|
(p->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED) ?
|
|
|
|
"enabled" : "disabled");
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* In this case we can rely on the device having a
|
|
|
|
* proximity domain reference
|
|
|
|
*/
|
|
|
|
pr_debug("SRAT Generic Initiator(HID=%.8s UID=%.4s) in proximity domain %d %s\n",
|
|
|
|
(char *)(&p->device_handle[0]),
|
|
|
|
(char *)(&p->device_handle[8]),
|
|
|
|
p->proximity_domain,
|
|
|
|
(p->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED) ?
|
|
|
|
"enabled" : "disabled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
default:
|
2016-05-25 06:35:31 +08:00
|
|
|
pr_warn("Found unsupported SRAT entry (type = 0x%x)\n",
|
|
|
|
header->type);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-10 07:48:18 +08:00
|
|
|
/*
|
|
|
|
* A lot of BIOS fill in 10 (= no distance) everywhere. This messes
|
|
|
|
* up the NUMA heuristics which wants the local node to have a smaller
|
|
|
|
* distance than the others.
|
|
|
|
* Do some quick checks here and only use the SLIT if it passes.
|
|
|
|
*/
|
2013-08-13 18:31:14 +08:00
|
|
|
static int __init slit_valid(struct acpi_table_slit *slit)
|
2008-06-10 07:48:18 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
int d = slit->locality_count;
|
|
|
|
for (i = 0; i < d; i++) {
|
|
|
|
for (j = 0; j < d; j++) {
|
|
|
|
u8 val = slit->entry[d*i + j];
|
|
|
|
if (i == j) {
|
|
|
|
if (val != LOCAL_DISTANCE)
|
|
|
|
return 0;
|
|
|
|
} else if (val <= LOCAL_DISTANCE)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-25 06:35:39 +08:00
|
|
|
void __init bad_srat(void)
|
|
|
|
{
|
|
|
|
pr_err("SRAT: SRAT not used.\n");
|
2020-10-14 07:48:57 +08:00
|
|
|
disable_srat();
|
2016-05-25 06:35:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int __init srat_disabled(void)
|
|
|
|
{
|
|
|
|
return acpi_numa < 0;
|
|
|
|
}
|
|
|
|
|
2021-07-05 20:42:04 +08:00
|
|
|
#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
|
2016-05-25 06:35:35 +08:00
|
|
|
/*
|
|
|
|
* Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for
|
|
|
|
* I/O localities since SRAT does not list them. I/O localities are
|
|
|
|
* not supported at this point.
|
|
|
|
*/
|
|
|
|
void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < slit->locality_count; i++) {
|
|
|
|
const int from_node = pxm_to_node(i);
|
|
|
|
|
|
|
|
if (from_node == NUMA_NO_NODE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < slit->locality_count; j++) {
|
|
|
|
const int to_node = pxm_to_node(j);
|
|
|
|
|
|
|
|
if (to_node == NUMA_NO_NODE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
numa_set_distance(from_node, to_node,
|
|
|
|
slit->entry[slit->locality_count * i + j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-25 06:35:41 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Default callback for parsing of the Proximity Domain <-> Memory
|
|
|
|
* Area mappings
|
|
|
|
*/
|
|
|
|
int __init
|
|
|
|
acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
|
|
|
|
{
|
|
|
|
u64 start, end;
|
|
|
|
u32 hotpluggable;
|
|
|
|
int node, pxm;
|
|
|
|
|
|
|
|
if (srat_disabled())
|
|
|
|
goto out_err;
|
2016-05-25 06:35:42 +08:00
|
|
|
if (ma->header.length < sizeof(struct acpi_srat_mem_affinity)) {
|
|
|
|
pr_err("SRAT: Unexpected header length: %d\n",
|
|
|
|
ma->header.length);
|
2016-05-25 06:35:41 +08:00
|
|
|
goto out_err_bad_srat;
|
2016-05-25 06:35:42 +08:00
|
|
|
}
|
2016-05-25 06:35:41 +08:00
|
|
|
if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
|
|
|
|
goto out_err;
|
2021-12-16 17:58:26 +08:00
|
|
|
hotpluggable = IS_ENABLED(CONFIG_MEMORY_HOTPLUG) &&
|
|
|
|
(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE);
|
2016-05-25 06:35:41 +08:00
|
|
|
|
|
|
|
start = ma->base_address;
|
|
|
|
end = start + ma->length;
|
|
|
|
pxm = ma->proximity_domain;
|
|
|
|
if (acpi_srat_revision <= 1)
|
|
|
|
pxm &= 0xff;
|
|
|
|
|
|
|
|
node = acpi_map_pxm_to_node(pxm);
|
2020-07-21 17:59:06 +08:00
|
|
|
if (node == NUMA_NO_NODE) {
|
2016-05-25 06:35:42 +08:00
|
|
|
pr_err("SRAT: Too many proximity domains.\n");
|
2016-05-25 06:35:41 +08:00
|
|
|
goto out_err_bad_srat;
|
|
|
|
}
|
|
|
|
|
2016-05-25 06:35:42 +08:00
|
|
|
if (numa_add_memblk(node, start, end) < 0) {
|
|
|
|
pr_err("SRAT: Failed to add memblk to node %u [mem %#010Lx-%#010Lx]\n",
|
|
|
|
node, (unsigned long long) start,
|
|
|
|
(unsigned long long) end - 1);
|
2016-05-25 06:35:41 +08:00
|
|
|
goto out_err_bad_srat;
|
2016-05-25 06:35:42 +08:00
|
|
|
}
|
2016-05-25 06:35:41 +08:00
|
|
|
|
|
|
|
node_set(node, numa_nodes_parsed);
|
|
|
|
|
|
|
|
pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s%s\n",
|
|
|
|
node, pxm,
|
|
|
|
(unsigned long long) start, (unsigned long long) end - 1,
|
|
|
|
hotpluggable ? " hotplug" : "",
|
|
|
|
ma->flags & ACPI_SRAT_MEM_NON_VOLATILE ? " non-volatile" : "");
|
|
|
|
|
|
|
|
/* Mark hotplug range in memblock. */
|
|
|
|
if (hotpluggable && memblock_mark_hotplug(start, ma->length))
|
|
|
|
pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
|
|
|
|
(unsigned long long)start, (unsigned long long)end - 1);
|
|
|
|
|
|
|
|
max_possible_pfn = max(max_possible_pfn, PFN_UP(end - 1));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
out_err_bad_srat:
|
|
|
|
bad_srat();
|
|
|
|
out_err:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2021-10-30 03:51:59 +08:00
|
|
|
|
|
|
|
static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
|
|
|
|
void *arg, const unsigned long table_end)
|
|
|
|
{
|
|
|
|
struct acpi_cedt_cfmws *cfmws;
|
|
|
|
int *fake_pxm = arg;
|
|
|
|
u64 start, end;
|
|
|
|
int node;
|
|
|
|
|
|
|
|
cfmws = (struct acpi_cedt_cfmws *)header;
|
|
|
|
start = cfmws->base_hpa;
|
|
|
|
end = cfmws->base_hpa + cfmws->window_size;
|
|
|
|
|
|
|
|
/* Skip if the SRAT already described the NUMA details for this HPA */
|
|
|
|
node = phys_to_target_node(start);
|
|
|
|
if (node != NUMA_NO_NODE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
node = acpi_map_pxm_to_node(*fake_pxm);
|
|
|
|
|
|
|
|
if (node == NUMA_NO_NODE) {
|
|
|
|
pr_err("ACPI NUMA: Too many proximity domains while processing CFMWS.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numa_add_memblk(node, start, end) < 0) {
|
|
|
|
/* CXL driver must handle the NUMA_NO_NODE case */
|
|
|
|
pr_warn("ACPI NUMA: Failed to add memblk for CFMWS node %d [mem %#llx-%#llx]\n",
|
|
|
|
node, start, end);
|
|
|
|
}
|
2022-10-21 07:54:55 +08:00
|
|
|
node_set(node, numa_nodes_parsed);
|
2021-10-30 03:51:59 +08:00
|
|
|
|
|
|
|
/* Set the next available fake_pxm value */
|
|
|
|
(*fake_pxm)++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static int __init acpi_parse_cfmws(union acpi_subtable_headers *header,
|
|
|
|
void *arg, const unsigned long table_end)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2016-05-25 06:35:35 +08:00
|
|
|
#endif /* defined(CONFIG_X86) || defined (CONFIG_ARM64) */
|
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
static int __init acpi_parse_slit(struct acpi_table_header *table)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2015-02-05 17:33:14 +08:00
|
|
|
struct acpi_table_slit *slit = (struct acpi_table_slit *)table;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-06-10 07:48:18 +08:00
|
|
|
if (!slit_valid(slit)) {
|
2016-05-25 06:35:31 +08:00
|
|
|
pr_info("SLIT table looks invalid. Not used.\n");
|
2008-06-10 07:48:18 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
acpi_numa_slit_init(slit);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-28 08:19:15 +08:00
|
|
|
void __init __weak
|
2009-03-31 05:55:30 +08:00
|
|
|
acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
|
|
|
|
{
|
2016-05-25 06:35:31 +08:00
|
|
|
pr_warn("Found unsupported x2apic [0x%08x] SRAT entry\n", pa->apic_id);
|
2009-03-31 05:55:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_parse_x2apic_affinity(union acpi_subtable_headers *header,
|
2009-03-31 05:55:30 +08:00
|
|
|
const unsigned long end)
|
|
|
|
{
|
|
|
|
struct acpi_srat_x2apic_cpu_affinity *processor_affinity;
|
|
|
|
|
|
|
|
processor_affinity = (struct acpi_srat_x2apic_cpu_affinity *)header;
|
|
|
|
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_table_print_srat_entry(&header->common);
|
2009-03-31 05:55:30 +08:00
|
|
|
|
|
|
|
/* let architecture-dependent part to do it */
|
|
|
|
acpi_numa_x2apic_affinity_init(processor_affinity);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int __init
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_parse_processor_affinity(union acpi_subtable_headers *header,
|
2005-08-05 12:44:28 +08:00
|
|
|
const unsigned long end)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-03 00:48:22 +08:00
|
|
|
struct acpi_srat_cpu_affinity *processor_affinity;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
processor_affinity = (struct acpi_srat_cpu_affinity *)header;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_table_print_srat_entry(&header->common);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* let architecture-dependent part to do it */
|
|
|
|
acpi_numa_processor_affinity_init(processor_affinity);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-17 11:53:02 +08:00
|
|
|
static int __init
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_parse_gicc_affinity(union acpi_subtable_headers *header,
|
2016-06-17 11:53:02 +08:00
|
|
|
const unsigned long end)
|
|
|
|
{
|
|
|
|
struct acpi_srat_gicc_affinity *processor_affinity;
|
|
|
|
|
|
|
|
processor_affinity = (struct acpi_srat_gicc_affinity *)header;
|
|
|
|
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_table_print_srat_entry(&header->common);
|
2016-06-17 11:53:02 +08:00
|
|
|
|
|
|
|
/* let architecture-dependent part to do it */
|
|
|
|
acpi_numa_gicc_affinity_init(processor_affinity);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:05:42 +08:00
|
|
|
#if defined(CONFIG_X86) || defined(CONFIG_ARM64)
|
|
|
|
static int __init
|
|
|
|
acpi_parse_gi_affinity(union acpi_subtable_headers *header,
|
|
|
|
const unsigned long end)
|
|
|
|
{
|
|
|
|
struct acpi_srat_generic_affinity *gi_affinity;
|
|
|
|
int node;
|
|
|
|
|
|
|
|
gi_affinity = (struct acpi_srat_generic_affinity *)header;
|
|
|
|
if (!gi_affinity)
|
|
|
|
return -EINVAL;
|
|
|
|
acpi_table_print_srat_entry(&header->common);
|
|
|
|
|
|
|
|
if (!(gi_affinity->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
node = acpi_map_pxm_to_node(gi_affinity->proximity_domain);
|
|
|
|
if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
|
|
|
|
pr_err("SRAT: Too many proximity domains.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
node_set(node, numa_nodes_parsed);
|
|
|
|
node_set_state(node, N_GENERIC_INITIATOR);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static int __init
|
|
|
|
acpi_parse_gi_affinity(union acpi_subtable_headers *header,
|
|
|
|
const unsigned long end)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* defined(CONFIG_X86) || defined (CONFIG_ARM64) */
|
|
|
|
|
2012-07-31 23:41:09 +08:00
|
|
|
static int __initdata parsed_numa_memblks;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int __init
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_parse_memory_affinity(union acpi_subtable_headers * header,
|
2005-08-05 12:44:28 +08:00
|
|
|
const unsigned long end)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-03 00:48:22 +08:00
|
|
|
struct acpi_srat_mem_affinity *memory_affinity;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
memory_affinity = (struct acpi_srat_mem_affinity *)header;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-03-12 04:55:57 +08:00
|
|
|
acpi_table_print_srat_entry(&header->common);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* let architecture-dependent part to do it */
|
2012-07-31 23:41:09 +08:00
|
|
|
if (!acpi_numa_memory_affinity_init(memory_affinity))
|
|
|
|
parsed_numa_memblks++;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
static int __init acpi_parse_srat(struct acpi_table_header *table)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2015-02-05 17:33:14 +08:00
|
|
|
struct acpi_table_srat *srat = (struct acpi_table_srat *)table;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-17 17:18:02 +08:00
|
|
|
acpi_srat_revision = srat->header.revision;
|
|
|
|
|
2010-07-21 06:18:36 +08:00
|
|
|
/* Real work done in acpi_table_parse_srat below. */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-21 23:09:56 +08:00
|
|
|
static int __init
|
2007-02-03 00:48:22 +08:00
|
|
|
acpi_table_parse_srat(enum acpi_srat_type id,
|
2013-01-12 23:29:38 +08:00
|
|
|
acpi_tbl_entry_handler handler, unsigned int max_entries)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-11 11:17:07 +08:00
|
|
|
return acpi_table_parse_entries(ACPI_SIG_SRAT,
|
2005-08-05 12:44:28 +08:00
|
|
|
sizeof(struct acpi_table_srat), id,
|
|
|
|
handler, max_entries);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
x86, ACPI, mm: Revert movablemem_map support
Tim found:
WARNING: at arch/x86/kernel/smpboot.c:324 topology_sane.isra.2+0x6f/0x80()
Hardware name: S2600CP
sched: CPU #1's llc-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency.
smpboot: Booting Node 1, Processors #1
Modules linked in:
Pid: 0, comm: swapper/1 Not tainted 3.9.0-0-generic #1
Call Trace:
set_cpu_sibling_map+0x279/0x449
start_secondary+0x11d/0x1e5
Don Morris reproduced on a HP z620 workstation, and bisected it to
commit e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock
is ready")
It turns out movable_map has some problems, and it breaks several things
1. numa_init is called several times, NOT just for srat. so those
nodes_clear(numa_nodes_parsed)
memset(&numa_meminfo, 0, sizeof(numa_meminfo))
can not be just removed. Need to consider sequence is: numaq, srat, amd, dummy.
and make fall back path working.
2. simply split acpi_numa_init to early_parse_srat.
a. that early_parse_srat is NOT called for ia64, so you break ia64.
b. for (i = 0; i < MAX_LOCAL_APIC; i++)
set_apicid_to_node(i, NUMA_NO_NODE)
still left in numa_init. So it will just clear result from early_parse_srat.
it should be moved before that....
c. it breaks ACPI_TABLE_OVERIDE...as the acpi table scan is moved
early before override from INITRD is settled.
3. that patch TITLE is total misleading, there is NO x86 in the title,
but it changes critical x86 code. It caused x86 guys did not
pay attention to find the problem early. Those patches really should
be routed via tip/x86/mm.
4. after that commit, following range can not use movable ram:
a. real_mode code.... well..funny, legacy Node0 [0,1M) could be hot-removed?
b. initrd... it will be freed after booting, so it could be on movable...
c. crashkernel for kdump...: looks like we can not put kdump kernel above 4G
anymore.
d. init_mem_mapping: can not put page table high anymore.
e. initmem_init: vmemmap can not be high local node anymore. That is
not good.
If node is hotplugable, the mem related range like page table and
vmemmap could be on the that node without problem and should be on that
node.
We have workaround patch that could fix some problems, but some can not
be fixed.
So just remove that offending commit and related ones including:
f7210e6c4ac7 ("mm/memblock.c: use CONFIG_HAVE_MEMBLOCK_NODE_MAP to
protect movablecore_map in memblock_overlaps_region().")
01a178a94e8e ("acpi, memory-hotplug: support getting hotplug info from
SRAT")
27168d38fa20 ("acpi, memory-hotplug: extend movablemem_map ranges to
the end of node")
e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock is
ready")
fb06bc8e5f42 ("page_alloc: bootmem limit with movablecore_map")
42f47e27e761 ("page_alloc: make movablemem_map have higher priority")
6981ec31146c ("page_alloc: introduce zone_movable_limit[] to keep
movable limit for nodes")
34b71f1e04fc ("page_alloc: add movable_memmap kernel parameter")
4d59a75125d5 ("x86: get pg_data_t's memory from other node")
Later we should have patches that will make sure kernel put page table
and vmemmap on local node ram instead of push them down to node0. Also
need to find way to put other kernel used ram to local node ram.
Reported-by: Tim Gardner <tim.gardner@canonical.com>
Reported-by: Don Morris <don.morris@hp.com>
Bisected-by: Don Morris <don.morris@hp.com>
Tested-by: Don Morris <don.morris@hp.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-03-02 06:51:27 +08:00
|
|
|
int __init acpi_numa_init(void)
|
acpi, memory-hotplug: parse SRAT before memblock is ready
On linux, the pages used by kernel could not be migrated. As a result,
if a memory range is used by kernel, it cannot be hot-removed. So if we
want to hot-remove memory, we should prevent kernel from using it.
The way now used to prevent this is specify a memory range by
movablemem_map boot option and set it as ZONE_MOVABLE.
But when the system is booting, memblock will allocate memory, and
reserve the memory for kernel. And before we parse SRAT, and know the
node memory ranges, memblock is working. And it may allocate memory in
ranges to be set as ZONE_MOVABLE. This memory can be used by kernel,
and never be freed.
So, let's parse SRAT before memblock is called first. And it is early
enough.
The first call of memblock_find_in_range_node() is in:
setup_arch()
|-->setup_real_mode()
so, this patch add a function early_parse_srat() to parse SRAT, and call
it before setup_real_mode() is called.
NOTE:
1) early_parse_srat() is called before numa_init(), and has initialized
numa_meminfo. So DO NOT clear numa_nodes_parsed in numa_init() and DO
NOT zero numa_meminfo in numa_init(), otherwise we will lose memory
numa info.
2) I don't know why using count of memory affinities parsed from SRAT
as a return value in original acpi_numa_init(). So I add a static
variable srat_mem_cnt to remember this count and use it as the return
value of the new acpi_numa_init()
[mhocko@suse.cz: parse SRAT before memblock is ready fix]
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Wen Congyang <wency@cn.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Jiang Liu <jiang.liu@huawei.com>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Wu Jianguo <wujianguo@huawei.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Len Brown <lenb@kernel.org>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-23 08:33:44 +08:00
|
|
|
{
|
2021-10-30 03:51:59 +08:00
|
|
|
int i, fake_pxm, cnt = 0;
|
x86, ACPI, mm: Revert movablemem_map support
Tim found:
WARNING: at arch/x86/kernel/smpboot.c:324 topology_sane.isra.2+0x6f/0x80()
Hardware name: S2600CP
sched: CPU #1's llc-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency.
smpboot: Booting Node 1, Processors #1
Modules linked in:
Pid: 0, comm: swapper/1 Not tainted 3.9.0-0-generic #1
Call Trace:
set_cpu_sibling_map+0x279/0x449
start_secondary+0x11d/0x1e5
Don Morris reproduced on a HP z620 workstation, and bisected it to
commit e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock
is ready")
It turns out movable_map has some problems, and it breaks several things
1. numa_init is called several times, NOT just for srat. so those
nodes_clear(numa_nodes_parsed)
memset(&numa_meminfo, 0, sizeof(numa_meminfo))
can not be just removed. Need to consider sequence is: numaq, srat, amd, dummy.
and make fall back path working.
2. simply split acpi_numa_init to early_parse_srat.
a. that early_parse_srat is NOT called for ia64, so you break ia64.
b. for (i = 0; i < MAX_LOCAL_APIC; i++)
set_apicid_to_node(i, NUMA_NO_NODE)
still left in numa_init. So it will just clear result from early_parse_srat.
it should be moved before that....
c. it breaks ACPI_TABLE_OVERIDE...as the acpi table scan is moved
early before override from INITRD is settled.
3. that patch TITLE is total misleading, there is NO x86 in the title,
but it changes critical x86 code. It caused x86 guys did not
pay attention to find the problem early. Those patches really should
be routed via tip/x86/mm.
4. after that commit, following range can not use movable ram:
a. real_mode code.... well..funny, legacy Node0 [0,1M) could be hot-removed?
b. initrd... it will be freed after booting, so it could be on movable...
c. crashkernel for kdump...: looks like we can not put kdump kernel above 4G
anymore.
d. init_mem_mapping: can not put page table high anymore.
e. initmem_init: vmemmap can not be high local node anymore. That is
not good.
If node is hotplugable, the mem related range like page table and
vmemmap could be on the that node without problem and should be on that
node.
We have workaround patch that could fix some problems, but some can not
be fixed.
So just remove that offending commit and related ones including:
f7210e6c4ac7 ("mm/memblock.c: use CONFIG_HAVE_MEMBLOCK_NODE_MAP to
protect movablecore_map in memblock_overlaps_region().")
01a178a94e8e ("acpi, memory-hotplug: support getting hotplug info from
SRAT")
27168d38fa20 ("acpi, memory-hotplug: extend movablemem_map ranges to
the end of node")
e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock is
ready")
fb06bc8e5f42 ("page_alloc: bootmem limit with movablecore_map")
42f47e27e761 ("page_alloc: make movablemem_map have higher priority")
6981ec31146c ("page_alloc: introduce zone_movable_limit[] to keep
movable limit for nodes")
34b71f1e04fc ("page_alloc: add movable_memmap kernel parameter")
4d59a75125d5 ("x86: get pg_data_t's memory from other node")
Later we should have patches that will make sure kernel put page table
and vmemmap on local node ram instead of push them down to node0. Also
need to find way to put other kernel used ram to local node ram.
Reported-by: Tim Gardner <tim.gardner@canonical.com>
Reported-by: Don Morris <don.morris@hp.com>
Bisected-by: Don Morris <don.morris@hp.com>
Tested-by: Don Morris <don.morris@hp.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-03-02 06:51:27 +08:00
|
|
|
|
2016-06-17 11:53:02 +08:00
|
|
|
if (acpi_disabled)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-12-17 11:09:58 +08:00
|
|
|
/*
|
|
|
|
* Should not limit number with cpu num that is from NR_CPUS or nr_cpus=
|
|
|
|
* SRAT cpu entries could have different order with that in MADT.
|
|
|
|
* So go over all cpu entries in SRAT to get apicid to node mapping.
|
|
|
|
*/
|
2009-09-26 06:20:04 +08:00
|
|
|
|
2017-07-22 06:51:24 +08:00
|
|
|
/* SRAT: System Resource Affinity Table */
|
2007-02-11 10:28:03 +08:00
|
|
|
if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
|
2020-09-30 22:05:42 +08:00
|
|
|
struct acpi_subtable_proc srat_proc[4];
|
2016-04-21 17:29:00 +08:00
|
|
|
|
|
|
|
memset(srat_proc, 0, sizeof(srat_proc));
|
|
|
|
srat_proc[0].id = ACPI_SRAT_TYPE_CPU_AFFINITY;
|
|
|
|
srat_proc[0].handler = acpi_parse_processor_affinity;
|
|
|
|
srat_proc[1].id = ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY;
|
|
|
|
srat_proc[1].handler = acpi_parse_x2apic_affinity;
|
2016-06-17 11:53:02 +08:00
|
|
|
srat_proc[2].id = ACPI_SRAT_TYPE_GICC_AFFINITY;
|
|
|
|
srat_proc[2].handler = acpi_parse_gicc_affinity;
|
2020-09-30 22:05:42 +08:00
|
|
|
srat_proc[3].id = ACPI_SRAT_TYPE_GENERIC_AFFINITY;
|
|
|
|
srat_proc[3].handler = acpi_parse_gi_affinity;
|
2016-04-21 17:29:00 +08:00
|
|
|
|
|
|
|
acpi_table_parse_entries_array(ACPI_SIG_SRAT,
|
|
|
|
sizeof(struct acpi_table_srat),
|
|
|
|
srat_proc, ARRAY_SIZE(srat_proc), 0);
|
|
|
|
|
x86, ACPI, mm: Revert movablemem_map support
Tim found:
WARNING: at arch/x86/kernel/smpboot.c:324 topology_sane.isra.2+0x6f/0x80()
Hardware name: S2600CP
sched: CPU #1's llc-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency.
smpboot: Booting Node 1, Processors #1
Modules linked in:
Pid: 0, comm: swapper/1 Not tainted 3.9.0-0-generic #1
Call Trace:
set_cpu_sibling_map+0x279/0x449
start_secondary+0x11d/0x1e5
Don Morris reproduced on a HP z620 workstation, and bisected it to
commit e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock
is ready")
It turns out movable_map has some problems, and it breaks several things
1. numa_init is called several times, NOT just for srat. so those
nodes_clear(numa_nodes_parsed)
memset(&numa_meminfo, 0, sizeof(numa_meminfo))
can not be just removed. Need to consider sequence is: numaq, srat, amd, dummy.
and make fall back path working.
2. simply split acpi_numa_init to early_parse_srat.
a. that early_parse_srat is NOT called for ia64, so you break ia64.
b. for (i = 0; i < MAX_LOCAL_APIC; i++)
set_apicid_to_node(i, NUMA_NO_NODE)
still left in numa_init. So it will just clear result from early_parse_srat.
it should be moved before that....
c. it breaks ACPI_TABLE_OVERIDE...as the acpi table scan is moved
early before override from INITRD is settled.
3. that patch TITLE is total misleading, there is NO x86 in the title,
but it changes critical x86 code. It caused x86 guys did not
pay attention to find the problem early. Those patches really should
be routed via tip/x86/mm.
4. after that commit, following range can not use movable ram:
a. real_mode code.... well..funny, legacy Node0 [0,1M) could be hot-removed?
b. initrd... it will be freed after booting, so it could be on movable...
c. crashkernel for kdump...: looks like we can not put kdump kernel above 4G
anymore.
d. init_mem_mapping: can not put page table high anymore.
e. initmem_init: vmemmap can not be high local node anymore. That is
not good.
If node is hotplugable, the mem related range like page table and
vmemmap could be on the that node without problem and should be on that
node.
We have workaround patch that could fix some problems, but some can not
be fixed.
So just remove that offending commit and related ones including:
f7210e6c4ac7 ("mm/memblock.c: use CONFIG_HAVE_MEMBLOCK_NODE_MAP to
protect movablecore_map in memblock_overlaps_region().")
01a178a94e8e ("acpi, memory-hotplug: support getting hotplug info from
SRAT")
27168d38fa20 ("acpi, memory-hotplug: extend movablemem_map ranges to
the end of node")
e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock is
ready")
fb06bc8e5f42 ("page_alloc: bootmem limit with movablecore_map")
42f47e27e761 ("page_alloc: make movablemem_map have higher priority")
6981ec31146c ("page_alloc: introduce zone_movable_limit[] to keep
movable limit for nodes")
34b71f1e04fc ("page_alloc: add movable_memmap kernel parameter")
4d59a75125d5 ("x86: get pg_data_t's memory from other node")
Later we should have patches that will make sure kernel put page table
and vmemmap on local node ram instead of push them down to node0. Also
need to find way to put other kernel used ram to local node ram.
Reported-by: Tim Gardner <tim.gardner@canonical.com>
Reported-by: Don Morris <don.morris@hp.com>
Bisected-by: Don Morris <don.morris@hp.com>
Tested-by: Don Morris <don.morris@hp.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-03-02 06:51:27 +08:00
|
|
|
cnt = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
|
2017-11-16 01:29:02 +08:00
|
|
|
acpi_parse_memory_affinity, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SLIT: System Locality Information Table */
|
2007-02-11 10:28:03 +08:00
|
|
|
acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2021-10-30 03:51:59 +08:00
|
|
|
/*
|
|
|
|
* CXL Fixed Memory Window Structures (CFMWS) must be parsed
|
|
|
|
* after the SRAT. Create NUMA Nodes for CXL memory ranges that
|
|
|
|
* are defined in the CFMWS and not already defined in the SRAT.
|
|
|
|
* Initialize a fake_pxm as the first available PXM to emulate.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* fake_pxm is the next unused PXM value after SRAT parsing */
|
|
|
|
for (i = 0, fake_pxm = -1; i < MAX_NUMNODES - 1; i++) {
|
|
|
|
if (node_to_pxm_map[i] > fake_pxm)
|
|
|
|
fake_pxm = node_to_pxm_map[i];
|
|
|
|
}
|
|
|
|
fake_pxm++;
|
|
|
|
acpi_table_parse_cedt(ACPI_CEDT_TYPE_CFMWS, acpi_parse_cfmws,
|
|
|
|
&fake_pxm);
|
|
|
|
|
x86, ACPI, mm: Revert movablemem_map support
Tim found:
WARNING: at arch/x86/kernel/smpboot.c:324 topology_sane.isra.2+0x6f/0x80()
Hardware name: S2600CP
sched: CPU #1's llc-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency.
smpboot: Booting Node 1, Processors #1
Modules linked in:
Pid: 0, comm: swapper/1 Not tainted 3.9.0-0-generic #1
Call Trace:
set_cpu_sibling_map+0x279/0x449
start_secondary+0x11d/0x1e5
Don Morris reproduced on a HP z620 workstation, and bisected it to
commit e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock
is ready")
It turns out movable_map has some problems, and it breaks several things
1. numa_init is called several times, NOT just for srat. so those
nodes_clear(numa_nodes_parsed)
memset(&numa_meminfo, 0, sizeof(numa_meminfo))
can not be just removed. Need to consider sequence is: numaq, srat, amd, dummy.
and make fall back path working.
2. simply split acpi_numa_init to early_parse_srat.
a. that early_parse_srat is NOT called for ia64, so you break ia64.
b. for (i = 0; i < MAX_LOCAL_APIC; i++)
set_apicid_to_node(i, NUMA_NO_NODE)
still left in numa_init. So it will just clear result from early_parse_srat.
it should be moved before that....
c. it breaks ACPI_TABLE_OVERIDE...as the acpi table scan is moved
early before override from INITRD is settled.
3. that patch TITLE is total misleading, there is NO x86 in the title,
but it changes critical x86 code. It caused x86 guys did not
pay attention to find the problem early. Those patches really should
be routed via tip/x86/mm.
4. after that commit, following range can not use movable ram:
a. real_mode code.... well..funny, legacy Node0 [0,1M) could be hot-removed?
b. initrd... it will be freed after booting, so it could be on movable...
c. crashkernel for kdump...: looks like we can not put kdump kernel above 4G
anymore.
d. init_mem_mapping: can not put page table high anymore.
e. initmem_init: vmemmap can not be high local node anymore. That is
not good.
If node is hotplugable, the mem related range like page table and
vmemmap could be on the that node without problem and should be on that
node.
We have workaround patch that could fix some problems, but some can not
be fixed.
So just remove that offending commit and related ones including:
f7210e6c4ac7 ("mm/memblock.c: use CONFIG_HAVE_MEMBLOCK_NODE_MAP to
protect movablecore_map in memblock_overlaps_region().")
01a178a94e8e ("acpi, memory-hotplug: support getting hotplug info from
SRAT")
27168d38fa20 ("acpi, memory-hotplug: extend movablemem_map ranges to
the end of node")
e8d195525809 ("acpi, memory-hotplug: parse SRAT before memblock is
ready")
fb06bc8e5f42 ("page_alloc: bootmem limit with movablecore_map")
42f47e27e761 ("page_alloc: make movablemem_map have higher priority")
6981ec31146c ("page_alloc: introduce zone_movable_limit[] to keep
movable limit for nodes")
34b71f1e04fc ("page_alloc: add movable_memmap kernel parameter")
4d59a75125d5 ("x86: get pg_data_t's memory from other node")
Later we should have patches that will make sure kernel put page table
and vmemmap on local node ram instead of push them down to node0. Also
need to find way to put other kernel used ram to local node ram.
Reported-by: Tim Gardner <tim.gardner@canonical.com>
Reported-by: Don Morris <don.morris@hp.com>
Bisected-by: Don Morris <don.morris@hp.com>
Tested-by: Don Morris <don.morris@hp.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-03-02 06:51:27 +08:00
|
|
|
if (cnt < 0)
|
|
|
|
return cnt;
|
2012-07-31 23:41:09 +08:00
|
|
|
else if (!parsed_numa_memblks)
|
2012-07-31 23:41:08 +08:00
|
|
|
return -ENOENT;
|
2011-02-16 19:13:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2014-01-25 06:48:01 +08:00
|
|
|
static int acpi_get_pxm(acpi_handle h)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-10-10 14:22:59 +08:00
|
|
|
unsigned long long pxm;
|
2005-04-17 06:20:36 +08:00
|
|
|
acpi_status status;
|
|
|
|
acpi_handle handle;
|
|
|
|
acpi_handle phandle = h;
|
|
|
|
|
|
|
|
do {
|
|
|
|
handle = phandle;
|
|
|
|
status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm);
|
|
|
|
if (ACPI_SUCCESS(status))
|
2006-10-01 06:28:50 +08:00
|
|
|
return pxm;
|
2005-04-17 06:20:36 +08:00
|
|
|
status = acpi_get_parent(handle, &phandle);
|
2005-08-05 12:44:28 +08:00
|
|
|
} while (ACPI_SUCCESS(status));
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2006-06-27 17:53:31 +08:00
|
|
|
|
2014-01-25 06:25:10 +08:00
|
|
|
int acpi_get_node(acpi_handle handle)
|
2006-06-27 17:53:31 +08:00
|
|
|
{
|
2014-01-25 06:42:17 +08:00
|
|
|
int pxm;
|
2006-06-27 17:53:31 +08:00
|
|
|
|
|
|
|
pxm = acpi_get_pxm(handle);
|
|
|
|
|
2020-08-18 22:24:29 +08:00
|
|
|
return pxm_to_node(pxm);
|
2006-06-27 17:53:31 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(acpi_get_node);
|