mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
[ Upstream commit f9f67e5adc8dc2e1cc51ab2d3d6382fa97f074d4 ]
For configurations that have the kconfig option NUMA_KEEP_MEMINFO
disabled, numa_fill_memblks() only returns with NUMA_NO_MEMBLK (-1).
SRAT lookup fails then because an existing SRAT memory range cannot be
found for a CFMWS address range. This causes the addition of a
duplicate numa_memblk with a different node id and a subsequent page
fault and kernel crash during boot.
Fix this by making numa_fill_memblks() always available regardless of
NUMA_KEEP_MEMINFO.
As Dan suggested, the fix is implemented to remove numa_fill_memblks()
from sparsemem.h and alos using __weak for the function.
Note that the issue was initially introduced with [1]. But since
phys_to_target_node() was originally used that returned the valid node
0, an additional numa_memblk was not added. Though, the node id was
wrong too, a message is seen then in the logs:
kernel/numa.c: pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n",
[1] commit fd49f99c18
("ACPI: NUMA: Add a node and memblk for each
CFMWS not in SRAT")
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/all/66271b0072317_69102944c@dwillia2-xfh.jf.intel.com.notmuch/
Fixes: 8f1004679987 ("ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window")
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
63 lines
1.3 KiB
C
63 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_NUMA_H
|
|
#define _LINUX_NUMA_H
|
|
#include <linux/init.h>
|
|
#include <linux/types.h>
|
|
|
|
#ifdef CONFIG_NODES_SHIFT
|
|
#define NODES_SHIFT CONFIG_NODES_SHIFT
|
|
#else
|
|
#define NODES_SHIFT 0
|
|
#endif
|
|
|
|
#define MAX_NUMNODES (1 << NODES_SHIFT)
|
|
|
|
#define NUMA_NO_NODE (-1)
|
|
#define NUMA_NO_MEMBLK (-1)
|
|
|
|
/* optionally keep NUMA memory info available post init */
|
|
#ifdef CONFIG_NUMA_KEEP_MEMINFO
|
|
#define __initdata_or_meminfo
|
|
#else
|
|
#define __initdata_or_meminfo __initdata
|
|
#endif
|
|
|
|
#ifdef CONFIG_NUMA
|
|
#include <asm/sparsemem.h>
|
|
|
|
/* Generic implementation available */
|
|
int numa_nearest_node(int node, unsigned int state);
|
|
|
|
#ifndef memory_add_physaddr_to_nid
|
|
int memory_add_physaddr_to_nid(u64 start);
|
|
#endif
|
|
|
|
#ifndef phys_to_target_node
|
|
int phys_to_target_node(u64 start);
|
|
#endif
|
|
|
|
int numa_fill_memblks(u64 start, u64 end);
|
|
|
|
#else /* !CONFIG_NUMA */
|
|
static inline int numa_nearest_node(int node, unsigned int state)
|
|
{
|
|
return NUMA_NO_NODE;
|
|
}
|
|
|
|
static inline int memory_add_physaddr_to_nid(u64 start)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int phys_to_target_node(u64 start)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#define numa_map_to_online_node(node) numa_nearest_node(node, N_ONLINE)
|
|
|
|
#ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
|
|
extern const struct attribute_group arch_node_dev_group;
|
|
#endif
|
|
|
|
#endif /* _LINUX_NUMA_H */
|