All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/smp: Unused value freq_scale
@ 2021-09-10 18:44 Tim Gardner
  2021-09-15  7:12 ` Giovanni Gherdovich
  2021-09-17 19:27 ` [tip: x86/cleanups] x86/smp: Remove unnecessary assignment to local var freq_scale tip-bot2 for Tim Gardner
  0 siblings, 2 replies; 3+ messages in thread
From: Tim Gardner @ 2021-09-10 18:44 UTC (permalink / raw)
  To: x86
  Cc: tim.gardner, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, Peter Zijlstra (Intel),
	Giovanni Gherdovich, Rafael J. Wysocki, Vitaly Kuznetsov,
	Alison Schofield, Nathan Fontenot, Balbir Singh, linux-kernel

Coverity warns of an unused value in arch_scale_freq_tick().

CID 100778 (#1 of 1): Unused value (UNUSED_VALUE)
assigned_value: Assigning value 1024ULL to freq_scale here, but that stored
value is overwritten before it can be used.

e2b0d619b400a ("x86, sched: check for counters overflow in frequency invariant
accounting") introduced this warning.

Fix this by removing the variable initializer.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Nathan Fontenot <nathan.fontenot@amd.com>
Cc: Balbir Singh <sblbir@amazon.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 85f6e242b6b4..c453b825a57f 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -2166,7 +2166,7 @@ DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE;
 
 void arch_scale_freq_tick(void)
 {
-	u64 freq_scale = SCHED_CAPACITY_SCALE;
+	u64 freq_scale;
 	u64 aperf, mperf;
 	u64 acnt, mcnt;
 
-- 
2.33.0


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

* Re: [PATCH] x86/smp: Unused value freq_scale
  2021-09-10 18:44 [PATCH] x86/smp: Unused value freq_scale Tim Gardner
@ 2021-09-15  7:12 ` Giovanni Gherdovich
  2021-09-17 19:27 ` [tip: x86/cleanups] x86/smp: Remove unnecessary assignment to local var freq_scale tip-bot2 for Tim Gardner
  1 sibling, 0 replies; 3+ messages in thread
From: Giovanni Gherdovich @ 2021-09-15  7:12 UTC (permalink / raw)
  To: Tim Gardner, x86
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	Peter Zijlstra (Intel),
	Rafael J. Wysocki, Vitaly Kuznetsov, Alison Schofield,
	Nathan Fontenot, Balbir Singh, linux-kernel

On Fri, 2021-09-10 at 12:44 -0600, Tim Gardner wrote:
> Coverity warns of an unused value in arch_scale_freq_tick().
> 
> CID 100778 (#1 of 1): Unused value (UNUSED_VALUE)
> assigned_value: Assigning value 1024ULL to freq_scale here, but that stored
> value is overwritten before it can be used.
> 
> e2b0d619b400a ("x86, sched: check for counters overflow in frequency invariant
> accounting") introduced this warning.
> 
> Fix this by removing the variable initializer.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: x86@kernel.org
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Nathan Fontenot <nathan.fontenot@amd.com>
> Cc: Balbir Singh <sblbir@amazon.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  arch/x86/kernel/smpboot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 85f6e242b6b4..c453b825a57f 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -2166,7 +2166,7 @@ DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE;
>  
>  void arch_scale_freq_tick(void)
>  {
> -	u64 freq_scale = SCHED_CAPACITY_SCALE;
> +	u64 freq_scale;
>  	u64 aperf, mperf;
>  	u64 acnt, mcnt;
>  

Reviewed-by: Giovanni Gherdovich <ggherdovich@suse.cz>


Thanks,
Giovanni


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

* [tip: x86/cleanups] x86/smp: Remove unnecessary assignment to local var freq_scale
  2021-09-10 18:44 [PATCH] x86/smp: Unused value freq_scale Tim Gardner
  2021-09-15  7:12 ` Giovanni Gherdovich
@ 2021-09-17 19:27 ` tip-bot2 for Tim Gardner
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Tim Gardner @ 2021-09-17 19:27 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Tim Gardner, Borislav Petkov, Giovanni Gherdovich, x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     85784470efa2d5733e86679ba05d310ece81b20f
Gitweb:        https://git.kernel.org/tip/85784470efa2d5733e86679ba05d310ece81b20f
Author:        Tim Gardner <tim.gardner@canonical.com>
AuthorDate:    Fri, 10 Sep 2021 12:44:05 -06:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 17 Sep 2021 21:20:34 +02:00

x86/smp: Remove unnecessary assignment to local var freq_scale

Coverity warns of an unused value in arch_scale_freq_tick():

  CID 100778 (#1 of 1): Unused value (UNUSED_VALUE)
  assigned_value: Assigning value 1024ULL to freq_scale here, but that stored
  value is overwritten before it can be used.

It was introduced by commit:

  e2b0d619b400a ("x86, sched: check for counters overflow in frequency invariant accounting")

Remove the variable initializer.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Giovanni Gherdovich <ggherdovich@suse.cz>
Link: https://lkml.kernel.org/r/20210910184405.24422-1-tim.gardner@canonical.com
---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 85f6e24..c453b82 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -2166,7 +2166,7 @@ DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE;
 
 void arch_scale_freq_tick(void)
 {
-	u64 freq_scale = SCHED_CAPACITY_SCALE;
+	u64 freq_scale;
 	u64 aperf, mperf;
 	u64 acnt, mcnt;
 

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

end of thread, other threads:[~2021-09-17 19:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 18:44 [PATCH] x86/smp: Unused value freq_scale Tim Gardner
2021-09-15  7:12 ` Giovanni Gherdovich
2021-09-17 19:27 ` [tip: x86/cleanups] x86/smp: Remove unnecessary assignment to local var freq_scale tip-bot2 for Tim Gardner

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.