linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: Mark core_vpe_count() as __init
@ 2023-06-15 16:21 Nathan Chancellor
  2023-06-15 19:42 ` Nick Desaulniers
  2023-06-20 12:50 ` Thomas Bogendoerfer
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-06-15 16:21 UTC (permalink / raw)
  To: tsbogend
  Cc: ndesaulniers, trix, jiaxun.yang, linux-mips, llvm, patches,
	Nathan Chancellor

After commit 96cb8ae28c65 ("MIPS: Rework smt cmdline parameters"),
modpost complains when building with clang:

  WARNING: modpost: vmlinux.o: section mismatch in reference: core_vpe_count (section: .text) -> smp_max_threads (section: .init.data)

This warning occurs when core_vpe_count() is not inlined, as it appears
that a non-init function is referring to an init symbol. However, this
is not a problem in practice because core_vpe_count() is only called
from __init functions, cps_smp_setup() and cps_prepare_cpus().

Resolve the warning by marking core_vpe_count() as __init, as it is only
called in an init context so it can refer to init functions and symbols
and have its memory freed on boot.

Fixes: 96cb8ae28c65 ("MIPS: Rework smt cmdline parameters")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/mips/kernel/smp-cps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index bea6a13ea464..92575222713b 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -29,7 +29,7 @@ static DECLARE_BITMAP(core_power, NR_CPUS);
 
 struct core_boot_config *mips_cps_core_bootcfg;
 
-static unsigned core_vpe_count(unsigned int cluster, unsigned core)
+static unsigned __init core_vpe_count(unsigned int cluster, unsigned core)
 {
 	return min(smp_max_threads, mips_cps_numvps(cluster, core));
 }

---
base-commit: 5cad8323040bb8d47e130c10ea4dcb7175c7602a
change-id: 20230615-mips-mark-core_vpe_count-as-init-600dc73e367d

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: Mark core_vpe_count() as __init
  2023-06-15 16:21 [PATCH] MIPS: Mark core_vpe_count() as __init Nathan Chancellor
@ 2023-06-15 19:42 ` Nick Desaulniers
  2023-06-20 12:50 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2023-06-15 19:42 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: tsbogend, trix, jiaxun.yang, linux-mips, llvm, patches

On Thu, Jun 15, 2023 at 12:21 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> After commit 96cb8ae28c65 ("MIPS: Rework smt cmdline parameters"),
> modpost complains when building with clang:
>
>   WARNING: modpost: vmlinux.o: section mismatch in reference: core_vpe_count (section: .text) -> smp_max_threads (section: .init.data)
>
> This warning occurs when core_vpe_count() is not inlined, as it appears
> that a non-init function is referring to an init symbol. However, this
> is not a problem in practice because core_vpe_count() is only called
> from __init functions, cps_smp_setup() and cps_prepare_cpus().
>
> Resolve the warning by marking core_vpe_count() as __init, as it is only
> called in an init context so it can refer to init functions and symbols
> and have its memory freed on boot.
>
> Fixes: 96cb8ae28c65 ("MIPS: Rework smt cmdline parameters")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  arch/mips/kernel/smp-cps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
> index bea6a13ea464..92575222713b 100644
> --- a/arch/mips/kernel/smp-cps.c
> +++ b/arch/mips/kernel/smp-cps.c
> @@ -29,7 +29,7 @@ static DECLARE_BITMAP(core_power, NR_CPUS);
>
>  struct core_boot_config *mips_cps_core_bootcfg;
>
> -static unsigned core_vpe_count(unsigned int cluster, unsigned core)
> +static unsigned __init core_vpe_count(unsigned int cluster, unsigned core)
>  {
>         return min(smp_max_threads, mips_cps_numvps(cluster, core));
>  }
>
> ---
> base-commit: 5cad8323040bb8d47e130c10ea4dcb7175c7602a
> change-id: 20230615-mips-mark-core_vpe_count-as-init-600dc73e367d
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: Mark core_vpe_count() as __init
  2023-06-15 16:21 [PATCH] MIPS: Mark core_vpe_count() as __init Nathan Chancellor
  2023-06-15 19:42 ` Nick Desaulniers
@ 2023-06-20 12:50 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2023-06-20 12:50 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: ndesaulniers, trix, jiaxun.yang, linux-mips, llvm, patches

On Thu, Jun 15, 2023 at 09:21:18AM -0700, Nathan Chancellor wrote:
> After commit 96cb8ae28c65 ("MIPS: Rework smt cmdline parameters"),
> modpost complains when building with clang:
> 
>   WARNING: modpost: vmlinux.o: section mismatch in reference: core_vpe_count (section: .text) -> smp_max_threads (section: .init.data)
> 
> This warning occurs when core_vpe_count() is not inlined, as it appears
> that a non-init function is referring to an init symbol. However, this
> is not a problem in practice because core_vpe_count() is only called
> from __init functions, cps_smp_setup() and cps_prepare_cpus().
> 
> Resolve the warning by marking core_vpe_count() as __init, as it is only
> called in an init context so it can refer to init functions and symbols
> and have its memory freed on boot.
> 
> Fixes: 96cb8ae28c65 ("MIPS: Rework smt cmdline parameters")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/mips/kernel/smp-cps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
> index bea6a13ea464..92575222713b 100644
> --- a/arch/mips/kernel/smp-cps.c
> +++ b/arch/mips/kernel/smp-cps.c
> @@ -29,7 +29,7 @@ static DECLARE_BITMAP(core_power, NR_CPUS);
>  
>  struct core_boot_config *mips_cps_core_bootcfg;
>  
> -static unsigned core_vpe_count(unsigned int cluster, unsigned core)
> +static unsigned __init core_vpe_count(unsigned int cluster, unsigned core)
>  {
>  	return min(smp_max_threads, mips_cps_numvps(cluster, core));
>  }
> 
> ---
> base-commit: 5cad8323040bb8d47e130c10ea4dcb7175c7602a
> change-id: 20230615-mips-mark-core_vpe_count-as-init-600dc73e367d
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
> 

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-20 12:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15 16:21 [PATCH] MIPS: Mark core_vpe_count() as __init Nathan Chancellor
2023-06-15 19:42 ` Nick Desaulniers
2023-06-20 12:50 ` Thomas Bogendoerfer

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).