Blame view
include/linux/cpuset.h
5.74 KB
1da177e4c
|
1 2 3 4 5 6 |
#ifndef _LINUX_CPUSET_H #define _LINUX_CPUSET_H /* * cpuset interface * * Copyright (C) 2003 BULL SA |
825a46af5
|
7 |
* Copyright (C) 2004-2006 Silicon Graphics, Inc. |
1da177e4c
|
8 9 10 11 12 13 |
* */ #include <linux/sched.h> #include <linux/cpumask.h> #include <linux/nodemask.h> |
a1bc5a4ee
|
14 |
#include <linux/mm.h> |
664eeddee
|
15 |
#include <linux/jump_label.h> |
1da177e4c
|
16 17 |
#ifdef CONFIG_CPUSETS |
664eeddee
|
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
extern struct static_key cpusets_enabled_key; static inline bool cpusets_enabled(void) { return static_key_false(&cpusets_enabled_key); } static inline int nr_cpusets(void) { /* jump label reference count + the top-level cpuset */ return static_key_count(&cpusets_enabled_key) + 1; } static inline void cpuset_inc(void) { static_key_slow_inc(&cpusets_enabled_key); } static inline void cpuset_dec(void) { static_key_slow_dec(&cpusets_enabled_key); } |
202f72d5d
|
39 |
|
1da177e4c
|
40 41 |
extern int cpuset_init(void); extern void cpuset_init_smp(void); |
7ddf96b02
|
42 |
extern void cpuset_update_active_cpus(bool cpu_online); |
6af866af3
|
43 |
extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); |
2baab4e90
|
44 |
extern void cpuset_cpus_allowed_fallback(struct task_struct *p); |
909d75a3b
|
45 |
extern nodemask_t cpuset_mems_allowed(struct task_struct *p); |
9276b1bc9
|
46 |
#define cpuset_current_mems_allowed (current->mems_allowed) |
1da177e4c
|
47 |
void cpuset_init_current_mems_allowed(void); |
19770b326
|
48 |
int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask); |
202f72d5d
|
49 |
|
344736f29
|
50 |
extern int __cpuset_node_allowed(int node, gfp_t gfp_mask); |
02a0e53d8
|
51 |
|
344736f29
|
52 |
static inline int cpuset_node_allowed(int node, gfp_t gfp_mask) |
02a0e53d8
|
53 |
{ |
344736f29
|
54 |
return nr_cpusets() <= 1 || __cpuset_node_allowed(node, gfp_mask); |
02a0e53d8
|
55 |
} |
344736f29
|
56 |
static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) |
202f72d5d
|
57 |
{ |
344736f29
|
58 |
return cpuset_node_allowed(zone_to_nid(z), gfp_mask); |
202f72d5d
|
59 |
} |
bbe373f2c
|
60 61 |
extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, const struct task_struct *tsk2); |
3e0d98b9f
|
62 63 64 65 66 67 68 69 |
#define cpuset_memory_pressure_bump() \ do { \ if (cpuset_memory_pressure_enabled) \ __cpuset_memory_pressure_bump(); \ } while (0) extern int cpuset_memory_pressure_enabled; extern void __cpuset_memory_pressure_bump(void); |
df5f8314c
|
70 71 |
extern void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task); |
52de4779f
|
72 73 |
extern int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *tsk); |
1da177e4c
|
74 |
|
825a46af5
|
75 |
extern int cpuset_mem_spread_node(void); |
6adef3ebe
|
76 |
extern int cpuset_slab_spread_node(void); |
825a46af5
|
77 78 79 |
static inline int cpuset_do_page_mem_spread(void) { |
2ad654bc5
|
80 |
return task_spread_page(current); |
825a46af5
|
81 82 83 84 |
} static inline int cpuset_do_slab_mem_spread(void) { |
2ad654bc5
|
85 |
return task_spread_slab(current); |
825a46af5
|
86 |
} |
8793d854e
|
87 |
extern int current_cpuset_is_being_rebound(void); |
e761b7725
|
88 |
extern void rebuild_sched_domains(void); |
da39da3a5
|
89 |
extern void cpuset_print_current_mems_allowed(void); |
75aa19941
|
90 |
|
c0ff7453b
|
91 |
/* |
d26914d11
|
92 93 94 95 96 |
* read_mems_allowed_begin is required when making decisions involving * mems_allowed such as during page allocation. mems_allowed can be updated in * parallel and depending on the new value an operation can fail potentially * causing process failure. A retry loop with read_mems_allowed_begin and * read_mems_allowed_retry prevents these artificial failures. |
c0ff7453b
|
97 |
*/ |
d26914d11
|
98 |
static inline unsigned int read_mems_allowed_begin(void) |
c0ff7453b
|
99 |
{ |
46e700abc
|
100 101 |
if (!cpusets_enabled()) return 0; |
cc9a6c877
|
102 |
return read_seqcount_begin(¤t->mems_allowed_seq); |
c0ff7453b
|
103 |
} |
cc9a6c877
|
104 |
/* |
d26914d11
|
105 106 107 |
* If this returns true, the operation that took place after * read_mems_allowed_begin may have failed artificially due to a concurrent * update of mems_allowed. It is up to the caller to retry the operation if |
cc9a6c877
|
108 109 |
* appropriate. */ |
d26914d11
|
110 |
static inline bool read_mems_allowed_retry(unsigned int seq) |
c0ff7453b
|
111 |
{ |
46e700abc
|
112 113 |
if (!cpusets_enabled()) return false; |
d26914d11
|
114 |
return read_seqcount_retry(¤t->mems_allowed_seq, seq); |
c0ff7453b
|
115 |
} |
58568d2a8
|
116 117 |
static inline void set_mems_allowed(nodemask_t nodemask) { |
db751fe3e
|
118 |
unsigned long flags; |
c0ff7453b
|
119 |
task_lock(current); |
db751fe3e
|
120 |
local_irq_save(flags); |
cc9a6c877
|
121 |
write_seqcount_begin(¤t->mems_allowed_seq); |
58568d2a8
|
122 |
current->mems_allowed = nodemask; |
cc9a6c877
|
123 |
write_seqcount_end(¤t->mems_allowed_seq); |
db751fe3e
|
124 |
local_irq_restore(flags); |
c0ff7453b
|
125 |
task_unlock(current); |
58568d2a8
|
126 |
} |
1da177e4c
|
127 |
#else /* !CONFIG_CPUSETS */ |
664eeddee
|
128 |
static inline bool cpusets_enabled(void) { return false; } |
1da177e4c
|
129 130 |
static inline int cpuset_init(void) { return 0; } static inline void cpuset_init_smp(void) {} |
1da177e4c
|
131 |
|
7ddf96b02
|
132 |
static inline void cpuset_update_active_cpus(bool cpu_online) |
3a101d054
|
133 134 135 |
{ partition_sched_domains(1, NULL, NULL); } |
6af866af3
|
136 137 |
static inline void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask) |
1da177e4c
|
138 |
{ |
aa85ea5b8
|
139 |
cpumask_copy(mask, cpu_possible_mask); |
1da177e4c
|
140 |
} |
2baab4e90
|
141 |
static inline void cpuset_cpus_allowed_fallback(struct task_struct *p) |
9084bb824
|
142 |
{ |
9084bb824
|
143 |
} |
909d75a3b
|
144 145 146 147 |
static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) { return node_possible_map; } |
38d7bee9d
|
148 |
#define cpuset_current_mems_allowed (node_states[N_MEMORY]) |
1da177e4c
|
149 |
static inline void cpuset_init_current_mems_allowed(void) {} |
1da177e4c
|
150 |
|
19770b326
|
151 |
static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask) |
1da177e4c
|
152 153 154 |
{ return 1; } |
344736f29
|
155 |
static inline int cpuset_node_allowed(int node, gfp_t gfp_mask) |
02a0e53d8
|
156 157 158 |
{ return 1; } |
344736f29
|
159 |
static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) |
1da177e4c
|
160 161 162 |
{ return 1; } |
bbe373f2c
|
163 164 |
static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, const struct task_struct *tsk2) |
ef08e3b49
|
165 166 167 |
{ return 1; } |
3e0d98b9f
|
168 |
static inline void cpuset_memory_pressure_bump(void) {} |
df5f8314c
|
169 170 |
static inline void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task) |
1da177e4c
|
171 |
{ |
1da177e4c
|
172 |
} |
825a46af5
|
173 174 175 176 |
static inline int cpuset_mem_spread_node(void) { return 0; } |
6adef3ebe
|
177 178 179 180 |
static inline int cpuset_slab_spread_node(void) { return 0; } |
825a46af5
|
181 182 183 184 185 186 187 188 189 |
static inline int cpuset_do_page_mem_spread(void) { return 0; } static inline int cpuset_do_slab_mem_spread(void) { return 0; } |
8793d854e
|
190 191 192 193 |
static inline int current_cpuset_is_being_rebound(void) { return 0; } |
e761b7725
|
194 195 |
static inline void rebuild_sched_domains(void) { |
dfb512ec4
|
196 |
partition_sched_domains(1, NULL, NULL); |
e761b7725
|
197 |
} |
da39da3a5
|
198 |
static inline void cpuset_print_current_mems_allowed(void) |
75aa19941
|
199 200 |
{ } |
58568d2a8
|
201 202 203 |
static inline void set_mems_allowed(nodemask_t nodemask) { } |
d26914d11
|
204 |
static inline unsigned int read_mems_allowed_begin(void) |
c0ff7453b
|
205 |
{ |
cc9a6c877
|
206 |
return 0; |
c0ff7453b
|
207 |
} |
d26914d11
|
208 |
static inline bool read_mems_allowed_retry(unsigned int seq) |
c0ff7453b
|
209 |
{ |
d26914d11
|
210 |
return false; |
c0ff7453b
|
211 |
} |
1da177e4c
|
212 213 214 |
#endif /* !CONFIG_CPUSETS */ #endif /* _LINUX_CPUSET_H */ |