public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef-wp2msK0BRk8tq7phqP6ubQ@public.gmane.org>
To: Dietmar Eggemann <dietmar.eggemann-5wv7dgnIgG8@public.gmane.org>,
	Juri Lelli <juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Juri Lelli <juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Peter Zijlstra <peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Ingo Molnar <mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>,
	tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	luca.abeni-5rdYK369eBLQB0XuIGIEkQ@public.gmane.org,
	claudio-YOzL5CV4y4YG1A2ADO40+w@public.gmane.org,
	tommaso.cucinotta-5rdYK369eBLQB0XuIGIEkQ@public.gmane.org,
	bristot-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Vincent Guittot
	<vincent.guittot-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Wei Wang <wvw-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Rick Yiu <rickyiu-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Quentin Perret <qperret-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Heiko Carstens <hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Vasily Gorbik <gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Alexander Gordeev
	<agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Sudeep Holla <sudeep.holla-5wv7dgnIgG8@public.gmane.org>,
	Zefan Li <lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>,
	linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH v3] sched: cpuset: Don't rebuild root domains on suspend-resume
Date: Tue, 28 Feb 2023 17:46:27 +0000	[thread overview]
Message-ID: <20230228174627.vja5aejq27dsta2u@airbuntu> (raw)
In-Reply-To: <5a1e58bf-7eb2-bd7a-7e19-7864428a2b83-5wv7dgnIgG8@public.gmane.org>

On 02/28/23 15:09, Dietmar Eggemann wrote:

> > IIUC you're suggesting to introduce some new mechanism to detect if hotplug has
> > lead to a cpu to disappear or not and use that instead? Are you saying I can
> > use arch_update_cpu_topology() for that? Something like this?
> > 
> > 	diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> > 	index e5ddc8e11e5d..60c3dcf06f0d 100644
> > 	--- a/kernel/cgroup/cpuset.c
> > 	+++ b/kernel/cgroup/cpuset.c
> > 	@@ -1122,7 +1122,7 @@ partition_and_rebuild_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
> > 	 {
> > 		mutex_lock(&sched_domains_mutex);
> > 		partition_sched_domains_locked(ndoms_new, doms_new, dattr_new);
> > 	-       if (update_dl_accounting)
> > 	+       if (arch_update_cpu_topology())
> > 			update_dl_rd_accounting();
> > 		mutex_unlock(&sched_domains_mutex);
> > 	 }
> 
> No, this is not what I meant. I'm just saying the:
> 
>   partition_sched_domains_locked()
>     new_topology = arch_update_cpu_topology();
> 
> has to be considered here as well since we do a
> `dl_clear_root_domain(rd)` (1) in partition_sched_domains_locked() for
> !new_topology.

Ah you're referring to the dl_clear_root_domain() call there. I thought this
doesn't trigger.

> 
> And (1) requires the `update_tasks_root_domain()` to happen later.
> 
> So there are cases now, e.g. `rebuild_sched_domains_energy()` in which
> `new_topology=0` and `update_dl_accounting=false` which now clean the rd
> but don't do a new DL accounting anymore.
> rebuild_root_domains() itself cleans the `default root domain`, not the
> other root domains which could exists as well.
> 
> Example: Switching CPUfreq policy [0,3-5] performance to schedutil (slow
> switching, i.e. we have sugov:X DL task(s)):
> 
> [  862.479906] CPU4 partition_sched_domains_locked() new_topology=0
> [  862.499073] Workqueue: events rebuild_sd_workfn
> [  862.503646] Call trace:
> ...
> [  862.520789]  partition_sched_domains_locked+0x6c/0x670
> [  862.525962]  rebuild_sched_domains_locked+0x204/0x8a0
> [  862.531050]  rebuild_sched_domains+0x2c/0x50
> [  862.535351]  rebuild_sd_workfn+0x38/0x54                        <-- !
> ...
> [  862.554047] CPU4 dl_clear_root_domain() rd->span=0-5 total_bw=0
> def_root_domain=0                                                  <-- !
> [  862.561597] CPU4 dl_clear_root_domain() rd->span= total_bw=0
> def_root_domain=1
> [  862.568960] CPU4 dl_add_task_root_domain() [sugov:0 1801]
> total_bw=104857 def_root_domain=0 rd=0xffff0008015f0000            <-- !
> 
> The dl_clear_root_domain() of the def_root_domain and the
> dl_add_task_root_domain() to the rd in use won't happen.
> 
> [sugov:0 1801] is only a simple example here. I could have spawned a
> couple of DL tasks before this to illustrate the issue more obvious.
> 
> ---
> 
> The same seems to happen during suspend/resume (system with 2 frequency
> domains, both with slow switching schedutil CPUfreq gov):
> 
> [   27.735821] CPU5 partition_sched_domains_locked() new_topology=0
> ...
> [   27.735864] Workqueue: events cpuset_hotplug_workfn
> [   27.735894] Call trace:
> ...
> [   27.735984]  partition_sched_domains_locked+0x6c/0x670
> [   27.736004]  rebuild_sched_domains_locked+0x204/0x8a0
> [   27.736026]  cpuset_hotplug_workfn+0x254/0x52c                  <-- !
> ...
> [   27.736155] CPU5 dl_clear_root_domain() rd->span=0-5 total_bw=0
> def_root_domain=0                                                  <-- !
> [   27.736178] CPU5 dl_clear_root_domain() rd->span= total_bw=0
> def_root_domain=1
> [   27.736296] CPU5 dl_add_task_root_domain() [sugov:0 80]         <-- !
>  total_bw=104857 def_root_domain=0 rd=0xffff000801728000
> [   27.736318] CPU5 dl_add_task_root_domain() [sugov:1 81]
> total_bw=209714 def_root_domain=0 rd=0xffff000801728000            <-- !
> ...
> 
> > I am not keen on this. arm64 seems to just read a value without a side effect.
> 
> Arm64 (among others) sets `update_topology=1` before
> `rebuild_sched_domains()` and `update_topology=0` after it in
> update_topology_flags_workfn(). This then makes `new_topology=1` in
> partition_sched_domains_locked().
> 
> > But x86 does reset this value so we can't read it twice in the same call tree
> > and I'll have to extract it.
> > 
> > The better solution that was discussed before is to not iterate through every
> > task in the system and let cpuset track when dl tasks are added to it and do
> > smarter iteration. ATM even if there are no dl tasks in the system we'll
> > blindly go through every task in the hierarchy to update nothing.
> 
> Yes, I can see the problem. And IMHO this solution approach seems to be
> better than parsing update_dl_accounting` through the stack of involved
> functions.

The best I can do is protect this dl_clear_root_domain() too. I really don't
have my heart in this but trying my best to help, but it has taken a lot of my
time already and would prefer to hand over to Juri to address this regression
if what I am proposing is not good enough.

FWIW, there are 0 dl tasks in the system where this was noticed. And this delay
is unbounded because it'll depend on how many tasks there are in the hierarchy.


Thanks!

  parent reply	other threads:[~2023-02-28 17:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 22:14 [PATCH v3] sched: cpuset: Don't rebuild root domains on suspend-resume Qais Yousef
     [not found] ` <20230206221428.2125324-1-qyousef-wp2msK0BRk8tq7phqP6ubQ@public.gmane.org>
