All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: perf: no need to initialise statics to 0
@ 2022-05-08  2:23 Jason Wang
  2022-05-09  8:45   ` Mark Rutland
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2022-05-08  2:23 UTC (permalink / raw)
  To: mark.rutland
  Cc: will, catalin.marinas, peterz, mingo, acme, alexander.shishkin,
	jolsa, namhyung, linux-arm-kernel, linux-perf-users,
	linux-kernel, Jason Wang

Static variables do not need to be initialised to 0, because compiler
will initialise all uninitialised statics to 0. Thus, remove the
unneeded initializations.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
 arch/arm64/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index cb69ff1e6138..919fdcf8fce6 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -1226,7 +1226,7 @@ static struct ctl_table armv8_pmu_sysctl_table[] = {
 
 static void armv8_pmu_register_sysctl_table(void)
 {
-	static u32 tbl_registered = 0;
+	static u32 tbl_registered;
 
 	if (!cmpxchg_relaxed(&tbl_registered, 0, 1))
 		register_sysctl("kernel", armv8_pmu_sysctl_table);
-- 
2.35.1



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

* Re: [PATCH] arm64: perf: no need to initialise statics to 0
  2022-05-08  2:23 [PATCH] arm64: perf: no need to initialise statics to 0 Jason Wang
@ 2022-05-09  8:45   ` Mark Rutland
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2022-05-09  8:45 UTC (permalink / raw)
  To: Jason Wang
  Cc: will, catalin.marinas, peterz, mingo, acme, alexander.shishkin,
	jolsa, namhyung, linux-arm-kernel, linux-perf-users,
	linux-kernel

On Sun, May 08, 2022 at 10:23:12AM +0800, Jason Wang wrote:
> Static variables do not need to be initialised to 0, because compiler
> will initialise all uninitialised statics to 0. Thus, remove the
> unneeded initializations.
> 
> Signed-off-by: Jason Wang <wangborong@cdjrlc.com>

I would strongly prefer that we leave this as-is.

There is no problem with explicitly initializing a static variable to 0, and it
clearly aligns with the cmpxchg arguments below. Removing the initialization
makes that *less* clear.

Thanks,
Mark.

> ---
>  arch/arm64/kernel/perf_event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> index cb69ff1e6138..919fdcf8fce6 100644
> --- a/arch/arm64/kernel/perf_event.c
> +++ b/arch/arm64/kernel/perf_event.c
> @@ -1226,7 +1226,7 @@ static struct ctl_table armv8_pmu_sysctl_table[] = {
>  
>  static void armv8_pmu_register_sysctl_table(void)
>  {
> -	static u32 tbl_registered = 0;
> +	static u32 tbl_registered;
>  
>  	if (!cmpxchg_relaxed(&tbl_registered, 0, 1))
>  		register_sysctl("kernel", armv8_pmu_sysctl_table);
> -- 
> 2.35.1
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: perf: no need to initialise statics to 0
@ 2022-05-09  8:45   ` Mark Rutland
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2022-05-09  8:45 UTC (permalink / raw)
  To: Jason Wang
  Cc: will, catalin.marinas, peterz, mingo, acme, alexander.shishkin,
	jolsa, namhyung, linux-arm-kernel, linux-perf-users,
	linux-kernel

On Sun, May 08, 2022 at 10:23:12AM +0800, Jason Wang wrote:
> Static variables do not need to be initialised to 0, because compiler
> will initialise all uninitialised statics to 0. Thus, remove the
> unneeded initializations.
> 
> Signed-off-by: Jason Wang <wangborong@cdjrlc.com>

I would strongly prefer that we leave this as-is.

There is no problem with explicitly initializing a static variable to 0, and it
clearly aligns with the cmpxchg arguments below. Removing the initialization
makes that *less* clear.

Thanks,
Mark.

> ---
>  arch/arm64/kernel/perf_event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> index cb69ff1e6138..919fdcf8fce6 100644
> --- a/arch/arm64/kernel/perf_event.c
> +++ b/arch/arm64/kernel/perf_event.c
> @@ -1226,7 +1226,7 @@ static struct ctl_table armv8_pmu_sysctl_table[] = {
>  
>  static void armv8_pmu_register_sysctl_table(void)
>  {
> -	static u32 tbl_registered = 0;
> +	static u32 tbl_registered;
>  
>  	if (!cmpxchg_relaxed(&tbl_registered, 0, 1))
>  		register_sysctl("kernel", armv8_pmu_sysctl_table);
> -- 
> 2.35.1
> 
> 

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

end of thread, other threads:[~2022-05-09  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-08  2:23 [PATCH] arm64: perf: no need to initialise statics to 0 Jason Wang
2022-05-09  8:45 ` Mark Rutland
2022-05-09  8:45   ` Mark Rutland

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.