]>
Commit | Line | Data |
---|---|---|
029632fb PZ |
1 | |
2 | #include <linux/sched.h> | |
3 | #include <linux/mutex.h> | |
4 | #include <linux/spinlock.h> | |
5 | #include <linux/stop_machine.h> | |
6 | ||
391e43da | 7 | #include "cpupri.h" |
029632fb PZ |
8 | |
9 | extern __read_mostly int scheduler_running; | |
10 | ||
11 | /* | |
12 | * Convert user-nice values [ -20 ... 0 ... 19 ] | |
13 | * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ], | |
14 | * and back. | |
15 | */ | |
16 | #define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20) | |
17 | #define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20) | |
18 | #define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio) | |
19 | ||
20 | /* | |
21 | * 'User priority' is the nice value converted to something we | |
22 | * can work with better when scaling various scheduler parameters, | |
23 | * it's a [ 0 ... 39 ] range. | |
24 | */ | |
25 | #define USER_PRIO(p) ((p)-MAX_RT_PRIO) | |
26 | #define TASK_USER_PRIO(p) USER_PRIO((p)->static_prio) | |
27 | #define MAX_USER_PRIO (USER_PRIO(MAX_PRIO)) | |
28 | ||
29 | /* | |
30 | * Helpers for converting nanosecond timing to jiffy resolution | |
31 | */ | |
32 | #define NS_TO_JIFFIES(TIME) ((unsigned long)(TIME) / (NSEC_PER_SEC / HZ)) | |
33 | ||
34 | #define NICE_0_LOAD SCHED_LOAD_SCALE | |
35 | #define NICE_0_SHIFT SCHED_LOAD_SHIFT | |
36 | ||
37 | /* | |
38 | * These are the 'tuning knobs' of the scheduler: | |
39 | * | |
40 | * default timeslice is 100 msecs (used only for SCHED_RR tasks). | |
41 | * Timeslices get refilled after they expire. | |
42 | */ | |
43 | #define DEF_TIMESLICE (100 * HZ / 1000) | |
44 | ||
45 | /* | |
46 | * single value that denotes runtime == period, ie unlimited time. | |
47 | */ | |
48 | #define RUNTIME_INF ((u64)~0ULL) | |
49 | ||
50 | static inline int rt_policy(int policy) | |
51 | { | |
52 | if (policy == SCHED_FIFO || policy == SCHED_RR) | |
53 | return 1; | |
54 | return 0; | |
55 | } | |
56 | ||
57 | static inline int task_has_rt_policy(struct task_struct *p) | |
58 | { | |
59 | return rt_policy(p->policy); | |
60 | } | |
61 | ||
62 | /* | |
63 | * This is the priority-queue data structure of the RT scheduling class: | |
64 | */ | |
65 | struct rt_prio_array { | |
66 | DECLARE_BITMAP(bitmap, MAX_RT_PRIO+1); /* include 1 bit for delimiter */ | |
67 | struct list_head queue[MAX_RT_PRIO]; | |
68 | }; | |
69 | ||
70 | struct rt_bandwidth { | |
71 | /* nests inside the rq lock: */ | |
72 | raw_spinlock_t rt_runtime_lock; | |
73 | ktime_t rt_period; | |
74 | u64 rt_runtime; | |
75 | struct hrtimer rt_period_timer; | |
76 | }; | |
77 | ||
78 | extern struct mutex sched_domains_mutex; | |
79 | ||
80 | #ifdef CONFIG_CGROUP_SCHED | |
81 | ||
82 | #include <linux/cgroup.h> | |
83 | ||
84 | struct cfs_rq; | |
85 | struct rt_rq; | |
86 | ||
87 | static LIST_HEAD(task_groups); | |
88 | ||
89 | struct cfs_bandwidth { | |
90 | #ifdef CONFIG_CFS_BANDWIDTH | |
91 | raw_spinlock_t lock; | |
92 | ktime_t period; | |
93 | u64 quota, runtime; | |
94 | s64 hierarchal_quota; | |
95 | u64 runtime_expires; | |
96 | ||
97 | int idle, timer_active; | |
98 | struct hrtimer period_timer, slack_timer; | |
99 | struct list_head throttled_cfs_rq; | |
100 | ||
101 | /* statistics */ | |
102 | int nr_periods, nr_throttled; | |
103 | u64 throttled_time; | |
104 | #endif | |
105 | }; | |
106 | ||
107 | /* task group related information */ | |
108 | struct task_group { | |
109 | struct cgroup_subsys_state css; | |
110 | ||
111 | #ifdef CONFIG_FAIR_GROUP_SCHED | |
112 | /* schedulable entities of this group on each cpu */ | |
113 | struct sched_entity **se; | |
114 | /* runqueue "owned" by this group on each cpu */ | |
115 | struct cfs_rq **cfs_rq; | |
116 | unsigned long shares; | |
117 | ||
118 | atomic_t load_weight; | |
119 | #endif | |
120 | ||
121 | #ifdef CONFIG_RT_GROUP_SCHED | |
122 | struct sched_rt_entity **rt_se; | |
123 | struct rt_rq **rt_rq; | |
124 | ||
125 | struct rt_bandwidth rt_bandwidth; | |
126 | #endif | |
127 | ||
128 | struct rcu_head rcu; | |
129 | struct list_head list; | |
130 | ||
131 | struct task_group *parent; | |
132 | struct list_head siblings; | |
133 | struct list_head children; | |
134 | ||
135 | #ifdef CONFIG_SCHED_AUTOGROUP | |
136 | struct autogroup *autogroup; | |
137 | #endif | |
138 | ||
139 | struct cfs_bandwidth cfs_bandwidth; | |
140 | }; | |
141 | ||
142 | #ifdef CONFIG_FAIR_GROUP_SCHED | |
143 | #define ROOT_TASK_GROUP_LOAD NICE_0_LOAD | |
144 | ||
145 | /* | |
146 | * A weight of 0 or 1 can cause arithmetics problems. | |
147 | * A weight of a cfs_rq is the sum of weights of which entities | |
148 | * are queued on this cfs_rq, so a weight of a entity should not be | |
149 | * too large, so as the shares value of a task group. | |
150 | * (The default weight is 1024 - so there's no practical | |
151 | * limitation from this.) | |
152 | */ | |
153 | #define MIN_SHARES (1UL << 1) | |
154 | #define MAX_SHARES (1UL << 18) | |
155 | #endif | |
156 | ||
157 | /* Default task group. | |
158 | * Every task in system belong to this group at bootup. | |
159 | */ | |
160 | extern struct task_group root_task_group; | |
161 | ||
162 | typedef int (*tg_visitor)(struct task_group *, void *); | |
163 | ||
164 | extern int walk_tg_tree_from(struct task_group *from, | |
165 | tg_visitor down, tg_visitor up, void *data); | |
166 | ||
167 | /* | |
168 | * Iterate the full tree, calling @down when first entering a node and @up when | |
169 | * leaving it for the final time. | |
170 | * | |
171 | * Caller must hold rcu_lock or sufficient equivalent. | |
172 | */ | |
173 | static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data) | |
174 | { | |
175 | return walk_tg_tree_from(&root_task_group, down, up, data); | |
176 | } | |
177 | ||
178 | extern int tg_nop(struct task_group *tg, void *data); | |
179 | ||
180 | extern void free_fair_sched_group(struct task_group *tg); | |
181 | extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent); | |
182 | extern void unregister_fair_sched_group(struct task_group *tg, int cpu); | |
183 | extern void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq, | |
184 | struct sched_entity *se, int cpu, | |
185 | struct sched_entity *parent); | |
186 | extern void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b); | |
187 | extern int sched_group_set_shares(struct task_group *tg, unsigned long shares); | |
188 | ||
189 | extern void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b); | |
190 | extern void __start_cfs_bandwidth(struct cfs_bandwidth *cfs_b); | |
191 | extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq); | |
192 | ||
193 | extern void free_rt_sched_group(struct task_group *tg); | |
194 | extern int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent); | |
195 | extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, | |
196 | struct sched_rt_entity *rt_se, int cpu, | |
197 | struct sched_rt_entity *parent); | |
198 | ||
199 | #else /* CONFIG_CGROUP_SCHED */ | |
200 | ||
201 | struct cfs_bandwidth { }; | |
202 | ||
203 | #endif /* CONFIG_CGROUP_SCHED */ | |
204 | ||
205 | /* CFS-related fields in a runqueue */ | |
206 | struct cfs_rq { | |
207 | struct load_weight load; | |
208 | unsigned long nr_running, h_nr_running; | |
209 | ||
210 | u64 exec_clock; | |
211 | u64 min_vruntime; | |
212 | #ifndef CONFIG_64BIT | |
213 | u64 min_vruntime_copy; | |
214 | #endif | |
215 | ||
216 | struct rb_root tasks_timeline; | |
217 | struct rb_node *rb_leftmost; | |
218 | ||
219 | struct list_head tasks; | |
220 | struct list_head *balance_iterator; | |
221 | ||
222 | /* | |
223 | * 'curr' points to currently running entity on this cfs_rq. | |
224 | * It is set to NULL otherwise (i.e when none are currently running). | |
225 | */ | |
226 | struct sched_entity *curr, *next, *last, *skip; | |
227 | ||
228 | #ifdef CONFIG_SCHED_DEBUG | |
229 | unsigned int nr_spread_over; | |
230 | #endif | |
231 | ||
232 | #ifdef CONFIG_FAIR_GROUP_SCHED | |
233 | struct rq *rq; /* cpu runqueue to which this cfs_rq is attached */ | |
234 | ||
235 | /* | |
236 | * leaf cfs_rqs are those that hold tasks (lowest schedulable entity in | |
237 | * a hierarchy). Non-leaf lrqs hold other higher schedulable entities | |
238 | * (like users, containers etc.) | |
239 | * | |
240 | * leaf_cfs_rq_list ties together list of leaf cfs_rq's in a cpu. This | |
241 | * list is used during load balance. | |
242 | */ | |
243 | int on_list; | |
244 | struct list_head leaf_cfs_rq_list; | |
245 | struct task_group *tg; /* group that "owns" this runqueue */ | |
246 | ||
247 | #ifdef CONFIG_SMP | |
248 | /* | |
249 | * the part of load.weight contributed by tasks | |
250 | */ | |
251 | unsigned long task_weight; | |
252 | ||
253 | /* | |
254 | * h_load = weight * f(tg) | |
255 | * | |
256 | * Where f(tg) is the recursive weight fraction assigned to | |
257 | * this group. | |
258 | */ | |
259 | unsigned long h_load; | |
260 | ||
261 | /* | |
262 | * Maintaining per-cpu shares distribution for group scheduling | |
263 | * | |
264 | * load_stamp is the last time we updated the load average | |
265 | * load_last is the last time we updated the load average and saw load | |
266 | * load_unacc_exec_time is currently unaccounted execution time | |
267 | */ | |
268 | u64 load_avg; | |
269 | u64 load_period; | |
270 | u64 load_stamp, load_last, load_unacc_exec_time; | |
271 | ||
272 | unsigned long load_contribution; | |
273 | #endif /* CONFIG_SMP */ | |
274 | #ifdef CONFIG_CFS_BANDWIDTH | |
275 | int runtime_enabled; | |
276 | u64 runtime_expires; | |
277 | s64 runtime_remaining; | |
278 | ||
279 | u64 throttled_timestamp; | |
280 | int throttled, throttle_count; | |
281 | struct list_head throttled_list; | |
282 | #endif /* CONFIG_CFS_BANDWIDTH */ | |
283 | #endif /* CONFIG_FAIR_GROUP_SCHED */ | |
284 | }; | |
285 | ||
286 | static inline int rt_bandwidth_enabled(void) | |
287 | { | |
288 | return sysctl_sched_rt_runtime >= 0; | |
289 | } | |
290 | ||
291 | /* Real-Time classes' related field in a runqueue: */ | |
292 | struct rt_rq { | |
293 | struct rt_prio_array active; | |
294 | unsigned long rt_nr_running; | |
295 | #if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED | |
296 | struct { | |
297 | int curr; /* highest queued rt task prio */ | |
298 | #ifdef CONFIG_SMP | |
299 | int next; /* next highest */ | |
300 | #endif | |
301 | } highest_prio; | |
302 | #endif | |
303 | #ifdef CONFIG_SMP | |
304 | unsigned long rt_nr_migratory; | |
305 | unsigned long rt_nr_total; | |
306 | int overloaded; | |
307 | struct plist_head pushable_tasks; | |
308 | #endif | |
309 | int rt_throttled; | |
310 | u64 rt_time; | |
311 | u64 rt_runtime; | |
312 | /* Nests inside the rq lock: */ | |
313 | raw_spinlock_t rt_runtime_lock; | |
314 | ||
315 | #ifdef CONFIG_RT_GROUP_SCHED | |
316 | unsigned long rt_nr_boosted; | |
317 | ||
318 | struct rq *rq; | |
319 | struct list_head leaf_rt_rq_list; | |
320 | struct task_group *tg; | |
321 | #endif | |
322 | }; | |
323 | ||
324 | #ifdef CONFIG_SMP | |
325 | ||
326 | /* | |
327 | * We add the notion of a root-domain which will be used to define per-domain | |
328 | * variables. Each exclusive cpuset essentially defines an island domain by | |
329 | * fully partitioning the member cpus from any other cpuset. Whenever a new | |
330 | * exclusive cpuset is created, we also create and attach a new root-domain | |
331 | * object. | |
332 | * | |
333 | */ | |
334 | struct root_domain { | |
335 | atomic_t refcount; | |
336 | atomic_t rto_count; | |
337 | struct rcu_head rcu; | |
338 | cpumask_var_t span; | |
339 | cpumask_var_t online; | |
340 | ||
341 | /* | |
342 | * The "RT overload" flag: it gets set if a CPU has more than | |
343 | * one runnable RT task. | |
344 | */ | |
345 | cpumask_var_t rto_mask; | |
346 | struct cpupri cpupri; | |
347 | }; | |
348 | ||
349 | extern struct root_domain def_root_domain; | |
350 | ||
351 | #endif /* CONFIG_SMP */ | |
352 | ||
353 | /* | |
354 | * This is the main, per-CPU runqueue data structure. | |
355 | * | |
356 | * Locking rule: those places that want to lock multiple runqueues | |
357 | * (such as the load balancing or the thread migration code), lock | |
358 | * acquire operations must be ordered by ascending &runqueue. | |
359 | */ | |
360 | struct rq { | |
361 | /* runqueue lock: */ | |
362 | raw_spinlock_t lock; | |
363 | ||
364 | /* | |
365 | * nr_running and cpu_load should be in the same cacheline because | |
366 | * remote CPUs use both these fields when doing load calculation. | |
367 | */ | |
368 | unsigned long nr_running; | |
369 | #define CPU_LOAD_IDX_MAX 5 | |
370 | unsigned long cpu_load[CPU_LOAD_IDX_MAX]; | |
371 | unsigned long last_load_update_tick; | |
372 | #ifdef CONFIG_NO_HZ | |
373 | u64 nohz_stamp; | |
1c792db7 | 374 | unsigned long nohz_flags; |
029632fb PZ |
375 | #endif |
376 | int skip_clock_update; | |
377 | ||
378 | /* capture load from *all* tasks on this cpu: */ | |
379 | struct load_weight load; | |
380 | unsigned long nr_load_updates; | |
381 | u64 nr_switches; | |
382 | ||
383 | struct cfs_rq cfs; | |
384 | struct rt_rq rt; | |
385 | ||
386 | #ifdef CONFIG_FAIR_GROUP_SCHED | |
387 | /* list of leaf cfs_rq on this cpu: */ | |
388 | struct list_head leaf_cfs_rq_list; | |
389 | #endif | |
390 | #ifdef CONFIG_RT_GROUP_SCHED | |
391 | struct list_head leaf_rt_rq_list; | |
392 | #endif | |
393 | ||
394 | /* | |
395 | * This is part of a global counter where only the total sum | |
396 | * over all CPUs matters. A task can increase this counter on | |
397 | * one CPU and if it got migrated afterwards it may decrease | |
398 | * it on another CPU. Always updated under the runqueue lock: | |
399 | */ | |
400 | unsigned long nr_uninterruptible; | |
401 | ||
402 | struct task_struct *curr, *idle, *stop; | |
403 | unsigned long next_balance; | |
404 | struct mm_struct *prev_mm; | |
405 | ||
406 | u64 clock; | |
407 | u64 clock_task; | |
408 | ||
409 | atomic_t nr_iowait; | |
410 | ||
411 | #ifdef CONFIG_SMP | |
412 | struct root_domain *rd; | |
413 | struct sched_domain *sd; | |
414 | ||
415 | unsigned long cpu_power; | |
416 | ||
417 | unsigned char idle_balance; | |
418 | /* For active balancing */ | |
419 | int post_schedule; | |
420 | int active_balance; | |
421 | int push_cpu; | |
422 | struct cpu_stop_work active_balance_work; | |
423 | /* cpu of this runqueue: */ | |
424 | int cpu; | |
425 | int online; | |
426 | ||
427 | u64 rt_avg; | |
428 | u64 age_stamp; | |
429 | u64 idle_stamp; | |
430 | u64 avg_idle; | |
431 | #endif | |
432 | ||
433 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | |
434 | u64 prev_irq_time; | |
435 | #endif | |
436 | #ifdef CONFIG_PARAVIRT | |
437 | u64 prev_steal_time; | |
438 | #endif | |
439 | #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING | |
440 | u64 prev_steal_time_rq; | |
441 | #endif | |
442 | ||
443 | /* calc_load related fields */ | |
444 | unsigned long calc_load_update; | |
445 | long calc_load_active; | |
446 | ||
447 | #ifdef CONFIG_SCHED_HRTICK | |
448 | #ifdef CONFIG_SMP | |
449 | int hrtick_csd_pending; | |
450 | struct call_single_data hrtick_csd; | |
451 | #endif | |
452 | struct hrtimer hrtick_timer; | |
453 | #endif | |
454 | ||
455 | #ifdef CONFIG_SCHEDSTATS | |
456 | /* latency stats */ | |
457 | struct sched_info rq_sched_info; | |
458 | unsigned long long rq_cpu_time; | |
459 | /* could above be rq->cfs_rq.exec_clock + rq->rt_rq.rt_runtime ? */ | |
460 | ||
461 | /* sys_sched_yield() stats */ | |
462 | unsigned int yld_count; | |
463 | ||
464 | /* schedule() stats */ | |
029632fb PZ |
465 | unsigned int sched_count; |
466 | unsigned int sched_goidle; | |
467 | ||
468 | /* try_to_wake_up() stats */ | |
469 | unsigned int ttwu_count; | |
470 | unsigned int ttwu_local; | |
471 | #endif | |
472 | ||
473 | #ifdef CONFIG_SMP | |
474 | struct llist_head wake_list; | |
475 | #endif | |
476 | }; | |
477 | ||
478 | static inline int cpu_of(struct rq *rq) | |
479 | { | |
480 | #ifdef CONFIG_SMP | |
481 | return rq->cpu; | |
482 | #else | |
483 | return 0; | |
484 | #endif | |
485 | } | |
486 | ||
487 | DECLARE_PER_CPU(struct rq, runqueues); | |
488 | ||
518cd623 PZ |
489 | #define cpu_rq(cpu) (&per_cpu(runqueues, (cpu))) |
490 | #define this_rq() (&__get_cpu_var(runqueues)) | |
491 | #define task_rq(p) cpu_rq(task_cpu(p)) | |
492 | #define cpu_curr(cpu) (cpu_rq(cpu)->curr) | |
493 | #define raw_rq() (&__raw_get_cpu_var(runqueues)) | |
494 | ||
495 | #ifdef CONFIG_SMP | |
496 | ||
029632fb PZ |
497 | #define rcu_dereference_check_sched_domain(p) \ |
498 | rcu_dereference_check((p), \ | |
499 | lockdep_is_held(&sched_domains_mutex)) | |
500 | ||
501 | /* | |
502 | * The domain tree (rq->sd) is protected by RCU's quiescent state transition. | |
503 | * See detach_destroy_domains: synchronize_sched for details. | |
504 | * | |
505 | * The domain tree of any CPU may only be accessed from within | |
506 | * preempt-disabled sections. | |
507 | */ | |
508 | #define for_each_domain(cpu, __sd) \ | |
518cd623 PZ |
509 | for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); \ |
510 | __sd; __sd = __sd->parent) | |
029632fb | 511 | |
77e81365 SS |
512 | #define for_each_lower_domain(sd) for (; sd; sd = sd->child) |
513 | ||
518cd623 PZ |
514 | /** |
515 | * highest_flag_domain - Return highest sched_domain containing flag. | |
516 | * @cpu: The cpu whose highest level of sched domain is to | |
517 | * be returned. | |
518 | * @flag: The flag to check for the highest sched_domain | |
519 | * for the given cpu. | |
520 | * | |
521 | * Returns the highest sched_domain of a cpu which contains the given flag. | |
522 | */ | |
523 | static inline struct sched_domain *highest_flag_domain(int cpu, int flag) | |
524 | { | |
525 | struct sched_domain *sd, *hsd = NULL; | |
526 | ||
527 | for_each_domain(cpu, sd) { | |
528 | if (!(sd->flags & flag)) | |
529 | break; | |
530 | hsd = sd; | |
531 | } | |
532 | ||
533 | return hsd; | |
534 | } | |
535 | ||
536 | DECLARE_PER_CPU(struct sched_domain *, sd_llc); | |
537 | DECLARE_PER_CPU(int, sd_llc_id); | |
538 | ||
539 | #endif /* CONFIG_SMP */ | |
029632fb | 540 | |
391e43da PZ |
541 | #include "stats.h" |
542 | #include "auto_group.h" | |
029632fb PZ |
543 | |
544 | #ifdef CONFIG_CGROUP_SCHED | |
545 | ||
546 | /* | |
547 | * Return the group to which this tasks belongs. | |
548 | * | |
549 | * We use task_subsys_state_check() and extend the RCU verification with | |
550 | * pi->lock and rq->lock because cpu_cgroup_attach() holds those locks for each | |
551 | * task it moves into the cgroup. Therefore by holding either of those locks, | |
552 | * we pin the task to the current cgroup. | |
553 | */ | |
554 | static inline struct task_group *task_group(struct task_struct *p) | |
555 | { | |
556 | struct task_group *tg; | |
557 | struct cgroup_subsys_state *css; | |
558 | ||
559 | css = task_subsys_state_check(p, cpu_cgroup_subsys_id, | |
560 | lockdep_is_held(&p->pi_lock) || | |
561 | lockdep_is_held(&task_rq(p)->lock)); | |
562 | tg = container_of(css, struct task_group, css); | |
563 | ||
564 | return autogroup_task_group(p, tg); | |
565 | } | |
566 | ||
567 | /* Change a task's cfs_rq and parent entity if it moves across CPUs/groups */ | |
568 | static inline void set_task_rq(struct task_struct *p, unsigned int cpu) | |
569 | { | |
570 | #if defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED) | |
571 | struct task_group *tg = task_group(p); | |
572 | #endif | |
573 | ||
574 | #ifdef CONFIG_FAIR_GROUP_SCHED | |
575 | p->se.cfs_rq = tg->cfs_rq[cpu]; | |
576 | p->se.parent = tg->se[cpu]; | |
577 | #endif | |
578 | ||
579 | #ifdef CONFIG_RT_GROUP_SCHED | |
580 | p->rt.rt_rq = tg->rt_rq[cpu]; | |
581 | p->rt.parent = tg->rt_se[cpu]; | |
582 | #endif | |
583 | } | |
584 | ||
585 | #else /* CONFIG_CGROUP_SCHED */ | |
586 | ||
587 | static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { } | |
588 | static inline struct task_group *task_group(struct task_struct *p) | |
589 | { | |
590 | return NULL; | |
591 | } | |
592 | ||
593 | #endif /* CONFIG_CGROUP_SCHED */ | |
594 | ||
595 | static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu) | |
596 | { | |
597 | set_task_rq(p, cpu); | |
598 | #ifdef CONFIG_SMP | |
599 | /* | |
600 | * After ->cpu is set up to a new value, task_rq_lock(p, ...) can be | |
601 | * successfuly executed on another CPU. We must ensure that updates of | |
602 | * per-task data have been completed by this moment. | |
603 | */ | |
604 | smp_wmb(); | |
605 | task_thread_info(p)->cpu = cpu; | |
606 | #endif | |
607 | } | |
608 | ||
609 | /* | |
610 | * Tunables that become constants when CONFIG_SCHED_DEBUG is off: | |
611 | */ | |
612 | #ifdef CONFIG_SCHED_DEBUG | |
f8b6d1cc | 613 | # include <linux/jump_label.h> |
029632fb PZ |
614 | # define const_debug __read_mostly |
615 | #else | |
616 | # define const_debug const | |
617 | #endif | |
618 | ||
619 | extern const_debug unsigned int sysctl_sched_features; | |
620 | ||
621 | #define SCHED_FEAT(name, enabled) \ | |
622 | __SCHED_FEAT_##name , | |
623 | ||
624 | enum { | |
391e43da | 625 | #include "features.h" |
f8b6d1cc | 626 | __SCHED_FEAT_NR, |
029632fb PZ |
627 | }; |
628 | ||
629 | #undef SCHED_FEAT | |
630 | ||
f8b6d1cc PZ |
631 | #if defined(CONFIG_SCHED_DEBUG) && defined(HAVE_JUMP_LABEL) |
632 | static __always_inline bool static_branch__true(struct jump_label_key *key) | |
633 | { | |
634 | return likely(static_branch(key)); /* Not out of line branch. */ | |
635 | } | |
636 | ||
637 | static __always_inline bool static_branch__false(struct jump_label_key *key) | |
638 | { | |
639 | return unlikely(static_branch(key)); /* Out of line branch. */ | |
640 | } | |
641 | ||
642 | #define SCHED_FEAT(name, enabled) \ | |
643 | static __always_inline bool static_branch_##name(struct jump_label_key *key) \ | |
644 | { \ | |
645 | return static_branch__##enabled(key); \ | |
646 | } | |
647 | ||
648 | #include "features.h" | |
649 | ||
650 | #undef SCHED_FEAT | |
651 | ||
652 | extern struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR]; | |
653 | #define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x])) | |
654 | #else /* !(SCHED_DEBUG && HAVE_JUMP_LABEL) */ | |
029632fb | 655 | #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) |
f8b6d1cc | 656 | #endif /* SCHED_DEBUG && HAVE_JUMP_LABEL */ |
029632fb PZ |
657 | |
658 | static inline u64 global_rt_period(void) | |
659 | { | |
660 | return (u64)sysctl_sched_rt_period * NSEC_PER_USEC; | |
661 | } | |
662 | ||
663 | static inline u64 global_rt_runtime(void) | |
664 | { | |
665 | if (sysctl_sched_rt_runtime < 0) | |
666 | return RUNTIME_INF; | |
667 | ||
668 | return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC; | |
669 | } | |
670 | ||
671 | ||
672 | ||
673 | static inline int task_current(struct rq *rq, struct task_struct *p) | |
674 | { | |
675 | return rq->curr == p; | |
676 | } | |
677 | ||
678 | static inline int task_running(struct rq *rq, struct task_struct *p) | |
679 | { | |
680 | #ifdef CONFIG_SMP | |
681 | return p->on_cpu; | |
682 | #else | |
683 | return task_current(rq, p); | |
684 | #endif | |
685 | } | |
686 | ||
687 | ||
688 | #ifndef prepare_arch_switch | |
689 | # define prepare_arch_switch(next) do { } while (0) | |
690 | #endif | |
691 | #ifndef finish_arch_switch | |
692 | # define finish_arch_switch(prev) do { } while (0) | |
693 | #endif | |
694 | ||
695 | #ifndef __ARCH_WANT_UNLOCKED_CTXSW | |
696 | static inline void prepare_lock_switch(struct rq *rq, struct task_struct *next) | |
697 | { | |
698 | #ifdef CONFIG_SMP | |
699 | /* | |
700 | * We can optimise this out completely for !SMP, because the | |
701 | * SMP rebalancing from interrupt is the only thing that cares | |
702 | * here. | |
703 | */ | |
704 | next->on_cpu = 1; | |
705 | #endif | |
706 | } | |
707 | ||
708 | static inline void finish_lock_switch(struct rq *rq, struct task_struct *prev) | |
709 | { | |
710 | #ifdef CONFIG_SMP | |
711 | /* | |
712 | * After ->on_cpu is cleared, the task can be moved to a different CPU. | |
713 | * We must ensure this doesn't happen until the switch is completely | |
714 | * finished. | |
715 | */ | |
716 | smp_wmb(); | |
717 | prev->on_cpu = 0; | |
718 | #endif | |
719 | #ifdef CONFIG_DEBUG_SPINLOCK | |
720 | /* this is a valid case when another task releases the spinlock */ | |
721 | rq->lock.owner = current; | |
722 | #endif | |
723 | /* | |
724 | * If we are tracking spinlock dependencies then we have to | |
725 | * fix up the runqueue lock - which gets 'carried over' from | |
726 | * prev into current: | |
727 | */ | |
728 | spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_); | |
729 | ||
730 | raw_spin_unlock_irq(&rq->lock); | |
731 | } | |
732 | ||
733 | #else /* __ARCH_WANT_UNLOCKED_CTXSW */ | |
734 | static inline void prepare_lock_switch(struct rq *rq, struct task_struct *next) | |
735 | { | |
736 | #ifdef CONFIG_SMP | |
737 | /* | |
738 | * We can optimise this out completely for !SMP, because the | |
739 | * SMP rebalancing from interrupt is the only thing that cares | |
740 | * here. | |
741 | */ | |
742 | next->on_cpu = 1; | |
743 | #endif | |
744 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | |
745 | raw_spin_unlock_irq(&rq->lock); | |
746 | #else | |
747 | raw_spin_unlock(&rq->lock); | |
748 | #endif | |
749 | } | |
750 | ||
751 | static inline void finish_lock_switch(struct rq *rq, struct task_struct *prev) | |
752 | { | |
753 | #ifdef CONFIG_SMP | |
754 | /* | |
755 | * After ->on_cpu is cleared, the task can be moved to a different CPU. | |
756 | * We must ensure this doesn't happen until the switch is completely | |
757 | * finished. | |
758 | */ | |
759 | smp_wmb(); | |
760 | prev->on_cpu = 0; | |
761 | #endif | |
762 | #ifndef __ARCH_WANT_INTERRUPTS_ON_CTXSW | |
763 | local_irq_enable(); | |
764 | #endif | |
765 | } | |
766 | #endif /* __ARCH_WANT_UNLOCKED_CTXSW */ | |
767 | ||
768 | ||
769 | static inline void update_load_add(struct load_weight *lw, unsigned long inc) | |
770 | { | |
771 | lw->weight += inc; | |
772 | lw->inv_weight = 0; | |
773 | } | |
774 | ||
775 | static inline void update_load_sub(struct load_weight *lw, unsigned long dec) | |
776 | { | |
777 | lw->weight -= dec; | |
778 | lw->inv_weight = 0; | |
779 | } | |
780 | ||
781 | static inline void update_load_set(struct load_weight *lw, unsigned long w) | |
782 | { | |
783 | lw->weight = w; | |
784 | lw->inv_weight = 0; | |
785 | } | |
786 | ||
787 | /* | |
788 | * To aid in avoiding the subversion of "niceness" due to uneven distribution | |
789 | * of tasks with abnormal "nice" values across CPUs the contribution that | |
790 | * each task makes to its run queue's load is weighted according to its | |
791 | * scheduling class and "nice" value. For SCHED_NORMAL tasks this is just a | |
792 | * scaled version of the new time slice allocation that they receive on time | |
793 | * slice expiry etc. | |
794 | */ | |
795 | ||
796 | #define WEIGHT_IDLEPRIO 3 | |
797 | #define WMULT_IDLEPRIO 1431655765 | |
798 | ||
799 | /* | |
800 | * Nice levels are multiplicative, with a gentle 10% change for every | |
801 | * nice level changed. I.e. when a CPU-bound task goes from nice 0 to | |
802 | * nice 1, it will get ~10% less CPU time than another CPU-bound task | |
803 | * that remained on nice 0. | |
804 | * | |
805 | * The "10% effect" is relative and cumulative: from _any_ nice level, | |
806 | * if you go up 1 level, it's -10% CPU usage, if you go down 1 level | |
807 | * it's +10% CPU usage. (to achieve that we use a multiplier of 1.25. | |
808 | * If a task goes up by ~10% and another task goes down by ~10% then | |
809 | * the relative distance between them is ~25%.) | |
810 | */ | |
811 | static const int prio_to_weight[40] = { | |
812 | /* -20 */ 88761, 71755, 56483, 46273, 36291, | |
813 | /* -15 */ 29154, 23254, 18705, 14949, 11916, | |
814 | /* -10 */ 9548, 7620, 6100, 4904, 3906, | |
815 | /* -5 */ 3121, 2501, 1991, 1586, 1277, | |
816 | /* 0 */ 1024, 820, 655, 526, 423, | |
817 | /* 5 */ 335, 272, 215, 172, 137, | |
818 | /* 10 */ 110, 87, 70, 56, 45, | |
819 | /* 15 */ 36, 29, 23, 18, 15, | |
820 | }; | |
821 | ||
822 | /* | |
823 | * Inverse (2^32/x) values of the prio_to_weight[] array, precalculated. | |
824 | * | |
825 | * In cases where the weight does not change often, we can use the | |
826 | * precalculated inverse to speed up arithmetics by turning divisions | |
827 | * into multiplications: | |
828 | */ | |
829 | static const u32 prio_to_wmult[40] = { | |
830 | /* -20 */ 48388, 59856, 76040, 92818, 118348, | |
831 | /* -15 */ 147320, 184698, 229616, 287308, 360437, | |
832 | /* -10 */ 449829, 563644, 704093, 875809, 1099582, | |
833 | /* -5 */ 1376151, 1717300, 2157191, 2708050, 3363326, | |
834 | /* 0 */ 4194304, 5237765, 6557202, 8165337, 10153587, | |
835 | /* 5 */ 12820798, 15790321, 19976592, 24970740, 31350126, | |
836 | /* 10 */ 39045157, 49367440, 61356676, 76695844, 95443717, | |
837 | /* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153, | |
838 | }; | |
839 | ||
840 | /* Time spent by the tasks of the cpu accounting group executing in ... */ | |
841 | enum cpuacct_stat_index { | |
842 | CPUACCT_STAT_USER, /* ... user mode */ | |
843 | CPUACCT_STAT_SYSTEM, /* ... kernel mode */ | |
844 | ||
845 | CPUACCT_STAT_NSTATS, | |
846 | }; | |
847 | ||
848 | ||
849 | #define sched_class_highest (&stop_sched_class) | |
850 | #define for_each_class(class) \ | |
851 | for (class = sched_class_highest; class; class = class->next) | |
852 | ||
853 | extern const struct sched_class stop_sched_class; | |
854 | extern const struct sched_class rt_sched_class; | |
855 | extern const struct sched_class fair_sched_class; | |
856 | extern const struct sched_class idle_sched_class; | |
857 | ||
858 | ||
859 | #ifdef CONFIG_SMP | |
860 | ||
861 | extern void trigger_load_balance(struct rq *rq, int cpu); | |
862 | extern void idle_balance(int this_cpu, struct rq *this_rq); | |
863 | ||
864 | #else /* CONFIG_SMP */ | |
865 | ||
866 | static inline void idle_balance(int cpu, struct rq *rq) | |
867 | { | |
868 | } | |
869 | ||
870 | #endif | |
871 | ||
872 | extern void sysrq_sched_debug_show(void); | |
873 | extern void sched_init_granularity(void); | |
874 | extern void update_max_interval(void); | |
875 | extern void update_group_power(struct sched_domain *sd, int cpu); | |
876 | extern int update_runtime(struct notifier_block *nfb, unsigned long action, void *hcpu); | |
877 | extern void init_sched_rt_class(void); | |
878 | extern void init_sched_fair_class(void); | |
879 | ||
880 | extern void resched_task(struct task_struct *p); | |
881 | extern void resched_cpu(int cpu); | |
882 | ||
883 | extern struct rt_bandwidth def_rt_bandwidth; | |
884 | extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime); | |
885 | ||
886 | extern void update_cpu_load(struct rq *this_rq); | |
887 | ||
888 | #ifdef CONFIG_CGROUP_CPUACCT | |
54c707e9 GC |
889 | #include <linux/cgroup.h> |
890 | /* track cpu usage of a group of tasks and its child groups */ | |
891 | struct cpuacct { | |
892 | struct cgroup_subsys_state css; | |
893 | /* cpuusage holds pointer to a u64-type object on every cpu */ | |
894 | u64 __percpu *cpuusage; | |
895 | struct kernel_cpustat __percpu *cpustat; | |
896 | }; | |
897 | ||
898 | /* return cpu accounting group corresponding to this container */ | |
899 | static inline struct cpuacct *cgroup_ca(struct cgroup *cgrp) | |
900 | { | |
901 | return container_of(cgroup_subsys_state(cgrp, cpuacct_subsys_id), | |
902 | struct cpuacct, css); | |
903 | } | |
904 | ||
905 | /* return cpu accounting group to which this task belongs */ | |
906 | static inline struct cpuacct *task_ca(struct task_struct *tsk) | |
907 | { | |
908 | return container_of(task_subsys_state(tsk, cpuacct_subsys_id), | |
909 | struct cpuacct, css); | |
910 | } | |
911 | ||
912 | static inline struct cpuacct *parent_ca(struct cpuacct *ca) | |
913 | { | |
914 | if (!ca || !ca->css.cgroup->parent) | |
915 | return NULL; | |
916 | return cgroup_ca(ca->css.cgroup->parent); | |
917 | } | |
918 | ||
029632fb | 919 | extern void cpuacct_charge(struct task_struct *tsk, u64 cputime); |
029632fb PZ |
920 | #else |
921 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {} | |
029632fb PZ |
922 | #endif |
923 | ||
924 | static inline void inc_nr_running(struct rq *rq) | |
925 | { | |
926 | rq->nr_running++; | |
927 | } | |
928 | ||
929 | static inline void dec_nr_running(struct rq *rq) | |
930 | { | |
931 | rq->nr_running--; | |
932 | } | |
933 | ||
934 | extern void update_rq_clock(struct rq *rq); | |
935 | ||
936 | extern void activate_task(struct rq *rq, struct task_struct *p, int flags); | |
937 | extern void deactivate_task(struct rq *rq, struct task_struct *p, int flags); | |
938 | ||
939 | extern void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags); | |
940 | ||
941 | extern const_debug unsigned int sysctl_sched_time_avg; | |
942 | extern const_debug unsigned int sysctl_sched_nr_migrate; | |
943 | extern const_debug unsigned int sysctl_sched_migration_cost; | |
944 | ||
945 | static inline u64 sched_avg_period(void) | |
946 | { | |
947 | return (u64)sysctl_sched_time_avg * NSEC_PER_MSEC / 2; | |
948 | } | |
949 | ||
950 | void calc_load_account_idle(struct rq *this_rq); | |
951 | ||
952 | #ifdef CONFIG_SCHED_HRTICK | |
953 | ||
954 | /* | |
955 | * Use hrtick when: | |
956 | * - enabled by features | |
957 | * - hrtimer is actually high res | |
958 | */ | |
959 | static inline int hrtick_enabled(struct rq *rq) | |
960 | { | |
961 | if (!sched_feat(HRTICK)) | |
962 | return 0; | |
963 | if (!cpu_active(cpu_of(rq))) | |
964 | return 0; | |
965 | return hrtimer_is_hres_active(&rq->hrtick_timer); | |
966 | } | |
967 | ||
968 | void hrtick_start(struct rq *rq, u64 delay); | |
969 | ||
b39e66ea MG |
970 | #else |
971 | ||
972 | static inline int hrtick_enabled(struct rq *rq) | |
973 | { | |
974 | return 0; | |
975 | } | |
976 | ||
029632fb PZ |
977 | #endif /* CONFIG_SCHED_HRTICK */ |
978 | ||
979 | #ifdef CONFIG_SMP | |
980 | extern void sched_avg_update(struct rq *rq); | |
981 | static inline void sched_rt_avg_update(struct rq *rq, u64 rt_delta) | |
982 | { | |
983 | rq->rt_avg += rt_delta; | |
984 | sched_avg_update(rq); | |
985 | } | |
986 | #else | |
987 | static inline void sched_rt_avg_update(struct rq *rq, u64 rt_delta) { } | |
988 | static inline void sched_avg_update(struct rq *rq) { } | |
989 | #endif | |
990 | ||
991 | extern void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period); | |
992 | ||
993 | #ifdef CONFIG_SMP | |
994 | #ifdef CONFIG_PREEMPT | |
995 | ||
996 | static inline void double_rq_lock(struct rq *rq1, struct rq *rq2); | |
997 | ||
998 | /* | |
999 | * fair double_lock_balance: Safely acquires both rq->locks in a fair | |
1000 | * way at the expense of forcing extra atomic operations in all | |
1001 | * invocations. This assures that the double_lock is acquired using the | |
1002 | * same underlying policy as the spinlock_t on this architecture, which | |
1003 | * reduces latency compared to the unfair variant below. However, it | |
1004 | * also adds more overhead and therefore may reduce throughput. | |
1005 | */ | |
1006 | static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest) | |
1007 | __releases(this_rq->lock) | |
1008 | __acquires(busiest->lock) | |
1009 | __acquires(this_rq->lock) | |
1010 | { | |
1011 | raw_spin_unlock(&this_rq->lock); | |
1012 | double_rq_lock(this_rq, busiest); | |
1013 | ||
1014 | return 1; | |
1015 | } | |
1016 | ||
1017 | #else | |
1018 | /* | |
1019 | * Unfair double_lock_balance: Optimizes throughput at the expense of | |
1020 | * latency by eliminating extra atomic operations when the locks are | |
1021 | * already in proper order on entry. This favors lower cpu-ids and will | |
1022 | * grant the double lock to lower cpus over higher ids under contention, | |
1023 | * regardless of entry order into the function. | |
1024 | */ | |
1025 | static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest) | |
1026 | __releases(this_rq->lock) | |
1027 | __acquires(busiest->lock) | |
1028 | __acquires(this_rq->lock) | |
1029 | { | |
1030 | int ret = 0; | |
1031 | ||
1032 | if (unlikely(!raw_spin_trylock(&busiest->lock))) { | |
1033 | if (busiest < this_rq) { | |
1034 | raw_spin_unlock(&this_rq->lock); | |
1035 | raw_spin_lock(&busiest->lock); | |
1036 | raw_spin_lock_nested(&this_rq->lock, | |
1037 | SINGLE_DEPTH_NESTING); | |
1038 | ret = 1; | |
1039 | } else | |
1040 | raw_spin_lock_nested(&busiest->lock, | |
1041 | SINGLE_DEPTH_NESTING); | |
1042 | } | |
1043 | return ret; | |
1044 | } | |
1045 | ||
1046 | #endif /* CONFIG_PREEMPT */ | |
1047 | ||
1048 | /* | |
1049 | * double_lock_balance - lock the busiest runqueue, this_rq is locked already. | |
1050 | */ | |
1051 | static inline int double_lock_balance(struct rq *this_rq, struct rq *busiest) | |
1052 | { | |
1053 | if (unlikely(!irqs_disabled())) { | |
1054 | /* printk() doesn't work good under rq->lock */ | |
1055 | raw_spin_unlock(&this_rq->lock); | |
1056 | BUG_ON(1); | |
1057 | } | |
1058 | ||
1059 | return _double_lock_balance(this_rq, busiest); | |
1060 | } | |
1061 | ||
1062 | static inline void double_unlock_balance(struct rq *this_rq, struct rq *busiest) | |
1063 | __releases(busiest->lock) | |
1064 | { | |
1065 | raw_spin_unlock(&busiest->lock); | |
1066 | lock_set_subclass(&this_rq->lock.dep_map, 0, _RET_IP_); | |
1067 | } | |
1068 | ||
1069 | /* | |
1070 | * double_rq_lock - safely lock two runqueues | |
1071 | * | |
1072 | * Note this does not disable interrupts like task_rq_lock, | |
1073 | * you need to do so manually before calling. | |
1074 | */ | |
1075 | static inline void double_rq_lock(struct rq *rq1, struct rq *rq2) | |
1076 | __acquires(rq1->lock) | |
1077 | __acquires(rq2->lock) | |
1078 | { | |
1079 | BUG_ON(!irqs_disabled()); | |
1080 | if (rq1 == rq2) { | |
1081 | raw_spin_lock(&rq1->lock); | |
1082 | __acquire(rq2->lock); /* Fake it out ;) */ | |
1083 | } else { | |
1084 | if (rq1 < rq2) { | |
1085 | raw_spin_lock(&rq1->lock); | |
1086 | raw_spin_lock_nested(&rq2->lock, SINGLE_DEPTH_NESTING); | |
1087 | } else { | |
1088 | raw_spin_lock(&rq2->lock); | |
1089 | raw_spin_lock_nested(&rq1->lock, SINGLE_DEPTH_NESTING); | |
1090 | } | |
1091 | } | |
1092 | } | |
1093 | ||
1094 | /* | |
1095 | * double_rq_unlock - safely unlock two runqueues | |
1096 | * | |
1097 | * Note this does not restore interrupts like task_rq_unlock, | |
1098 | * you need to do so manually after calling. | |
1099 | */ | |
1100 | static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2) | |
1101 | __releases(rq1->lock) | |
1102 | __releases(rq2->lock) | |
1103 | { | |
1104 | raw_spin_unlock(&rq1->lock); | |
1105 | if (rq1 != rq2) | |
1106 | raw_spin_unlock(&rq2->lock); | |
1107 | else | |
1108 | __release(rq2->lock); | |
1109 | } | |
1110 | ||
1111 | #else /* CONFIG_SMP */ | |
1112 | ||
1113 | /* | |
1114 | * double_rq_lock - safely lock two runqueues | |
1115 | * | |
1116 | * Note this does not disable interrupts like task_rq_lock, | |
1117 | * you need to do so manually before calling. | |
1118 | */ | |
1119 | static inline void double_rq_lock(struct rq *rq1, struct rq *rq2) | |
1120 | __acquires(rq1->lock) | |
1121 | __acquires(rq2->lock) | |
1122 | { | |
1123 | BUG_ON(!irqs_disabled()); | |
1124 | BUG_ON(rq1 != rq2); | |
1125 | raw_spin_lock(&rq1->lock); | |
1126 | __acquire(rq2->lock); /* Fake it out ;) */ | |
1127 | } | |
1128 | ||
1129 | /* | |
1130 | * double_rq_unlock - safely unlock two runqueues | |
1131 | * | |
1132 | * Note this does not restore interrupts like task_rq_unlock, | |
1133 | * you need to do so manually after calling. | |
1134 | */ | |
1135 | static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2) | |
1136 | __releases(rq1->lock) | |
1137 | __releases(rq2->lock) | |
1138 | { | |
1139 | BUG_ON(rq1 != rq2); | |
1140 | raw_spin_unlock(&rq1->lock); | |
1141 | __release(rq2->lock); | |
1142 | } | |
1143 | ||
1144 | #endif | |
1145 | ||
1146 | extern struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq); | |
1147 | extern struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq); | |
1148 | extern void print_cfs_stats(struct seq_file *m, int cpu); | |
1149 | extern void print_rt_stats(struct seq_file *m, int cpu); | |
1150 | ||
1151 | extern void init_cfs_rq(struct cfs_rq *cfs_rq); | |
1152 | extern void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq); | |
1153 | extern void unthrottle_offline_cfs_rqs(struct rq *rq); | |
1154 | ||
1155 | extern void account_cfs_bandwidth_used(int enabled, int was_enabled); | |
1c792db7 SS |
1156 | |
1157 | #ifdef CONFIG_NO_HZ | |
1158 | enum rq_nohz_flag_bits { | |
1159 | NOHZ_TICK_STOPPED, | |
1160 | NOHZ_BALANCE_KICK, | |
69e1e811 | 1161 | NOHZ_IDLE, |
1c792db7 SS |
1162 | }; |
1163 | ||
1164 | #define nohz_flags(cpu) (&cpu_rq(cpu)->nohz_flags) | |
1165 | #endif |