From: Johannes Weiner <hannes@cmpxchg.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, surenb@google.com, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/4] sched: Fix cgroup irq accounting for CONFIG_IRQ_TIME_ACCOUNTING
Date: Tue, 8 Oct 2024 10:23:13 -0400 [thread overview]
Message-ID: <20241008142129.GB6937@cmpxchg.org> (raw)
In-Reply-To: <20241008061951.3980-5-laoar.shao@gmail.com>
On Tue, Oct 08, 2024 at 02:19:51PM +0800, Yafang Shao wrote:
> @@ -5587,7 +5587,24 @@ void sched_tick(void)
> rq_lock(rq, &rf);
>
> curr = rq->curr;
> - psi_account_irqtime(rq, curr, NULL);
> +
> +#ifdef CONFIG_IRQ_TIME_ACCOUNTING
> + if (static_branch_likely(&sched_clock_irqtime)) {
> + u64 now, irq;
> + s64 delta;
> +
> + now = cpu_clock(cpu);
> + irq = irq_time_read(cpu);
> + delta = (s64)(irq - rq->psi_irq_time);
> + if (delta > 0) {
> + rq->psi_irq_time = irq;
> + psi_account_irqtime(rq, curr, NULL, now, delta);
> + cgroup_account_cputime(curr, delta);
> + /* We account both softirq and irq into softirq */
> + cgroup_account_cputime_field(curr, CPUTIME_SOFTIRQ, delta);
> + }
> + }
> +#endif
>
> update_rq_clock(rq);
> hw_pressure = arch_scale_hw_pressure(cpu_of(rq));
> @@ -6667,7 +6684,25 @@ static void __sched notrace __schedule(int sched_mode)
> ++*switch_count;
>
> migrate_disable_switch(rq, prev);
> - psi_account_irqtime(rq, prev, next);
> +
> +#ifdef CONFIG_IRQ_TIME_ACCOUNTING
> + if (static_branch_likely(&sched_clock_irqtime)) {
> + u64 now, irq;
> + s64 delta;
> +
> + now = cpu_clock(cpu);
> + irq = irq_time_read(cpu);
> + delta = (s64)(irq - rq->psi_irq_time);
> + if (delta > 0) {
> + rq->psi_irq_time = irq;
> + psi_account_irqtime(rq, prev, next, now, delta);
> + cgroup_account_cputime(prev, delta);
> + /* We account both softirq and irq into softirq */
> + cgroup_account_cputime_field(prev, CPUTIME_SOFTIRQ, delta);
> + }
> + }
> +#endif
This should be inside its own function - to avoid duplication of
course, but also the ifdefs and overly detailed accounting code in the
middle of core scheduling logic.
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
static void account_irqtime(struct rq *rq, ...)
{
...
}
#else
static inline void account_irqtime(...) {}
#endif
next prev parent reply other threads:[~2024-10-08 14:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 6:19 [PATCH v2 0/4] sched: Fix " Yafang Shao
2024-10-08 6:19 ` [PATCH v2 1/4] sched: Define sched_clock_irqtime as static key Yafang Shao
2024-10-08 6:19 ` [PATCH v2 2/4] sched: Don't account irq time if sched_clock_irqtime is disabled Yafang Shao
2024-10-08 6:19 ` [PATCH v2 3/4] sched, psi: " Yafang Shao
2024-10-08 14:04 ` Johannes Weiner
2024-10-08 6:19 ` [PATCH v2 4/4] sched: Fix cgroup irq accounting for CONFIG_IRQ_TIME_ACCOUNTING Yafang Shao
2024-10-08 14:23 ` Johannes Weiner [this message]
2024-10-09 11:40 ` Yafang Shao
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=20241008142129.GB6937@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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
all inboxes | Powered by JetHome®