162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __ASM_GENERIC_NUMA_H
362306a36Sopenharmony_ci#define __ASM_GENERIC_NUMA_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#ifdef CONFIG_NUMA
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#define NR_NODE_MEMBLKS		(MAX_NUMNODES * 2)
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciint __node_distance(int from, int to);
1062306a36Sopenharmony_ci#define node_distance(a, b) __node_distance(a, b)
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciextern nodemask_t numa_nodes_parsed __initdata;
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciextern bool numa_off;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/* Mappings between node number and cpus on that node. */
1762306a36Sopenharmony_ciextern cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
1862306a36Sopenharmony_civoid numa_clear_node(unsigned int cpu);
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_PER_CPU_MAPS
2162306a36Sopenharmony_ciconst struct cpumask *cpumask_of_node(int node);
2262306a36Sopenharmony_ci#else
2362306a36Sopenharmony_ci/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
2462306a36Sopenharmony_cistatic inline const struct cpumask *cpumask_of_node(int node)
2562306a36Sopenharmony_ci{
2662306a36Sopenharmony_ci	if (node == NUMA_NO_NODE)
2762306a36Sopenharmony_ci		return cpu_all_mask;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	return node_to_cpumask_map[node];
3062306a36Sopenharmony_ci}
3162306a36Sopenharmony_ci#endif
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_civoid __init arch_numa_init(void);
3462306a36Sopenharmony_ciint __init numa_add_memblk(int nodeid, u64 start, u64 end);
3562306a36Sopenharmony_civoid __init numa_set_distance(int from, int to, int distance);
3662306a36Sopenharmony_civoid __init numa_free_distance(void);
3762306a36Sopenharmony_civoid __init early_map_cpu_to_node(unsigned int cpu, int nid);
3862306a36Sopenharmony_ciint __init early_cpu_to_node(int cpu);
3962306a36Sopenharmony_civoid numa_store_cpu_info(unsigned int cpu);
4062306a36Sopenharmony_civoid numa_add_cpu(unsigned int cpu);
4162306a36Sopenharmony_civoid numa_remove_cpu(unsigned int cpu);
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#else	/* CONFIG_NUMA */
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_cistatic inline void numa_store_cpu_info(unsigned int cpu) { }
4662306a36Sopenharmony_cistatic inline void numa_add_cpu(unsigned int cpu) { }
4762306a36Sopenharmony_cistatic inline void numa_remove_cpu(unsigned int cpu) { }
4862306a36Sopenharmony_cistatic inline void arch_numa_init(void) { }
4962306a36Sopenharmony_cistatic inline void early_map_cpu_to_node(unsigned int cpu, int nid) { }
5062306a36Sopenharmony_cistatic inline int early_cpu_to_node(int cpu) { return 0; }
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#endif	/* CONFIG_NUMA */
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#endif	/* __ASM_GENERIC_NUMA_H */
55