All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Dawei Li <dawei.li@shingroup.cn>
Cc: davem@davemloft.net, andreas@gaisler.com,
	sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/7] sparc: Remove on-stack cpumask var
Date: Sat, 20 Apr 2024 10:28:05 +0200	[thread overview]
Message-ID: <20240420082805.GE614130@ravnborg.org> (raw)
In-Reply-To: <20240420051547.3681642-6-dawei.li@shingroup.cn>

On Sat, Apr 20, 2024 at 01:15:45PM +0800, Dawei Li wrote:
> In general it's preferable to avoid placing cpumasks on the stack, as
> for large values of NR_CPUS these can consume significant amounts of
> stack space and make stack overflows more likely.
> 
> Since the cpumask var resides in __init function, which means it's free
> of any concurrenct access, it can be safely marked with static to get
> rid of allocation on stack.
> 
> while at it, mark it with __initdata to keep it from persistently
> consumed memory.

I do not see the need for this - it does not fix a bug and it
complicates things.
If the size is a real concern the normal pattern is to allocate
and not declare it __initdata.

Yes - __initdata is used in some place.
I suggest to leave it as is unless we are fixing a real bug here.

	Sam

> 
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> ---
>  arch/sparc/mm/init_64.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
> index 1ca9054d9b97..088d9c103dcc 100644
> --- a/arch/sparc/mm/init_64.c
> +++ b/arch/sparc/mm/init_64.c
> @@ -1438,7 +1438,7 @@ static int __init numa_attach_mlgroup(struct mdesc_handle *md, u64 grp,
>  static int __init numa_parse_mdesc_group(struct mdesc_handle *md, u64 grp,
>  					 int index)
>  {
> -	cpumask_t mask;
> +	static cpumask_t mask __initdata;
>  	int cpu;
>  
>  	numa_parse_mdesc_group_cpus(md, grp, &mask);
> -- 
> 2.27.0

  reply	other threads:[~2024-04-20  8:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20  5:15 [PATCH v2 0/7] Remove onstack cpumask var for sparc Dawei Li
2024-04-20  5:15 ` [PATCH v2 1/7] sparc/srmmu: Remove on-stack cpumask var Dawei Li
2024-04-20  7:58   ` Sam Ravnborg
2024-04-22  5:46     ` Dawei Li
2024-04-20  5:15 ` [PATCH v2 2/7] sparc/irq: " Dawei Li
2024-04-20  8:22   ` Sam Ravnborg
2024-04-20  5:15 ` [PATCH v2 3/7] sparc/of: " Dawei Li
2024-04-20  8:23   ` Sam Ravnborg
2024-04-20  5:15 ` [PATCH v2 4/7] sparc/pci_msi: " Dawei Li
2024-04-20  8:23   ` Sam Ravnborg
2024-04-20  5:15 ` [PATCH v2 5/7] sparc: " Dawei Li
2024-04-20  8:28   ` Sam Ravnborg [this message]
2024-04-22  5:49     ` Dawei Li
2024-04-20  5:15 ` [PATCH v2 6/7] sparc/leon: " Dawei Li
2024-04-20  8:32   ` Sam Ravnborg
2024-04-22  6:15     ` Dawei Li
2024-04-20  5:15 ` [PATCH v2 7/7] sparc/smp: " Dawei Li
2024-04-20 11:42   ` Sam Ravnborg
2024-04-22  6:19     ` Dawei Li

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=20240420082805.GE614130@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=dawei.li@shingroup.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.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 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.