2023-02-23 15:38   ` Qais Yousef
2023-02-24 15:14     ` Dietmar Eggemann
     [not found]       ` <5f087dd8-3e39-ce83-fe24-afa5179c05d9-5wv7dgnIgG8@public.gmane.org>
2023-02-27 20:57         ` Qais Yousef
2023-02-28 14:09           ` Dietmar Eggemann
     [not found]             ` <5a1e58bf-7eb2-bd7a-7e19-7864428a2b83-5wv7dgnIgG8@public.gmane.org>
2023-02-28 17:46               ` Qais Yousef [this message]
2023-03-01  7:31                 ` Juri Lelli
     [not found]                   ` <Y/7/SLzvK8LfB29z-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2023-03-01 12:28                     ` Qais Yousef
2023-03-01 14:26                       ` Juri Lelli
     [not found]                         ` <Y/9gmDRlGOChIwpf-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2023-03-01 17:03                           ` Qais Yousef
2023-03-08 10:19                             ` Juri Lelli
     [not found]                               ` <ZAhhGi55BkYkc3ss-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2023-03-08 18:01                                 ` Hao Luo
     [not found]                                   ` <CA+khW7hmE0tECG2qfKW1HN9yLVOLUn5Zzx4Rz-wHYDtSUPYotw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-03-09  6:55                                     ` Juri Lelli
2023-03-09 22:23                                       ` Hao Luo
     [not found]                                         ` <CA+khW7iAeTALH5b6upHXs1RotFBohVeZCcAp5H+r-=L05kqnww-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-03-11 18:51                                           ` Qais Yousef
2023-03-13 16:37                                             ` Juri Lelli
     [not found]                                               ` <ZA9RZ3VvGXKp+1L6-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2023-03-13 17:10                                                 ` Dietmar Eggemann
     [not found]                                                   ` <7070da53-a5a7-6965-5604-abee3cae9d46-5wv7dgnIgG8@public.gmane.org>
2023-03-14 11:41                                                     ` Dietmar Eggemann
2023-03-08 19:21                                 ` Waiman Long
2023-03-13 12:37                                 ` Dietmar Eggemann
2023-03-07 19:56   ` Hao Luo
     [not found]     ` <CA+khW7i_Sc0M4FXzojmQ5PSfkPwk6AdcbN9j0gDXZ9FsOMQAwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-03-07 20:08       ` Waiman Long
     [not found]         ` <f3a99500-e51c-032f-a0c6-01763f0a5be6-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-03-07 21:06           ` Hao Luo
     [not found]             ` <CA+khW7iWAn6bbXdkJX1Lt4dWUsN6o4KqVQ8OFTs0B+VTtVjBkw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-03-07 21:13               ` Waiman Long
     [not found]                 ` <1f2cf8ea-a9d7-5245-0f69-eb8be9f64afc-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-03-07 22:17                   ` Hao Luo
2023-03-08  2:29                     ` Waiman Long
     [not found]                       ` <315efe55-abaf-c199-673b-95ef76a1e442-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-03-08 18:11                         ` Hao Luo

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=20230228174627.vja5aejq27dsta2u@airbuntu \
    --to=qyousef-wp2msk0brk8tq7phqp6ubq@public.gmane.org \
    --cc=agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=bristot-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=claudio-YOzL5CV4y4YG1A2ADO40+w@public.gmane.org \
    --cc=dietmar.eggemann-5wv7dgnIgG8@public.gmane.org \
    --cc=gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
    --cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=luca.abeni-5rdYK369eBLQB0XuIGIEkQ@public.gmane.org \
    --cc=mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=qperret-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=rickyiu-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org \
    --cc=sudeep.holla-5wv7dgnIgG8@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=tommaso.cucinotta-5rdYK369eBLQB0XuIGIEkQ@public.gmane.org \
    --cc=vincent.guittot-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=wvw-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /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