blob: 4bcd9d0c7bee72303d5b5645c3366a7df67af698 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_NUMA_H
3#define _ASM_X86_NUMA_H
4
5#include <linux/nodemask.h>
6
7#include <asm/topology.h>
8#include <asm/apicdef.h>
9
10#ifdef CONFIG_NUMA
11
12#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
13
14extern int numa_off;
15
16/*
17 * __apicid_to_node[] stores the raw mapping between physical apicid and
18 * node and is used to initialize cpu_to_node mapping.
19 *
20 * The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus
21 * should be accessed by the accessors - set_apicid_to_node() and
22 * numa_cpu_node().
23 */
24extern s16 __apicid_to_node[MAX_LOCAL_APIC];
25extern nodemask_t numa_nodes_parsed __initdata;
26
27extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
28extern void __init numa_set_distance(int from, int to, int distance);
29
30static inline void set_apicid_to_node(int apicid, s16 node)
31{
32 __apicid_to_node[apicid] = node;
33}
34
35extern int numa_cpu_node(int cpu);
36
37#else /* CONFIG_NUMA */
38static inline void set_apicid_to_node(int apicid, s16 node)
39{
40}
41
42static inline int numa_cpu_node(int cpu)
43{
44 return NUMA_NO_NODE;
45}
46#endif /* CONFIG_NUMA */
47
48#ifdef CONFIG_X86_32
49# include <asm/numa_32.h>
50#endif
51
52#ifdef CONFIG_NUMA
53extern void numa_set_node(int cpu, int node);
54extern void numa_clear_node(int cpu);
55extern void __init init_cpu_to_node(void);
56extern void numa_add_cpu(int cpu);
57extern void numa_remove_cpu(int cpu);
58#else /* CONFIG_NUMA */
59static inline void numa_set_node(int cpu, int node) { }
60static inline void numa_clear_node(int cpu) { }
61static inline void init_cpu_to_node(void) { }
62static inline void numa_add_cpu(int cpu) { }
63static inline void numa_remove_cpu(int cpu) { }
64#endif /* CONFIG_NUMA */
65
66#ifdef CONFIG_DEBUG_PER_CPU_MAPS
67void debug_cpumask_set_cpu(int cpu, int node, bool enable);
68#endif
69
70#ifdef CONFIG_NUMA_EMU
71#define FAKE_NODE_MIN_SIZE ((u64)32 << 20)
72#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
73void numa_emu_cmdline(char *);
74#endif /* CONFIG_NUMA_EMU */
75
76#endif /* _ASM_X86_NUMA_H */