From: Chengming Zhou <zhouchengming@bytedance.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com
Cc: rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, linux-kernel@vger.kernel.org,
Xuan Lu <luxuan.windniw@bytedance.com>,
Minye Zhu <zhuminye@bytedance.com>,
Qiang Wang <wangqiang.wq.frank@bytedance.com>
Subject: Re: [PATCH] sched/cpuacct: fix percpu time accounting
Date: Mon, 20 Dec 2021 15:38:27 +0800 [thread overview]
Message-ID: <c27af938-5f96-f153-63b5-df7e2d3f2e3e@bytedance.com> (raw)
In-Reply-To: <20211208073836.70619-1-zhouchengming@bytedance.com>
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@bytedance.com>
> Reported-by: Minye Zhu <zhuminye@bytedance.com>
> Co-developed-by: Qiang Wang <wangqiang.wq.frank@bytedance.com>
> Signed-off-by: Qiang Wang <wangqiang.wq.frank@bytedance.com>
> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.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();
> }
prev parent reply other threads:[~2021-12-20 7:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 7:38 [PATCH] sched/cpuacct: fix percpu time accounting Chengming Zhou
2021-12-20 7:38 ` Chengming Zhou [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c27af938-5f96-f153-63b5-df7e2d3f2e3e@bytedance.com \
--to=zhouchengming@bytedance.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luxuan.windniw@bytedance.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=wangqiang.wq.frank@bytedance.com \
--cc=zhuminye@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).