[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANDhNCo0u4bdvMxCpoDaZtFFJw5s2KJU=FOeho116p_8LujAfA@mail.gmail.com>
Date: Thu, 10 Jul 2025 10:25:46 -0700
From: John Stultz <jstultz@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: LKML <linux-kernel@...r.kernel.org>, K Prateek Nayak <kprateek.nayak@....com>,
Joel Fernandes <joelagnelf@...dia.com>, Qais Yousef <qyousef@...alina.io>,
Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>,
Valentin Schneider <vschneid@...hat.com>, Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Zimuzo Ezeozue <zezeozue@...gle.com>, Mel Gorman <mgorman@...e.de>,
Will Deacon <will@...nel.org>, Waiman Long <longman@...hat.com>, Boqun Feng <boqun.feng@...il.com>,
"Paul E. McKenney" <paulmck@...nel.org>, Metin Kaya <Metin.Kaya@....com>,
Xuewen Yan <xuewen.yan94@...il.com>, Thomas Gleixner <tglx@...utronix.de>,
Daniel Lezcano <daniel.lezcano@...aro.org>, Suleiman Souhlal <suleiman@...gle.com>,
kuyo chang <kuyo.chang@...iatek.com>, hupu <hupu.gm@...il.com>, kernel-team@...roid.com
Subject: Re: [RESEND][PATCH v18 5/8] sched: Fix runtime accounting w/ split
exec & sched contexts
On Thu, Jul 10, 2025 at 2:45 AM Peter Zijlstra <peterz@...radead.org> wrote:
> On Mon, Jul 07, 2025 at 08:43:52PM +0000, John Stultz wrote:
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index edcc7d59ecc3b..c34e0891193a7 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -1143,30 +1143,40 @@ static void update_tg_load_avg(struct cfs_rq *cfs_rq)
> > }
> > #endif /* CONFIG_SMP */
> >
> > +static s64 update_se(struct rq *rq, struct sched_entity *se)
> > {
> > u64 now = rq_clock_task(rq);
> > s64 delta_exec;
> >
> > + delta_exec = now - se->exec_start;
> > if (unlikely(delta_exec <= 0))
> > return delta_exec;
> >
> > + se->exec_start = now;
> > + if (entity_is_task(se)) {
> > + struct task_struct *donor = task_of(se);
> > + struct task_struct *running = rq->curr;
> > + /*
> > + * If se is a task, we account the time against the running
> > + * task, as w/ proxy-exec they may not be the same.
> > + */
> > + running->se.exec_start = now;
> > + running->se.sum_exec_runtime += delta_exec;
> >
> > + trace_sched_stat_runtime(running, delta_exec);
> > + account_group_exec_runtime(running, delta_exec);
> >
> > + /* cgroup time is always accounted against the donor */
> > + cgroup_account_cputime(donor, delta_exec);
> > + } else {
> > + /* If not task, account the time against donor se */
> > + se->sum_exec_runtime += delta_exec;
> > }
>
> Bah.. this is all terrible :-) But yeah, I suppose this wil do.
Yeah, :/ I'm happy to rework it further if you have ideas.
> > @@ -1213,7 +1223,7 @@ s64 update_curr_common(struct rq *rq)
> > {
> > struct task_struct *donor = rq->donor;
> >
> > + return update_se(rq, &donor->se);
> > }
>
> At this point this might as well read:
>
> return update_se(rq, &rq->donor->se);
Good point. Done.
Thanks so much for the review! I'll get the next iteration ready to go out soon.
-john
Powered by blists - more mailing lists