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