From: Aaron Lu <ziqianlu@bytedance.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Valentin Schneider <vschneid@redhat.com>,
Ben Segall <bsegall@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Chengming Zhou <chengming.zhou@linux.dev>,
Josh Don <joshdon@google.com>, Ingo Molnar <mingo@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Xi Wang <xii@google.com>,
linux-kernel@vger.kernel.org, Juri Lelli <juri.lelli@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mel Gorman <mgorman@suse.de>,
Chuyi Zhou <zhouchuyi@bytedance.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Florian Bezdeka <florian.bezdeka@siemens.com>,
Songtang Liu <liusongtang@bytedance.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCH v3 3/5] sched/fair: Switch to task based throttle model
Date: Wed, 3 Sep 2025 19:35:51 +0800 [thread overview]
Message-ID: <20250903113551.GC42@bytedance> (raw)
In-Reply-To: <13467b08-96a6-478d-bb97-060b7d8887e4@amd.com>
[-- Attachment #1: Type: text/plain, Size: 4001 bytes --]
On Wed, Sep 03, 2025 at 04:01:03PM +0530, K Prateek Nayak wrote:
> Hello Aaron,
>
> On 9/3/2025 3:41 PM, Aaron Lu wrote:
> > Hi Prateek,
> >
> > On Wed, Sep 03, 2025 at 02:41:55PM +0530, K Prateek Nayak wrote:
> >> Hello Aaron,
> >>
> >> On 9/3/2025 12:44 PM, Aaron Lu wrote:
> >>> On Fri, Aug 22, 2025 at 07:07:01PM +0800, Aaron Lu wrote:
> >>>> With this said, I reduced the task number and retested on this 2nd AMD
> >>>> Genoa:
> >>>> - quota set to 50 cpu for each level1 cgroup;
> >>
> >> What exactly is the quota and period when you say 50cpu?
> >
> > period is the default 100000 and quota is set to 5000000.
>
> Thank you! I'll do some tests on my end as well.
>
I've attached test scripts I've used for your reference.
> [..snip..]
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index df8dc389af8e1..3e927b9b7eeb6 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -9370,6 +9370,9 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
> > if ((p->se.sched_delayed) && (env->migration_type != migrate_load))
> > return 0;
> >
> > + if (throttled_hierarchy(task_group(p)->cfs_rq[env->dst_cpu]))
> > + return 0;
> > +
>
> This makes sense instead of the full throttled_lb_pair(). You'll still
> need to put it behind CONFIG_CGROUP_SCHED (or better yet
> CONFIG_CFS_BANDWIDTH) since task_group() can return NULL if GROUP_SCHED
> is not enabled.
>
Got it, thanks for the remind. Maybe I can avoid adding new wrappers
and just check task_group() first, something like this:
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index df8dc389af8e1..d9abde5e631b8 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9362,6 +9362,7 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
/*
* We do not migrate tasks that are:
* 1) delayed dequeued unless we migrate load, or
+ * 2) target cfs_rq is in throttled hierarchy, or
* 2) cannot be migrated to this CPU due to cpus_ptr, or
* 3) running (obviously), or
* 4) are cache-hot on their current CPU, or
@@ -9370,6 +9371,10 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
if ((p->se.sched_delayed) && (env->migration_type != migrate_load))
return 0;
+ if (task_group(p) &&
+ throttled_hierarchy(task_group(p)->cfs_rq[env->dst_cpu]))
+ return 0;
+
/*
* We want to prioritize the migration of eligible tasks.
* For ineligible tasks we soft-limit them and only allow
> > /*
> > * We want to prioritize the migration of eligible tasks.
> > * For ineligible tasks we soft-limit them and only allow
> >
> > base head' diff head(patch1-5)
> > Time 82.55±4.82% 83.81±2.89% -1.5% 99.69±6.71%
> >
> > head': head + above diff
> >
> > I also tested netperf on this AMD system as well as hackbench and
> > netperf on Intel EMR, no obvious performance difference observed
> > after applying the above diff, i.e. base and head' performance is
> > roughly the same.
> >
> > Does the above diff make sense? One thing I'm slightly concerned is,
> > there may be one case when balancing a task to a throttled target
> > cfs_rq makes sense: if the task holds some kernel resource and is
> > running inside kernel, even its target cfs_rq is throttled, we still
> > want this task to go there and finish its job in kernel mode sooner,
> > this could help other resource waiters. But, this may not be a big deal
>
> I think it is still an improvement over per-cfs_rq throttling from a
> tail latency perspective.
>
> > and in most of the time, balancing a task to a throttled cfs_rq doesn't
> > look like a meaningful thing to do.Ack.
Just want to add that with the above diff applied, I also tested
songtang's stress test[0] and Jan's rt deadlock reproducer[1] and didn't
see any problem.
[0]: https://lore.kernel.org/lkml/20250715072218.GA304@bytedance/
[1]: https://lore.kernel.org/all/7483d3ae-5846-4067-b9f7-390a614ba408@siemens.com/
[-- Attachment #2: test.sh --]
[-- Type: application/x-sh, Size: 2030 bytes --]
[-- Attachment #3: run_in_cg.sh --]
[-- Type: application/x-sh, Size: 294 bytes --]
[-- Attachment #4: cleanup.sh --]
[-- Type: application/x-sh, Size: 1022 bytes --]
next prev parent reply other threads:[~2025-09-03 11:36 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 7:16 [PATCH v3 0/5] Defer throttle when task exits to user Aaron Lu
2025-07-15 7:16 ` [PATCH v3 1/5] sched/fair: Add related data structure for task based throttle Aaron Lu
2025-07-15 7:16 ` [PATCH v3 2/5] sched/fair: Implement throttle task work and related helpers Aaron Lu
2025-07-15 7:16 ` [PATCH v3 3/5] sched/fair: Switch to task based throttle model Aaron Lu
2025-07-15 23:29 ` kernel test robot
2025-07-16 6:57 ` Aaron Lu
2025-07-16 7:40 ` Philip Li
2025-07-16 11:15 ` [PATCH v3 update " Aaron Lu
2025-07-16 11:27 ` [PATCH v3 " Peter Zijlstra
2025-07-16 15:20 ` kernel test robot
2025-07-17 3:52 ` Aaron Lu
2025-07-23 8:21 ` Oliver Sang
2025-07-23 10:08 ` Aaron Lu
2025-08-08 9:12 ` Valentin Schneider
2025-08-08 10:13 ` Aaron Lu
2025-08-08 11:45 ` Valentin Schneider
2025-08-12 8:48 ` Aaron Lu
2025-08-14 15:54 ` Valentin Schneider
2025-08-15 9:30 ` Aaron Lu
2025-08-22 11:07 ` Aaron Lu
2025-09-03 7:14 ` Aaron Lu
2025-09-03 9:11 ` K Prateek Nayak
2025-09-03 10:11 ` Aaron Lu
2025-09-03 10:31 ` K Prateek Nayak
2025-09-03 11:35 ` Aaron Lu [this message]
2025-09-04 7:33 ` Bezdeka, Florian
2025-09-04 8:26 ` K Prateek Nayak
2025-09-04 8:40 ` Aaron Lu
2025-08-28 3:50 ` Aaron Lu
2025-08-17 8:50 ` Chen, Yu C
2025-08-18 2:50 ` Aaron Lu
2025-08-18 3:10 ` Chen, Yu C
2025-08-18 3:12 ` Aaron Lu
2025-07-15 7:16 ` [PATCH v3 4/5] sched/fair: Task based throttle time accounting Aaron Lu
2025-08-18 14:57 ` Valentin Schneider
2025-08-19 9:34 ` Aaron Lu
2025-08-19 14:09 ` Valentin Schneider
2025-08-26 14:10 ` Michal Koutný
2025-08-27 15:16 ` Valentin Schneider
2025-08-28 6:06 ` Aaron Lu
2025-08-26 9:15 ` Aaron Lu
2025-07-15 7:16 ` [PATCH v3 5/5] sched/fair: Get rid of throttled_lb_pair() Aaron Lu
2025-07-15 7:22 ` [PATCH v3 0/5] Defer throttle when task exits to user Aaron Lu
2025-08-01 14:31 ` Matteo Martelli
2025-08-04 7:52 ` Aaron Lu
2025-08-04 11:18 ` Valentin Schneider
2025-08-04 11:56 ` Aaron Lu
2025-08-08 16:37 ` Matteo Martelli
2025-08-04 8:51 ` K Prateek Nayak
2025-08-04 11:48 ` Aaron Lu
2025-08-27 14:58 ` Valentin Schneider
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=20250903113551.GC42@bytedance \
--to=ziqianlu@bytedance.com \
--cc=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=chengming.zhou@linux.dev \
--cc=dietmar.eggemann@arm.com \
--cc=florian.bezdeka@siemens.com \
--cc=jan.kiszka@siemens.com \
--cc=joshdon@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liusongtang@bytedance.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=xii@google.com \
--cc=zhouchuyi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.