From: Steven Rostedt <rostedt@goodmis.org>
To: Xiu Jianfeng <xiujianfeng@huawei.com>
Cc: <mingo@redhat.com>, <peterz@infradead.org>,
<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
<dietmar.eggemann@arm.com>, <bsegall@google.com>,
<mgorman@suse.de>, <bristot@redhat.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] sched: Use struct_size() helper in task_numa_group()
Date: Thu, 6 Jan 2022 11:39:11 -0500 [thread overview]
Message-ID: <20220106113911.6ffb7fd0@gandalf.local.home> (raw)
In-Reply-To: <20211221132138.49464-1-xiujianfeng@huawei.com>
On Tue, 21 Dec 2021 21:21:38 +0800
Xiu Jianfeng <xiujianfeng@huawei.com> wrote:
> Make use of struct_size() helper instead of an open-coded calculation.
> There is no functional change in this patch.
I'm all for this clean up, but...
>
> Link: https://github.com/KSPP/linux/issues/160
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
> kernel/sched/fair.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 095b0aa378df..265e37be0c92 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2437,11 +2437,8 @@ static void task_numa_group(struct task_struct *p, int cpupid, int flags,
> int i;
>
> if (unlikely(!deref_curr_numa_group(p))) {
> - unsigned int size = sizeof(struct numa_group) +
> - NR_NUMA_HINT_FAULT_STATS *
> - nr_node_ids * sizeof(unsigned long);
> -
> - grp = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
> + grp = kzalloc(struct_size(grp, faults, NR_NUMA_HINT_FAULT_STATS * nr_node_ids),
> + GFP_KERNEL | __GFP_NOWARN);
Ug, the above is so ugly. Why remove the size variable?
unsigned int size = struct_size(grp, faults,
NR_NUMA_HINT_FAULT_STATS * nr_node_ids);
-- Steve
> if (!grp)
> return;
>
next prev parent reply other threads:[~2022-01-06 16:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 13:21 [PATCH -next] sched: Use struct_size() helper in task_numa_group() Xiu Jianfeng
2022-01-06 16:39 ` Steven Rostedt [this message]
2022-01-07 2:52 Xiu Jianfeng
2022-01-07 14:36 ` Steven Rostedt
2022-01-10 1:20 ` xiujianfeng
2022-01-10 16:06 ` Peter Zijlstra
2022-01-10 16:11 ` Steven Rostedt
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=20220106113911.6ffb7fd0@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
--cc=xiujianfeng@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).