On Fri, May 04, 2018 at 10:28:20PM +0800, zhangq95 wrote: > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 5e10aae..ba969af 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3404,11 +3404,19 @@ static void __sched notrace __schedule(bool preempt) > struct rq_flags rf; > struct rq *rq; > int cpu; > + struct task_struct *prev_root = NULL, *next_root = NULL; > > cpu = smp_processor_id(); > rq = cpu_rq(cpu); > prev = rq->curr; > > + if (task_active_pid_ns(prev)) { > + prev_root = task_active_pid_ns(prev)->child_reaper; > + if (prev_root != init_pid_ns.child_reaper) > + update_cpuacct_procs_stat(prev, prev->cpu, > + CPUACCT_PROCS_SWITCHES, 1, 0); > + } > + > schedule_debug(prev); > > if (sched_feat(HRTICK)) > @@ -3462,6 +3470,12 @@ static void __sched notrace __schedule(bool preempt) > } > > next = pick_next_task(rq, prev, &rf); > + if (task_active_pid_ns(next)) { > + next_root = task_active_pid_ns(next)->child_reaper; > + if (prev_root && prev_root != next_root) > + update_cpuacct_procs_stat(next, next->cpu, > + CPUACCT_PROCS_SWITCHES, 1, 0); > + } > clear_tsk_need_resched(prev); > clear_preempt_need_resched(); > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 54dc31e..46adf63 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -4757,6 +4774,7 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq) > if (dequeue) > dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); > qcfs_rq->h_nr_running -= task_delta; > + update_cpuacct_running_from_cfs(qcfs_rq, -task_delta); > > if (qcfs_rq->load.weight) > dequeue = 0; > @@ -4820,6 +4838,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) > if (enqueue) > enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); > cfs_rq->h_nr_running += task_delta; > + update_cpuacct_running_from_cfs(cfs_rq, task_delta); > > if (cfs_rq_throttled(cfs_rq)) > break; > @@ -5379,6 +5398,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > if (cfs_rq_throttled(cfs_rq)) > break; > cfs_rq->h_nr_running++; > + update_cpuacct_running_from_cfs(cfs_rq, 1); > > flags = ENQUEUE_WAKEUP; > } > @@ -5386,6 +5406,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > for_each_sched_entity(se) { > cfs_rq = cfs_rq_of(se); > cfs_rq->h_nr_running++; > + update_cpuacct_running_from_cfs(cfs_rq, 1); > > if (cfs_rq_throttled(cfs_rq)) > break; > @@ -5427,6 +5448,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) > if (cfs_rq_throttled(cfs_rq)) > break; > cfs_rq->h_nr_running--; > + update_cpuacct_running_from_cfs(cfs_rq, -1); > > /* Don't dequeue parent if it has other entities besides us */ > if (cfs_rq->load.weight) { > @@ -5446,6 +5468,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) > for_each_sched_entity(se) { > cfs_rq = cfs_rq_of(se); > cfs_rq->h_nr_running--; > + update_cpuacct_running_from_cfs(cfs_rq, -1); > > if (cfs_rq_throttled(cfs_rq)) > break; > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 7aef6b4..766ec16 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -1327,6 +1327,7 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags) > rt_se->timeout = 0; > > enqueue_rt_entity(rt_se, flags); > + update_cpuacct_procs_stat(p, cpu_of(rq), CPUACCT_PROCS_RUNNING, 1, 0); > > if (!task_current(rq, p) && p->nr_cpus_allowed > 1) > enqueue_pushable_task(rq, p); > @@ -1338,6 +1339,7 @@ static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags) > > update_curr_rt(rq); > dequeue_rt_entity(rt_se, flags); > + update_cpuacct_procs_stat(p, cpu_of(rq), CPUACCT_PROCS_RUNNING, -1, 0); > > dequeue_pushable_task(rq, p); > } Yeah, I think not... death by accounting. -- To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html