blob: bbfde3d2662f4f2254a4604e9eac5efdd11e95f3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Tejun Heobbc9e2f2011-01-23 14:37:39 +01002#ifndef _ASM_X86_NUMA_H
3#define _ASM_X86_NUMA_H
4
Tejun Heo6bd26272011-05-02 14:18:52 +02005#include <linux/nodemask.h>
6
Tejun Heode2d9442011-01-23 14:37:41 +01007#include <asm/topology.h>
Tejun Heobbc9e2f2011-01-23 14:37:39 +01008#include <asm/apicdef.h>
9
10#ifdef CONFIG_NUMA
Tejun Heoef396ec2011-02-16 17:11:07 +010011
12#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
Tejun Heoa4106ea2011-05-02 14:18:53 +020013
14/*
15 * Too small node sizes may confuse the VM badly. Usually they
16 * result from BIOS bugs. So dont recognize nodes as standalone
17 * NUMA entities that have less than this amount of RAM listed:
18 */
19#define NODE_MIN_SIZE (4*1024*1024)
20
21extern int numa_off;
Tejun Heoef396ec2011-02-16 17:11:07 +010022
Tejun Heobbc9e2f2011-01-23 14:37:39 +010023/*
24 * __apicid_to_node[] stores the raw mapping between physical apicid and
25 * node and is used to initialize cpu_to_node mapping.
26 *
27 * The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus
28 * should be accessed by the accessors - set_apicid_to_node() and
29 * numa_cpu_node().
30 */
31extern s16 __apicid_to_node[MAX_LOCAL_APIC];
Tejun Heoe6df5952011-05-02 14:18:53 +020032extern nodemask_t numa_nodes_parsed __initdata;
Tejun Heobbc9e2f2011-01-23 14:37:39 +010033
Tejun Heob0d31082011-05-02 14:18:53 +020034extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
35extern void __init numa_set_distance(int from, int to, int distance);
36
Tejun Heobbc9e2f2011-01-23 14:37:39 +010037static inline void set_apicid_to_node(int apicid, s16 node)
38{
39 __apicid_to_node[apicid] = node;
40}
Tejun Heo6bd26272011-05-02 14:18:52 +020041
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040042extern int numa_cpu_node(int cpu);
Tejun Heo6bd26272011-05-02 14:18:52 +020043
Tejun Heobbc9e2f2011-01-23 14:37:39 +010044#else /* CONFIG_NUMA */
45static inline void set_apicid_to_node(int apicid, s16 node)
46{
47}
Tejun Heo6bd26272011-05-02 14:18:52 +020048
49static inline int numa_cpu_node(int cpu)
50{
51 return NUMA_NO_NODE;
52}
Tejun Heobbc9e2f2011-01-23 14:37:39 +010053#endif /* CONFIG_NUMA */
54
Thomas Gleixner96a388d2007-10-11 11:20:03 +020055#ifdef CONFIG_X86_32
David Howellsa1ce3922012-10-02 18:01:25 +010056# include <asm/numa_32.h>
Thomas Gleixner96a388d2007-10-11 11:20:03 +020057#endif
Tejun Heobbc9e2f2011-01-23 14:37:39 +010058
Tejun Heo645a7912011-01-23 14:37:40 +010059#ifdef CONFIG_NUMA
Wen Congyange13fe862013-02-22 16:33:31 -080060extern void numa_set_node(int cpu, int node);
61extern void numa_clear_node(int cpu);
Tejun Heo8db78cc2011-01-23 14:37:42 +010062extern void __init init_cpu_to_node(void);
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040063extern void numa_add_cpu(int cpu);
64extern void numa_remove_cpu(int cpu);
Tejun Heo645a7912011-01-23 14:37:40 +010065#else /* CONFIG_NUMA */
66static inline void numa_set_node(int cpu, int node) { }
67static inline void numa_clear_node(int cpu) { }
Tejun Heo8db78cc2011-01-23 14:37:42 +010068static inline void init_cpu_to_node(void) { }
Tejun Heode2d9442011-01-23 14:37:41 +010069static inline void numa_add_cpu(int cpu) { }
70static inline void numa_remove_cpu(int cpu) { }
Tejun Heo645a7912011-01-23 14:37:40 +010071#endif /* CONFIG_NUMA */
72
Tejun Heode2d9442011-01-23 14:37:41 +010073#ifdef CONFIG_DEBUG_PER_CPU_MAPS
David Rientjes7a6c6542011-04-20 19:19:13 -070074void debug_cpumask_set_cpu(int cpu, int node, bool enable);
Tejun Heode2d9442011-01-23 14:37:41 +010075#endif
76
Tejun Heoa4106ea2011-05-02 14:18:53 +020077#ifdef CONFIG_NUMA_EMU
78#define FAKE_NODE_MIN_SIZE ((u64)32 << 20)
79#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
80void numa_emu_cmdline(char *);
81#endif /* CONFIG_NUMA_EMU */
82
Tejun Heobbc9e2f2011-01-23 14:37:39 +010083#endif /* _ASM_X86_NUMA_H */