^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_X86_NUMA_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_X86_NUMA_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/nodemask.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/topology.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/apicdef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifdef CONFIG_NUMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Too small node sizes may confuse the VM badly. Usually they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * result from BIOS bugs. So dont recognize nodes as standalone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * NUMA entities that have less than this amount of RAM listed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define NODE_MIN_SIZE (4*1024*1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern int numa_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * __apicid_to_node[] stores the raw mapping between physical apicid and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * node and is used to initialize cpu_to_node mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * should be accessed by the accessors - set_apicid_to_node() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * numa_cpu_node().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern s16 __apicid_to_node[MAX_LOCAL_APIC];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern nodemask_t numa_nodes_parsed __initdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) extern void __init numa_set_distance(int from, int to, int distance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline void set_apicid_to_node(int apicid, s16 node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __apicid_to_node[apicid] = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) extern int numa_cpu_node(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #else /* CONFIG_NUMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static inline void set_apicid_to_node(int apicid, s16 node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline int numa_cpu_node(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return NUMA_NO_NODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #endif /* CONFIG_NUMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #ifdef CONFIG_X86_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) # include <asm/numa_32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #ifdef CONFIG_NUMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) extern void numa_set_node(int cpu, int node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) extern void numa_clear_node(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) extern void __init init_cpu_to_node(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) extern void numa_add_cpu(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) extern void numa_remove_cpu(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) extern void init_gi_nodes(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #else /* CONFIG_NUMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static inline void numa_set_node(int cpu, int node) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static inline void numa_clear_node(int cpu) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static inline void init_cpu_to_node(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static inline void numa_add_cpu(int cpu) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static inline void numa_remove_cpu(int cpu) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static inline void init_gi_nodes(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #endif /* CONFIG_NUMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #ifdef CONFIG_DEBUG_PER_CPU_MAPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) void debug_cpumask_set_cpu(int cpu, int node, bool enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #ifdef CONFIG_NUMA_EMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define FAKE_NODE_MIN_SIZE ((u64)32 << 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int numa_emu_cmdline(char *str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #else /* CONFIG_NUMA_EMU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static inline int numa_emu_cmdline(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #endif /* CONFIG_NUMA_EMU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #endif /* _ASM_X86_NUMA_H */