xref: /openbmc/linux/arch/powerpc/include/asm/topology.h (revision 800f65bba8d2030b3fef62850e203f9f176625a8)
1 #ifndef _ASM_POWERPC_TOPOLOGY_H
2 #define _ASM_POWERPC_TOPOLOGY_H
3 #ifdef __KERNEL__
4 
5 
6 struct sys_device;
7 struct device_node;
8 
9 #ifdef CONFIG_NUMA
10 
11 /*
12  * Before going off node we want the VM to try and reclaim from the local
13  * node. It does this if the remote distance is larger than RECLAIM_DISTANCE.
14  * With the default REMOTE_DISTANCE of 20 and the default RECLAIM_DISTANCE of
15  * 20, we never reclaim and go off node straight away.
16  *
17  * To fix this we choose a smaller value of RECLAIM_DISTANCE.
18  */
19 #define RECLAIM_DISTANCE 10
20 
21 /*
22  * Before going off node we want the VM to try and reclaim from the local
23  * node. It does this if the remote distance is larger than RECLAIM_DISTANCE.
24  * With the default REMOTE_DISTANCE of 20 and the default RECLAIM_DISTANCE of
25  * 20, we never reclaim and go off node straight away.
26  *
27  * To fix this we choose a smaller value of RECLAIM_DISTANCE.
28  */
29 #define RECLAIM_DISTANCE 10
30 
31 #include <asm/mmzone.h>
32 
33 static inline int cpu_to_node(int cpu)
34 {
35 	return numa_cpu_lookup_table[cpu];
36 }
37 
38 #define parent_node(node)	(node)
39 
40 #define cpumask_of_node(node) ((node) == -1 ?				\
41 			       cpu_all_mask :				\
42 			       node_to_cpumask_map[node])
43 
44 int of_node_to_nid(struct device_node *device);
45 
46 struct pci_bus;
47 #ifdef CONFIG_PCI
48 extern int pcibus_to_node(struct pci_bus *bus);
49 #else
50 static inline int pcibus_to_node(struct pci_bus *bus)
51 {
52 	return -1;
53 }
54 #endif
55 
56 #define cpumask_of_pcibus(bus)	(pcibus_to_node(bus) == -1 ?		\
57 				 cpu_all_mask :				\
58 				 cpumask_of_node(pcibus_to_node(bus)))
59 
60 /* sched_domains SD_NODE_INIT for PPC64 machines */
61 #define SD_NODE_INIT (struct sched_domain) {				\
62 	.min_interval		= 8,					\
63 	.max_interval		= 32,					\
64 	.busy_factor		= 32,					\
65 	.imbalance_pct		= 125,					\
66 	.cache_nice_tries	= 1,					\
67 	.busy_idx		= 3,					\
68 	.idle_idx		= 1,					\
69 	.newidle_idx		= 0,					\
70 	.wake_idx		= 0,					\
71 	.forkexec_idx		= 0,					\
72 									\
73 	.flags			= 1*SD_LOAD_BALANCE			\
74 				| 1*SD_BALANCE_NEWIDLE			\
75 				| 1*SD_BALANCE_EXEC			\
76 				| 1*SD_BALANCE_FORK			\
77 				| 0*SD_BALANCE_WAKE			\
78 				| 0*SD_WAKE_AFFINE			\
79 				| 0*SD_PREFER_LOCAL			\
80 				| 0*SD_SHARE_CPUPOWER			\
81 				| 0*SD_POWERSAVINGS_BALANCE		\
82 				| 0*SD_SHARE_PKG_RESOURCES		\
83 				| 1*SD_SERIALIZE			\
84 				| 0*SD_PREFER_SIBLING			\
85 				,					\
86 	.last_balance		= jiffies,				\
87 	.balance_interval	= 1,					\
88 }
89 
90 extern void __init dump_numa_cpu_topology(void);
91 
92 extern int sysfs_add_device_to_node(struct sys_device *dev, int nid);
93 extern void sysfs_remove_device_from_node(struct sys_device *dev, int nid);
94 
95 #else
96 
97 static inline int of_node_to_nid(struct device_node *device)
98 {
99 	return 0;
100 }
101 
102 static inline void dump_numa_cpu_topology(void) {}
103 
104 static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid)
105 {
106 	return 0;
107 }
108 
109 static inline void sysfs_remove_device_from_node(struct sys_device *dev,
110 						int nid)
111 {
112 }
113 
114 #endif /* CONFIG_NUMA */
115 
116 #include <asm-generic/topology.h>
117 
118 #ifdef CONFIG_SMP
119 #include <asm/cputable.h>
120 #define smt_capable()		(cpu_has_feature(CPU_FTR_SMT))
121 
122 #ifdef CONFIG_PPC64
123 #include <asm/smp.h>
124 
125 #define topology_thread_cpumask(cpu)	(per_cpu(cpu_sibling_map, cpu))
126 #define topology_core_cpumask(cpu)	(per_cpu(cpu_core_map, cpu))
127 #define topology_core_id(cpu)		(cpu_to_core_id(cpu))
128 #endif
129 #endif
130 
131 #endif /* __KERNEL__ */
132 #endif	/* _ASM_POWERPC_TOPOLOGY_H */
133