All of lore.kernel.org
 help / color / mirror / Atom feed
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>, <gustavoars@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-hardening@vger.kernel.org>
Subject: Re: [PATCH -next] sched: Use struct_size() helper in task_numa_group()
Date: Fri, 7 Jan 2022 09:36:17 -0500	[thread overview]
Message-ID: <20220107093617.56e218dc@gandalf.local.home> (raw)
In-Reply-To: <20220107025212.177040-1-xiujianfeng@huawei.com>

On Fri, 7 Jan 2022 10:52:12 +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.
> 
> 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);

I just replied yesterday. Keep the size variable. The above is too much for
a kzalloc().

-- Steve




>  		if (!grp)
>  			return;
>  


  reply	other threads:[~2022-01-07 14:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  2:52 [PATCH -next] sched: Use struct_size() helper in task_numa_group() Xiu Jianfeng
2022-01-07 14:36 ` Steven Rostedt [this message]
2022-01-10  1:20   ` xiujianfeng
2022-01-10 16:06 ` Peter Zijlstra
2022-01-10 16:11   ` Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2021-12-21 13:21 Xiu Jianfeng
2022-01-06 16:39 ` 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=20220107093617.56e218dc@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gustavoars@kernel.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-hardening@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.