aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c255
1 files changed, 158 insertions, 97 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 5255c9d2e053..afc6d7e71557 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -71,7 +71,9 @@
71#include <linux/ftrace.h> 71#include <linux/ftrace.h>
72#include <linux/slab.h> 72#include <linux/slab.h>
73#include <linux/init_task.h> 73#include <linux/init_task.h>
74#include <linux/binfmts.h>
74 75
76#include <asm/switch_to.h>
75#include <asm/tlb.h> 77#include <asm/tlb.h>
76#include <asm/irq_regs.h> 78#include <asm/irq_regs.h>
77#include <asm/mutex.h> 79#include <asm/mutex.h>
@@ -162,13 +164,13 @@ static int sched_feat_show(struct seq_file *m, void *v)
162 164
163#ifdef HAVE_JUMP_LABEL 165#ifdef HAVE_JUMP_LABEL
164 166
165#define jump_label_key__true jump_label_key_enabled 167#define jump_label_key__true STATIC_KEY_INIT_TRUE
166#define jump_label_key__false jump_label_key_disabled 168#define jump_label_key__false STATIC_KEY_INIT_FALSE
167 169
168#define SCHED_FEAT(name, enabled) \ 170#define SCHED_FEAT(name, enabled) \
169 jump_label_key__##enabled , 171 jump_label_key__##enabled ,
170 172
171struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR] = { 173struct static_key sched_feat_keys[__SCHED_FEAT_NR] = {
172#include "features.h" 174#include "features.h"
173}; 175};
174 176
@@ -176,14 +178,14 @@ struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR] = {
176 178
177static void sched_feat_disable(int i) 179static void sched_feat_disable(int i)
178{ 180{
179 if (jump_label_enabled(&sched_feat_keys[i])) 181 if (static_key_enabled(&sched_feat_keys[i]))
180 jump_label_dec(&sched_feat_keys[i]); 182 static_key_slow_dec(&sched_feat_keys[i]);
181} 183}
182 184
183static void sched_feat_enable(int i) 185static void sched_feat_enable(int i)
184{ 186{
185 if (!jump_label_enabled(&sched_feat_keys[i])) 187 if (!static_key_enabled(&sched_feat_keys[i]))
186 jump_label_inc(&sched_feat_keys[i]); 188 static_key_slow_inc(&sched_feat_keys[i]);
187} 189}
188#else 190#else
189static void sched_feat_disable(int i) { }; 191static void sched_feat_disable(int i) { };
@@ -894,7 +896,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
894 delta -= irq_delta; 896 delta -= irq_delta;
895#endif 897#endif
896#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING 898#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
897 if (static_branch((&paravirt_steal_rq_enabled))) { 899 if (static_key_false((&paravirt_steal_rq_enabled))) {
898 u64 st; 900 u64 st;
899 901
900 steal = paravirt_steal_clock(cpu_of(rq)); 902 steal = paravirt_steal_clock(cpu_of(rq));
@@ -1263,29 +1265,59 @@ EXPORT_SYMBOL_GPL(kick_process);
1263 */ 1265 */
1264static int select_fallback_rq(int cpu, struct task_struct *p) 1266static int select_fallback_rq(int cpu, struct task_struct *p)
1265{ 1267{
1266 int dest_cpu;
1267 const struct cpumask *nodemask = cpumask_of_node(cpu_to_node(cpu)); 1268 const struct cpumask *nodemask = cpumask_of_node(cpu_to_node(cpu));
1269 enum { cpuset, possible, fail } state = cpuset;
1270 int dest_cpu;
1268 1271
1269 /* Look for allowed, online CPU in same node. */ 1272 /* Look for allowed, online CPU in same node. */
1270 for_each_cpu_and(dest_cpu, nodemask, cpu_active_mask) 1273 for_each_cpu(dest_cpu, nodemask) {
1274 if (!cpu_online(dest_cpu))
1275 continue;
1276 if (!cpu_active(dest_cpu))
1277 continue;
1271 if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) 1278 if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p)))
1272 return dest_cpu; 1279 return dest_cpu;
1280 }
1273 1281
1274 /* Any allowed, online CPU? */ 1282 for (;;) {
1275 dest_cpu = cpumask_any_and(tsk_cpus_allowed(p), cpu_active_mask); 1283 /* Any allowed, online CPU? */
1276 if (dest_cpu < nr_cpu_ids) 1284 for_each_cpu(dest_cpu, tsk_cpus_allowed(p)) {
1277 return dest_cpu; 1285 if (!cpu_online(dest_cpu))
1286 continue;
1287 if (!cpu_active(dest_cpu))
1288 continue;
1289 goto out;
1290 }
1278 1291
1279 /* No more Mr. Nice Guy. */ 1292 switch (state) {
1280 dest_cpu = cpuset_cpus_allowed_fallback(p); 1293 case cpuset:
1281 /* 1294 /* No more Mr. Nice Guy. */
1282 * Don't tell them about moving exiting tasks or 1295 cpuset_cpus_allowed_fallback(p);
1283 * kernel threads (both mm NULL), since they never 1296 state = possible;
1284 * leave kernel. 1297 break;
1285 */ 1298
1286 if (p->mm && printk_ratelimit()) { 1299 case possible:
1287 printk(KERN_INFO "process %d (%s) no longer affine to cpu%d\n", 1300 do_set_cpus_allowed(p, cpu_possible_mask);
1288 task_pid_nr(p), p->comm, cpu); 1301 state = fail;
1302 break;
1303
1304 case fail:
1305 BUG();
1306 break;
1307 }
1308 }
1309
1310out:
1311 if (state != cpuset) {
1312 /*
1313 * Don't tell them about moving exiting tasks or
1314 * kernel threads (both mm NULL), since they never
1315 * leave kernel.
1316 */
1317 if (p->mm && printk_ratelimit()) {
1318 printk_sched("process %d (%s) no longer affine to cpu%d\n",
1319 task_pid_nr(p), p->comm, cpu);
1320 }
1289 } 1321 }
1290 1322
1291 return dest_cpu; 1323 return dest_cpu;
@@ -1507,7 +1539,7 @@ static int ttwu_activate_remote(struct task_struct *p, int wake_flags)
1507} 1539}
1508#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ 1540#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
1509 1541
1510static inline int ttwu_share_cache(int this_cpu, int that_cpu) 1542bool cpus_share_cache(int this_cpu, int that_cpu)
1511{ 1543{
1512 return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu); 1544 return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
1513} 1545}
@@ -1518,7 +1550,7 @@ static void ttwu_queue(struct task_struct *p, int cpu)
1518 struct rq *rq = cpu_rq(cpu); 1550 struct rq *rq = cpu_rq(cpu);
1519 1551
1520#if defined(CONFIG_SMP) 1552#if defined(CONFIG_SMP)
1521 if (sched_feat(TTWU_QUEUE) && !ttwu_share_cache(smp_processor_id(), cpu)) { 1553 if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) {
1522 sched_clock_cpu(cpu); /* sync clocks x-cpu */ 1554 sched_clock_cpu(cpu); /* sync clocks x-cpu */
1523 ttwu_queue_remote(p, cpu); 1555 ttwu_queue_remote(p, cpu);
1524 return; 1556 return;
@@ -1932,7 +1964,7 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev)
1932 local_irq_enable(); 1964 local_irq_enable();
1933#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ 1965#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
1934 finish_lock_switch(rq, prev); 1966 finish_lock_switch(rq, prev);
1935 trace_sched_stat_sleeptime(current, rq->clock); 1967 finish_arch_post_lock_switch();
1936 1968
1937 fire_sched_in_preempt_notifiers(current); 1969 fire_sched_in_preempt_notifiers(current);
1938 if (mm) 1970 if (mm)
@@ -2267,13 +2299,10 @@ calc_load_n(unsigned long load, unsigned long exp,
2267 * Once we've updated the global active value, we need to apply the exponential 2299 * Once we've updated the global active value, we need to apply the exponential
2268 * weights adjusted to the number of cycles missed. 2300 * weights adjusted to the number of cycles missed.
2269 */ 2301 */
2270static void calc_global_nohz(unsigned long ticks) 2302static void calc_global_nohz(void)
2271{ 2303{
2272 long delta, active, n; 2304 long delta, active, n;
2273 2305
2274 if (time_before(jiffies, calc_load_update))
2275 return;
2276
2277 /* 2306 /*
2278 * If we crossed a calc_load_update boundary, make sure to fold 2307 * If we crossed a calc_load_update boundary, make sure to fold
2279 * any pending idle changes, the respective CPUs might have 2308 * any pending idle changes, the respective CPUs might have
@@ -2285,31 +2314,25 @@ static void calc_global_nohz(unsigned long ticks)
2285 atomic_long_add(delta, &calc_load_tasks); 2314 atomic_long_add(delta, &calc_load_tasks);
2286 2315
2287 /* 2316 /*
2288 * If we were idle for multiple load cycles, apply them. 2317 * It could be the one fold was all it took, we done!
2289 */ 2318 */
2290 if (ticks >= LOAD_FREQ) { 2319 if (time_before(jiffies, calc_load_update + 10))
2291 n = ticks / LOAD_FREQ; 2320 return;
2292 2321
2293 active = atomic_long_read(&calc_load_tasks); 2322 /*
2294 active = active > 0 ? active * FIXED_1 : 0; 2323 * Catch-up, fold however many we are behind still
2324 */
2325 delta = jiffies - calc_load_update - 10;
2326 n = 1 + (delta / LOAD_FREQ);
2295 2327
2296 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n); 2328 active = atomic_long_read(&calc_load_tasks);
2297 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n); 2329 active = active > 0 ? active * FIXED_1 : 0;
2298 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
2299 2330
2300 calc_load_update += n * LOAD_FREQ; 2331 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
2301 } 2332 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
2333 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
2302 2334
2303 /* 2335 calc_load_update += n * LOAD_FREQ;
2304 * Its possible the remainder of the above division also crosses
2305 * a LOAD_FREQ period, the regular check in calc_global_load()
2306 * which comes after this will take care of that.
2307 *
2308 * Consider us being 11 ticks before a cycle completion, and us
2309 * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will
2310 * age us 4 cycles, and the test in calc_global_load() will
2311 * pick up the final one.
2312 */
2313} 2336}
2314#else 2337#else
2315void calc_load_account_idle(struct rq *this_rq) 2338void calc_load_account_idle(struct rq *this_rq)
@@ -2321,7 +2344,7 @@ static inline long calc_load_fold_idle(void)
2321 return 0; 2344 return 0;
2322} 2345}
2323 2346
2324static void calc_global_nohz(unsigned long ticks) 2347static void calc_global_nohz(void)
2325{ 2348{
2326} 2349}
2327#endif 2350#endif
@@ -2349,8 +2372,6 @@ void calc_global_load(unsigned long ticks)
2349{ 2372{
2350 long active; 2373 long active;
2351 2374
2352 calc_global_nohz(ticks);
2353
2354 if (time_before(jiffies, calc_load_update + 10)) 2375 if (time_before(jiffies, calc_load_update + 10))
2355 return; 2376 return;
2356 2377
@@ -2362,6 +2383,16 @@ void calc_global_load(unsigned long ticks)
2362 avenrun[2] = calc_load(avenrun[2], EXP_15, active); 2383 avenrun[2] = calc_load(avenrun[2], EXP_15, active);
2363 2384
2364 calc_load_update += LOAD_FREQ; 2385 calc_load_update += LOAD_FREQ;
2386
2387 /*
2388 * Account one period with whatever state we found before
2389 * folding in the nohz state and ageing the entire idle period.
2390 *
2391 * This avoids loosing a sample when we go idle between
2392 * calc_load_account_active() (10 ticks ago) and now and thus
2393 * under-accounting.
2394 */
2395 calc_global_nohz();
2365} 2396}
2366 2397
2367/* 2398/*
@@ -2756,7 +2787,7 @@ void account_idle_time(cputime_t cputime)
2756static __always_inline bool steal_account_process_tick(void) 2787static __always_inline bool steal_account_process_tick(void)
2757{ 2788{
2758#ifdef CONFIG_PARAVIRT 2789#ifdef CONFIG_PARAVIRT
2759 if (static_branch(&paravirt_steal_enabled)) { 2790 if (static_key_false(&paravirt_steal_enabled)) {
2760 u64 steal, st = 0; 2791 u64 steal, st = 0;
2761 2792
2762 steal = paravirt_steal_clock(smp_processor_id()); 2793 steal = paravirt_steal_clock(smp_processor_id());
@@ -3071,8 +3102,6 @@ EXPORT_SYMBOL(sub_preempt_count);
3071 */ 3102 */
3072static noinline void __schedule_bug(struct task_struct *prev) 3103static noinline void __schedule_bug(struct task_struct *prev)
3073{ 3104{
3074 struct pt_regs *regs = get_irq_regs();
3075
3076 if (oops_in_progress) 3105 if (oops_in_progress)
3077 return; 3106 return;
3078 3107
@@ -3083,11 +3112,7 @@ static noinline void __schedule_bug(struct task_struct *prev)
3083 print_modules(); 3112 print_modules();
3084 if (irqs_disabled()) 3113 if (irqs_disabled())
3085 print_irqtrace_events(prev); 3114 print_irqtrace_events(prev);
3086 3115 dump_stack();
3087 if (regs)
3088 show_regs(regs);
3089 else
3090 dump_stack();
3091} 3116}
3092 3117
3093/* 3118/*
@@ -3221,14 +3246,14 @@ need_resched:
3221 3246
3222 post_schedule(rq); 3247 post_schedule(rq);
3223 3248
3224 preempt_enable_no_resched(); 3249 sched_preempt_enable_no_resched();
3225 if (need_resched()) 3250 if (need_resched())
3226 goto need_resched; 3251 goto need_resched;
3227} 3252}
3228 3253
3229static inline void sched_submit_work(struct task_struct *tsk) 3254static inline void sched_submit_work(struct task_struct *tsk)
3230{ 3255{
3231 if (!tsk->state) 3256 if (!tsk->state || tsk_is_pi_blocked(tsk))
3232 return; 3257 return;
3233 /* 3258 /*
3234 * If we are going to sleep and we have plugged IO queued, 3259 * If we are going to sleep and we have plugged IO queued,
@@ -3247,6 +3272,18 @@ asmlinkage void __sched schedule(void)
3247} 3272}
3248EXPORT_SYMBOL(schedule); 3273EXPORT_SYMBOL(schedule);
3249 3274
3275/**
3276 * schedule_preempt_disabled - called with preemption disabled
3277 *
3278 * Returns with preemption disabled. Note: preempt_count must be 1
3279 */
3280void __sched schedule_preempt_disabled(void)
3281{
3282 sched_preempt_enable_no_resched();
3283 schedule();
3284 preempt_disable();
3285}
3286
3250#ifdef CONFIG_MUTEX_SPIN_ON_OWNER 3287#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
3251 3288
3252static inline bool owner_running(struct mutex *lock, struct task_struct *owner) 3289static inline bool owner_running(struct mutex *lock, struct task_struct *owner)
@@ -3407,9 +3444,9 @@ EXPORT_SYMBOL(__wake_up);
3407/* 3444/*
3408 * Same as __wake_up but called with the spinlock in wait_queue_head_t held. 3445 * Same as __wake_up but called with the spinlock in wait_queue_head_t held.
3409 */ 3446 */
3410void __wake_up_locked(wait_queue_head_t *q, unsigned int mode) 3447void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr)
3411{ 3448{
3412 __wake_up_common(q, mode, 1, 0, NULL); 3449 __wake_up_common(q, mode, nr, 0, NULL);
3413} 3450}
3414EXPORT_SYMBOL_GPL(__wake_up_locked); 3451EXPORT_SYMBOL_GPL(__wake_up_locked);
3415 3452
@@ -3768,6 +3805,24 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
3768 3805
3769 rq = __task_rq_lock(p); 3806 rq = __task_rq_lock(p);
3770 3807
3808 /*
3809 * Idle task boosting is a nono in general. There is one
3810 * exception, when PREEMPT_RT and NOHZ is active:
3811 *
3812 * The idle task calls get_next_timer_interrupt() and holds
3813 * the timer wheel base->lock on the CPU and another CPU wants
3814 * to access the timer (probably to cancel it). We can safely
3815 * ignore the boosting request, as the idle CPU runs this code
3816 * with interrupts disabled and will complete the lock
3817 * protected section without being interrupted. So there is no
3818 * real need to boost.
3819 */
3820 if (unlikely(p == rq->idle)) {
3821 WARN_ON(p != rq->curr);
3822 WARN_ON(p->pi_blocked_on);
3823 goto out_unlock;
3824 }
3825
3771 trace_sched_pi_setprio(p, prio); 3826 trace_sched_pi_setprio(p, prio);
3772 oldprio = p->prio; 3827 oldprio = p->prio;
3773 prev_class = p->sched_class; 3828 prev_class = p->sched_class;
@@ -3791,11 +3846,10 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
3791 enqueue_task(rq, p, oldprio < prio ? ENQUEUE_HEAD : 0); 3846 enqueue_task(rq, p, oldprio < prio ? ENQUEUE_HEAD : 0);
3792 3847
3793 check_class_changed(rq, p, prev_class, oldprio); 3848 check_class_changed(rq, p, prev_class, oldprio);
3849out_unlock:
3794 __task_rq_unlock(rq); 3850 __task_rq_unlock(rq);
3795} 3851}
3796
3797#endif 3852#endif
3798
3799void set_user_nice(struct task_struct *p, long nice) 3853void set_user_nice(struct task_struct *p, long nice)
3800{ 3854{
3801 int old_prio, delta, on_rq; 3855 int old_prio, delta, on_rq;
@@ -4475,7 +4529,7 @@ SYSCALL_DEFINE0(sched_yield)
4475 __release(rq->lock); 4529 __release(rq->lock);
4476 spin_release(&rq->lock.dep_map, 1, _THIS_IP_); 4530 spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
4477 do_raw_spin_unlock(&rq->lock); 4531 do_raw_spin_unlock(&rq->lock);
4478 preempt_enable_no_resched(); 4532 sched_preempt_enable_no_resched();
4479 4533
4480 schedule(); 4534 schedule();
4481 4535
@@ -4549,8 +4603,24 @@ EXPORT_SYMBOL(__cond_resched_softirq);
4549/** 4603/**
4550 * yield - yield the current processor to other threads. 4604 * yield - yield the current processor to other threads.
4551 * 4605 *
4552 * This is a shortcut for kernel-space yielding - it marks the 4606 * Do not ever use this function, there's a 99% chance you're doing it wrong.
4553 * thread runnable and calls sys_sched_yield(). 4607 *
4608 * The scheduler is at all times free to pick the calling task as the most
4609 * eligible task to run, if removing the yield() call from your code breaks
4610 * it, its already broken.
4611 *
4612 * Typical broken usage is:
4613 *
4614 * while (!event)
4615 * yield();
4616 *
4617 * where one assumes that yield() will let 'the other' process run that will
4618 * make event true. If the current task is a SCHED_FIFO task that will never
4619 * happen. Never use yield() as a progress guarantee!!
4620 *
4621 * If you want to use yield() to wait for something, use wait_event().
4622 * If you want to use yield() to be 'nice' for others, use cond_resched().
4623 * If you still want to use yield(), do not!
4554 */ 4624 */
4555void __sched yield(void) 4625void __sched yield(void)
4556{ 4626{
@@ -5382,7 +5452,7 @@ static int __cpuinit sched_cpu_active(struct notifier_block *nfb,
5382 unsigned long action, void *hcpu) 5452 unsigned long action, void *hcpu)
5383{ 5453{
5384 switch (action & ~CPU_TASKS_FROZEN) { 5454 switch (action & ~CPU_TASKS_FROZEN) {
5385 case CPU_ONLINE: 5455 case CPU_STARTING:
5386 case CPU_DOWN_FAILED: 5456 case CPU_DOWN_FAILED:
5387 set_cpu_active((long)hcpu, true); 5457 set_cpu_active((long)hcpu, true);
5388 return NOTIFY_OK; 5458 return NOTIFY_OK;
@@ -5754,7 +5824,7 @@ static void destroy_sched_domains(struct sched_domain *sd, int cpu)
5754 * 5824 *
5755 * Also keep a unique ID per domain (we use the first cpu number in 5825 * Also keep a unique ID per domain (we use the first cpu number in
5756 * the cpumask of the domain), this allows us to quickly tell if 5826 * the cpumask of the domain), this allows us to quickly tell if
5757 * two cpus are in the same cache domain, see ttwu_share_cache(). 5827 * two cpus are in the same cache domain, see cpus_share_cache().
5758 */ 5828 */
5759DEFINE_PER_CPU(struct sched_domain *, sd_llc); 5829DEFINE_PER_CPU(struct sched_domain *, sd_llc);
5760DEFINE_PER_CPU(int, sd_llc_id); 5830DEFINE_PER_CPU(int, sd_llc_id);
@@ -6931,6 +7001,9 @@ void __init sched_init(void)
6931 rq->online = 0; 7001 rq->online = 0;
6932 rq->idle_stamp = 0; 7002 rq->idle_stamp = 0;
6933 rq->avg_idle = 2*sysctl_sched_migration_cost; 7003 rq->avg_idle = 2*sysctl_sched_migration_cost;
7004
7005 INIT_LIST_HEAD(&rq->cfs_tasks);
7006
6934 rq_attach_root(rq, &def_root_domain); 7007 rq_attach_root(rq, &def_root_domain);
6935#ifdef CONFIG_NO_HZ 7008#ifdef CONFIG_NO_HZ
6936 rq->nohz_flags = 0; 7009 rq->nohz_flags = 0;
@@ -7525,8 +7598,7 @@ static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
7525 struct task_group, css); 7598 struct task_group, css);
7526} 7599}
7527 7600
7528static struct cgroup_subsys_state * 7601static struct cgroup_subsys_state *cpu_cgroup_create(struct cgroup *cgrp)
7529cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp)
7530{ 7602{
7531 struct task_group *tg, *parent; 7603 struct task_group *tg, *parent;
7532 7604
@@ -7543,15 +7615,14 @@ cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp)
7543 return &tg->css; 7615 return &tg->css;
7544} 7616}
7545 7617
7546static void 7618static void cpu_cgroup_destroy(struct cgroup *cgrp)
7547cpu_cgroup_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
7548{ 7619{
7549 struct task_group *tg = cgroup_tg(cgrp); 7620 struct task_group *tg = cgroup_tg(cgrp);
7550 7621
7551 sched_destroy_group(tg); 7622 sched_destroy_group(tg);
7552} 7623}
7553 7624
7554static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 7625static int cpu_cgroup_can_attach(struct cgroup *cgrp,
7555 struct cgroup_taskset *tset) 7626 struct cgroup_taskset *tset)
7556{ 7627{
7557 struct task_struct *task; 7628 struct task_struct *task;
@@ -7569,7 +7640,7 @@ static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
7569 return 0; 7640 return 0;
7570} 7641}
7571 7642
7572static void cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 7643static void cpu_cgroup_attach(struct cgroup *cgrp,
7573 struct cgroup_taskset *tset) 7644 struct cgroup_taskset *tset)
7574{ 7645{
7575 struct task_struct *task; 7646 struct task_struct *task;
@@ -7579,8 +7650,8 @@ static void cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
7579} 7650}
7580 7651
7581static void 7652static void
7582cpu_cgroup_exit(struct cgroup_subsys *ss, struct cgroup *cgrp, 7653cpu_cgroup_exit(struct cgroup *cgrp, struct cgroup *old_cgrp,
7583 struct cgroup *old_cgrp, struct task_struct *task) 7654 struct task_struct *task)
7584{ 7655{
7585 /* 7656 /*
7586 * cgroup_exit() is called in the copy_process() failure path. 7657 * cgroup_exit() is called in the copy_process() failure path.
@@ -7899,13 +7970,9 @@ static struct cftype cpu_files[] = {
7899 .write_u64 = cpu_rt_period_write_uint, 7970 .write_u64 = cpu_rt_period_write_uint,
7900 }, 7971 },
7901#endif 7972#endif
7973 { } /* terminate */
7902}; 7974};
7903 7975
7904static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont)
7905{
7906 return cgroup_add_files(cont, ss, cpu_files, ARRAY_SIZE(cpu_files));
7907}
7908
7909struct cgroup_subsys cpu_cgroup_subsys = { 7976struct cgroup_subsys cpu_cgroup_subsys = {
7910 .name = "cpu", 7977 .name = "cpu",
7911 .create = cpu_cgroup_create, 7978 .create = cpu_cgroup_create,
@@ -7913,8 +7980,8 @@ struct cgroup_subsys cpu_cgroup_subsys = {
7913 .can_attach = cpu_cgroup_can_attach, 7980 .can_attach = cpu_cgroup_can_attach,
7914 .attach = cpu_cgroup_attach, 7981 .attach = cpu_cgroup_attach,
7915 .exit = cpu_cgroup_exit, 7982 .exit = cpu_cgroup_exit,
7916 .populate = cpu_cgroup_populate,
7917 .subsys_id = cpu_cgroup_subsys_id, 7983 .subsys_id = cpu_cgroup_subsys_id,
7984 .base_cftypes = cpu_files,
7918 .early_init = 1, 7985 .early_init = 1,
7919}; 7986};
7920 7987
@@ -7930,8 +7997,7 @@ struct cgroup_subsys cpu_cgroup_subsys = {
7930 */ 7997 */
7931 7998
7932/* create a new cpu accounting group */ 7999/* create a new cpu accounting group */
7933static struct cgroup_subsys_state *cpuacct_create( 8000static struct cgroup_subsys_state *cpuacct_create(struct cgroup *cgrp)
7934 struct cgroup_subsys *ss, struct cgroup *cgrp)
7935{ 8001{
7936 struct cpuacct *ca; 8002 struct cpuacct *ca;
7937 8003
@@ -7961,8 +8027,7 @@ out:
7961} 8027}
7962 8028
7963/* destroy an existing cpu accounting group */ 8029/* destroy an existing cpu accounting group */
7964static void 8030static void cpuacct_destroy(struct cgroup *cgrp)
7965cpuacct_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
7966{ 8031{
7967 struct cpuacct *ca = cgroup_ca(cgrp); 8032 struct cpuacct *ca = cgroup_ca(cgrp);
7968 8033
@@ -8101,13 +8166,9 @@ static struct cftype files[] = {
8101 .name = "stat", 8166 .name = "stat",
8102 .read_map = cpuacct_stats_show, 8167 .read_map = cpuacct_stats_show,
8103 }, 8168 },
8169 { } /* terminate */
8104}; 8170};
8105 8171
8106static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
8107{
8108 return cgroup_add_files(cgrp, ss, files, ARRAY_SIZE(files));
8109}
8110
8111/* 8172/*
8112 * charge this task's execution time to its accounting group. 8173 * charge this task's execution time to its accounting group.
8113 * 8174 *
@@ -8139,7 +8200,7 @@ struct cgroup_subsys cpuacct_subsys = {
8139 .name = "cpuacct", 8200 .name = "cpuacct",
8140 .create = cpuacct_create, 8201 .create = cpuacct_create,
8141 .destroy = cpuacct_destroy, 8202 .destroy = cpuacct_destroy,
8142 .populate = cpuacct_populate,
8143 .subsys_id = cpuacct_subsys_id, 8203 .subsys_id = cpuacct_subsys_id,
8204 .base_cftypes = files,
8144}; 8205};
8145#endif /* CONFIG_CGROUP_CPUACCT */ 8206#endif /* CONFIG_CGROUP_CPUACCT */