From: Xiu Jianfeng <xiujianfeng@huawei.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
<dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
<bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH -next] sched: Use struct_size() helper in task_numa_group()
Date: Tue, 21 Dec 2021 21:21:38 +0800 [thread overview]
Message-ID: <20211221132138.49464-1-xiujianfeng@huawei.com> (raw)
Make use of struct_size() helper instead of an open-coded calculation.
There is no functional change in this patch.
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);
if (!grp)
return;
--
2.17.1
next reply other threads:[~2021-12-21 13:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 13:21 Xiu Jianfeng [this message]
2022-01-06 16:39 ` [PATCH -next] sched: Use struct_size() helper in task_numa_group() Steven Rostedt
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=20211221132138.49464-1-xiujianfeng@huawei.com \
--to=xiujianfeng@huawei.com \
--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=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.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;
as well as URLs for NNTP newsgroup(s).