From: Waiman Long <longman@redhat.com>
To: Markus Elfring <Markus.Elfring@web.de>,
cgroups@vger.kernel.org, kernel-janitors@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>, Tejun Heo <tj@kernel.org>,
Zefan Li <lizefan.x@bytedance.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cgroup/cpuset: Adjust exception handling in generate_sched_domains()
Date: Mon, 1 Jan 2024 11:26:57 -0500 [thread overview]
Message-ID: <86fa9afa-21c0-42fb-926d-5ffc69695d30@redhat.com> (raw)
In-Reply-To: <b441f304-a3cc-4ebe-91cb-84caf55cbfe2@web.de>
On 1/1/24 03:56, Markus Elfring wrote:
>>> Two resource allocation failures triggered further actions
>>> over the label “done” so far.
>>>
>>> * Jump to the statement “ndoms = 1;” in three cases directly
>>> by using the label “set_ndoms” instead.
>>>
>>> * Delete an assignment for the variable “ndoms” in one if branch.
> …
>>> ---
>>> kernel/cgroup/cpuset.c | 8 ++++----
>>> 1 file changed, 4 insertions(+), 4 deletions(-)
> …
>>> @@ -973,10 +973,9 @@ static int generate_sched_domains(cpumask_var_t **domains,
>>>
>>> /* Special case for the 99% of systems with one, full, sched domain */
>>> if (root_load_balance && !top_cpuset.nr_subparts) {
>>> - ndoms = 1;
>>> doms = alloc_sched_domains(ndoms);
>>> if (!doms)
>>> - goto done;
>>> + goto set_ndoms;
>>>
>>> dattr = kmalloc(sizeof(struct sched_domain_attr), GFP_KERNEL);
>>> if (dattr) {
> …
>>> @@ -1123,6 +1122,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
>>> * See comments in partition_sched_domains().
>>> */
>>> if (doms == NULL)
>>> +set_ndoms:
>>> ndoms = 1;
>>>
>>> *domains = doms;
> …
>> Please clarify what this patch is for. Is it just a cleanup with no functional changes or is there a bug that is being fixed?
> The development opinions might vary for the presented transformation.
> I suggest to reconsider the number of relevant variable assignments here.
> Would you categorise an extra statement still as a desirable implementation detail?
My understanding of the patch is just to avoid an unnecessary call to
kfree() as kfree(NULL) is basically a NOP. By jumping inside the "if"
part of the conditional statement, however, it makes it a bit harder to
read. As generate_sched_domains() is not in the fast path, I would
rather have a patch that can simplify the logic than to make it harder
to understand.
Cheers,
Longman
next prev parent reply other threads:[~2024-01-01 16:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-31 7:28 [PATCH] cgroup/cpuset: Adjust exception handling in generate_sched_domains() Markus Elfring
2023-12-31 18:29 ` Waiman Long
2024-01-01 8:56 ` Markus Elfring
2024-01-01 16:26 ` Waiman Long [this message]
2024-01-10 15:01 ` kernel test robot
2024-01-10 15:21 ` Waiman Long
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=86fa9afa-21c0-42fb-926d-5ffc69695d30@redhat.com \
--to=longman@redhat.com \
--cc=Markus.Elfring@web.de \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=tj@kernel.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