Merge branch 'x86/urgent' into x86/core
[linux-2.6] / arch / ia64 / include / asm / topology.h
1 /*
2  * Copyright (C) 2002, Erich Focht, NEC
3  *
4  * All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11 #ifndef _ASM_IA64_TOPOLOGY_H
12 #define _ASM_IA64_TOPOLOGY_H
13
14 #include <asm/acpi.h>
15 #include <asm/numa.h>
16 #include <asm/smp.h>
17
18 #ifdef CONFIG_NUMA
19
20 /* Nodes w/o CPUs are preferred for memory allocations, see build_zonelists */
21 #define PENALTY_FOR_NODE_WITH_CPUS 255
22
23 /*
24  * Distance above which we begin to use zone reclaim
25  */
26 #define RECLAIM_DISTANCE 15
27
28 /*
29  * Returns the number of the node containing CPU 'cpu'
30  */
31 #define cpu_to_node(cpu) (int)(cpu_to_node_map[cpu])
32
33 /*
34  * Returns a bitmask of CPUs on Node 'node'.
35  */
36 #define node_to_cpumask(node) (node_to_cpu_mask[node])
37 #define cpumask_of_node(node) (&node_to_cpu_mask[node])
38
39 /*
40  * Returns the number of the node containing Node 'nid'.
41  * Not implemented here. Multi-level hierarchies detected with
42  * the help of node_distance().
43  */
44 #define parent_node(nid) (nid)
45
46 /*
47  * Returns the number of the first CPU on Node 'node'.
48  */
49 #define node_to_first_cpu(node) (cpumask_first(cpumask_of_node(node)))
50
51 /*
52  * Determines the node for a given pci bus
53  */
54 #define pcibus_to_node(bus) PCI_CONTROLLER(bus)->node
55
56 void build_cpu_to_node_map(void);
57
58 #define SD_CPU_INIT (struct sched_domain) {             \
59         .parent                 = NULL,                 \
60         .child                  = NULL,                 \
61         .groups                 = NULL,                 \
62         .min_interval           = 1,                    \
63         .max_interval           = 4,                    \
64         .busy_factor            = 64,                   \
65         .imbalance_pct          = 125,                  \
66         .cache_nice_tries       = 2,                    \
67         .busy_idx               = 2,                    \
68         .idle_idx               = 1,                    \
69         .newidle_idx            = 2,                    \
70         .wake_idx               = 1,                    \
71         .forkexec_idx           = 1,                    \
72         .flags                  = SD_LOAD_BALANCE       \
73                                 | SD_BALANCE_NEWIDLE    \
74                                 | SD_BALANCE_EXEC       \
75                                 | SD_WAKE_AFFINE,       \
76         .last_balance           = jiffies,              \
77         .balance_interval       = 1,                    \
78         .nr_balance_failed      = 0,                    \
79 }
80
81 /* sched_domains SD_NODE_INIT for IA64 NUMA machines */
82 #define SD_NODE_INIT (struct sched_domain) {            \
83         .parent                 = NULL,                 \
84         .child                  = NULL,                 \
85         .groups                 = NULL,                 \
86         .min_interval           = 8,                    \
87         .max_interval           = 8*(min(num_online_cpus(), 32U)), \
88         .busy_factor            = 64,                   \
89         .imbalance_pct          = 125,                  \
90         .cache_nice_tries       = 2,                    \
91         .busy_idx               = 3,                    \
92         .idle_idx               = 2,                    \
93         .newidle_idx            = 2,                    \
94         .wake_idx               = 1,                    \
95         .forkexec_idx           = 1,                    \
96         .flags                  = SD_LOAD_BALANCE       \
97                                 | SD_BALANCE_EXEC       \
98                                 | SD_BALANCE_FORK       \
99                                 | SD_SERIALIZE          \
100                                 | SD_WAKE_BALANCE,      \
101         .last_balance           = jiffies,              \
102         .balance_interval       = 64,                   \
103         .nr_balance_failed      = 0,                    \
104 }
105
106 #endif /* CONFIG_NUMA */
107
108 #ifdef CONFIG_SMP
109 #define topology_physical_package_id(cpu)       (cpu_data(cpu)->socket_id)
110 #define topology_core_id(cpu)                   (cpu_data(cpu)->core_id)
111 #define topology_core_siblings(cpu)             (cpu_core_map[cpu])
112 #define topology_thread_siblings(cpu)           (per_cpu(cpu_sibling_map, cpu))
113 #define topology_core_cpumask(cpu)              (&cpu_core_map[cpu])
114 #define topology_thread_cpumask(cpu)            (&per_cpu(cpu_sibling_map, cpu))
115 #define smt_capable()                           (smp_num_siblings > 1)
116 #endif
117
118 extern void arch_fix_phys_package_id(int num, u32 slot);
119
120 #define pcibus_to_cpumask(bus)  (pcibus_to_node(bus) == -1 ? \
121                                         CPU_MASK_ALL : \
122                                         node_to_cpumask(pcibus_to_node(bus)) \
123                                 )
124
125 #define cpumask_of_pcibus(bus)  (pcibus_to_node(bus) == -1 ?            \
126                                  cpu_all_mask :                         \
127                                  cpumask_of_node(pcibus_to_node(bus)))
128
129 #include <asm-generic/topology.h>
130
131 #endif /* _ASM_IA64_TOPOLOGY_H */