[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c27af938-5f96-f153-63b5-df7e2d3f2e3e@bytedance.com>
Date: Mon, 20 Dec 2021 15:38:27 +0800
From: Chengming Zhou <zhouchengming@...edance.com>
To: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, dietmar.eggemann@....com
Cc: rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
bristot@...hat.com, linux-kernel@...r.kernel.org,
Xuan Lu <luxuan.windniw@...edance.com>,
Minye Zhu <zhuminye@...edance.com>,
Qiang Wang <wangqiang.wq.frank@...edance.com>
Subject: Re: [PATCH] sched/cpuacct: fix percpu time accounting
Ping guys. Any comments or suggestions?
On 2021/12/8 3:38 下午, Chengming Zhou wrote:
> The usage percpu data is the CPU time consumed on each CPU by all tasks
> in this cgroup (including tasks lower in the hierarchy). When cpuacct_charge
> called from other CPUs, we should use the CPU of task, not this CPU.
>
> e.g.
> cpuacct_charge+1
> update_curr+332
> enqueue_entity+70
> enqueue_task_fair+169
> activate_task+57
> attach_task+46
> load_balance+1512
> run_rebalance_domains+451
> __do_softirq+282
> sysvec_apic_timer_interrupt+159
> asm_sysvec_apic_timer_interrupt+18
> native_safe_halt+11
> default_idle+10
> default_enter_idle+45
> cpuidle_enter_state+130
> cpuidle_enter+47
> do_idle+489
> cpu_startup_entry+25
> start_secondary+261
> secondary_startup_64_no_verify+176
>
> Reported-by: Xuan Lu <luxuan.windniw@...edance.com>
> Reported-by: Minye Zhu <zhuminye@...edance.com>
> Co-developed-by: Qiang Wang <wangqiang.wq.frank@...edance.com>
> Signed-off-by: Qiang Wang <wangqiang.wq.frank@...edance.com>
> Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
> ---
> kernel/sched/cpuacct.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
> index 893eece65bfd..aab51c88bd34 100644
> --- a/kernel/sched/cpuacct.c
> +++ b/kernel/sched/cpuacct.c
> @@ -341,6 +341,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
> struct cpuacct *ca;
> int index = CPUACCT_STAT_SYSTEM;
> struct pt_regs *regs = get_irq_regs() ? : task_pt_regs(tsk);
> + unsigned int cpu = task_cpu(tsk);
>
> if (regs && user_mode(regs))
> index = CPUACCT_STAT_USER;
> @@ -348,7 +349,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
> rcu_read_lock();
>
> for (ca = task_ca(tsk); ca; ca = parent_ca(ca))
> - __this_cpu_add(ca->cpuusage->usages[index], cputime);
> + per_cpu_ptr(ca->cpuusage, cpu)->usages[index] += cputime;
>
> rcu_read_unlock();
> }
Powered by blists - more mailing lists