mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xavier  <xavier_qy@163.com>
To: "Michal Koutný" <mkoutny@suse.com>, longman@redhat.com
Cc: tj@kernel.org, akpm@linux-foundation.org,
	lizefan.x@bytedance.com,  hannes@cmpxchg.org,
	cgroups@vger.kernel.org,  linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: Re:Re: [PATCH-cpuset v10 2/2] cpuset: use Union-Find to optimize the merging of cpumasks
Date: Wed, 3 Jul 2024 18:49:43 +0800 (CST)	[thread overview]
Message-ID: <2ea89e07.ac63.1907836ec4b.Coremail.xavier_qy@163.com> (raw)
In-Reply-To: <zkkadtdssdgkndojsvfwbig3xwtqvfleyw3wbg6vewjntmklxe@xle6jq7jvkv5>



Hi Michal and Longman,

Please confirm my explanation about cgroup v2 below.


At 2024-07-03 17:40:49, "Michal Koutný" <mkoutny@suse.com> wrote:
>On Wed, Jul 03, 2024 at 02:37:27PM GMT, Xavier <xavier_qy@163.com> wrote:
>> @@ -1102,31 +1101,25 @@ static int generate_sched_domains(cpumask_var_t **domains,
>>  	if (root_load_balance && (csn == 1))
>>  		goto single_root_domain;
>>  
>> -	for (i = 0; i < csn; i++)
>> -		csa[i]->pn = i;
>> -	ndoms = csn;
>> -
>> -restart:
>> -	/* Find the best partition (set of sched domains) */
>> -	for (i = 0; i < csn; i++) {
>> -		struct cpuset *a = csa[i];
>> -		int apn = a->pn;
>> -
>> -		for (j = 0; j < csn; j++) {
>> -			struct cpuset *b = csa[j];
>> -			int bpn = b->pn;
>> -
>> -			if (apn != bpn && cpusets_overlap(a, b)) {
>> -				for (k = 0; k < csn; k++) {
>> -					struct cpuset *c = csa[k];
>> +	if (!cgrpv2) {
>
>I'm surprised that original code wasn't branched on this on you add it
>here. Why is UF used only for v1 code?
>

In the Patch v6, I explained to Longman that based on his new patch, the overlapping check and
merge operations for cpusets are skipped in the case of cgroup v2. Because for cgroup v2,
doms[i] is merely copied from csa[i] rather than merged.
This needs further confirmation from Longman.

	if (cgrpv2) {
		for (i = 0; i < ndoms; i++) {
			cpumask_copy(doms[i], csa[i]->effective_cpus);
			if (dattr)
				dattr[i] = SD_ATTR_INIT;
		}
		goto done;
	}


>> +		for (i = 0; i < csn; i++)
>> +			uf_node_init(&csa[i]->node);
>>  
>> -					if (c->pn == bpn)
>> -						c->pn = apn;
>> -				}
>> -				ndoms--;	/* one less element */
>> -				goto restart;
>> +		/* Merge overlapping cpusets */
>> +		for (i = 0; i < csn; i++) {
>> +			for (j = i + 1; j < csn; j++) {
>> +				if (cpusets_overlap(csa[i], csa[j]))
>> +					uf_union(&csa[i]->node, &csa[j]->node);
>>  			}
>>  		}
>> +
>> +		/* Count the total number of domains */
>> +		for (i = 0; i < csn; i++) {
>> +			if (csa[i]->node.parent == &csa[i]->node)
>> +				ndoms++;
>
>The naked parent access doesn't hide the UF abstraction well.
>I'd consider uf_find(&csa[i]->node) == &csa[i]->node or a specific
>helper like uf_is_representant(&csa[i]->node).

This can be optimized here. I will change it to the first method you mentioned in the next patch.

Best Regards,
Xavier


  reply	other threads:[~2024-07-03 10:50 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  2:48 [PATCH v2] cpuset: Optimize the number of iterations in the scheduling domain construction process Xavier
2024-05-31 21:13 ` Waiman Long
2024-06-03 12:31 ` [PATCH v3] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-06-04 15:02   ` Waiman Long
2024-06-10 17:18   ` Michal Koutný
2024-06-20  8:52   ` [PATCH v4 v4 0/2] cpuset: use Union-Find to optimize Xavier
2024-06-20  8:52     ` [PATCH v4 v4 1/2] Union-Find: add a new module in kernel library Xavier
2024-06-20 14:54       ` Waiman Long
2024-06-21  8:49         ` [PATCH-cpuset v5 0/2] cpuset: use Union-Find to optimize Xavier
2024-06-21  8:49           ` [PATCH-cpuset v5 1/2] Union-Find: add a new module in kernel library Xavier
2024-06-21 21:10             ` Tejun Heo
2024-06-22  7:14               ` [PATCH-cpuset v6 0/2] Add Union-Find and use it to optimize cpuset Xavier
2024-06-22  7:14                 ` [PATCH-cpuset v6 1/2] Union-Find: add a new module in kernel library Xavier
2024-06-22  7:14                 ` [PATCH-cpuset v6 2/2] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-06-22 16:13                 ` [PATCH-cpuset v6 0/2] Add Union-Find and use it to optimize cpuset Tejun Heo
2024-06-23  2:38                   ` [PATCH-cpuset v7 " Xavier
2024-06-23  2:39                     ` [PATCH-cpuset v7 1/2] Union-Find: add a new module in kernel library Xavier
2024-06-23  2:39                     ` [PATCH-cpuset v7 2/2] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-06-27 21:06                     ` [PATCH-cpuset v7 0/2] Add Union-Find and use it to optimize cpuset Tejun Heo
2024-06-28 16:13                       ` [PATCH-cpuset v8 " Xavier
2024-06-28 16:13                         ` [PATCH-cpuset v8 1/2] Union-Find: add a new module in kernel library Xavier
2024-07-01 20:53                           ` Tejun Heo
2024-07-02 10:50                             ` [PATCH-cpuset v9 0/2] Add Union-Find and use it to optimize cpuset Xavier
2024-07-02 10:50                               ` [PATCH-cpuset v9 1/2] Union-Find: add a new module in kernel library Xavier
2024-07-02 10:50                               ` [PATCH-cpuset v9 2/2] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-07-03  3:05                                 ` Waiman Long
2024-07-02 19:22                               ` [PATCH-cpuset v9 0/2] Add Union-Find and use it to optimize cpuset Tejun Heo
2024-07-03  0:31                                 ` Andrew Morton
2024-07-03 17:34                                   ` Tejun Heo
2024-07-03  6:37                                 ` [PATCH-cpuset v10 " Xavier
2024-07-03  6:37                                   ` [PATCH-cpuset v10 1/2] Union-Find: add a new module in kernel library Xavier
2024-07-03  9:40                                     ` Michal Koutný
2024-07-03 11:20                                       ` Xavier
2024-07-04 12:12                                         ` Michal Koutný
2024-07-03  6:37                                   ` [PATCH-cpuset v10 2/2] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-07-03  9:40                                     ` Michal Koutný
2024-07-03 10:49                                       ` Xavier [this message]
2024-07-03 16:43                                         ` Waiman Long
2024-07-04  6:24                                           ` [PATCH-cpuset v11 0/2] Add Union-Find and use it to optimize cpuset Xavier
2024-07-04  6:24                                             ` [PATCH-cpuset v11 1/2] Union-Find: add a new module in kernel library Xavier
2024-07-30 23:05                                               ` Tejun Heo
2024-07-04  6:24                                             ` [PATCH-cpuset v11 2/2] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-07-30 23:05                                               ` Tejun Heo
2024-07-08  1:59                                             ` [PATCH-cpuset v11 0/2] Add Union-Find and use it to optimize cpuset Waiman Long
2024-07-08 18:38                                               ` Tejun Heo
2024-07-09  2:45                                                 ` Xavier
2024-07-29  2:44                                                 ` Xavier
2024-07-30 23:06                                                   ` Tejun Heo
2024-06-28 16:13                         ` [PATCH-cpuset v8 2/2] cpuset: use Union-Find to optimize the merging of cpumasks Xavier
2024-07-01 20:53                           ` Tejun Heo
2024-06-21  8:49           ` [PATCH-cpuset v5 " Xavier
2024-06-20  8:52     ` [PATCH v4 v4 " Xavier

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=2ea89e07.ac63.1907836ec4b.Coremail.xavier_qy@163.com \
    --to=xavier_qy@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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

Powered by JetHome