Skip to contentSkip to conversation

x86/smp: Unused value freq_scale

PATCH Applied Tim Gardner 3 participants 3 messages Sep 10, 2021 – Sep 17, 2021 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/smp: Unused value 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.

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

Fix this by removing the variable initializer.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Giovanni Gherdovich <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Vitaly Kuznetsov <[email protected]>
Cc Alison Schofield <[email protected]>
Cc Nathan Fontenot <[email protected]>
Cc Balbir Singh <[email protected]>
---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +1 -1
index 85f6e242b6b4..c453b825a57f 100644
@@ -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;
 
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Tim Gardner

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 <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Giovanni Gherdovich <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Vitaly Kuznetsov <[email protected]>
Cc Alison Schofield <[email protected]>
Cc Nathan Fontenot <[email protected]>
Cc Balbir Singh <[email protected]>
---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +0 -0
index 85f6e242b6b4..c453b825a57f 100644

arch/x86/kernel/smpboot.c DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE; · line 2172

Quoted 8 lines
arch/x86/kernel/smpboot.c +1 -1
@@ -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;
 

Thanks,
Giovanni

merge bot Applied
#2 lore raw

[tip: x86/cleanups] x86/smp: Remove unnecessary assignment to local var freq_scale

In reply to Tim Gardner
The following commit has been merged into the x86/cleanups branch of tip:

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 <[email protected]>
AuthorDate:    Fri, 10 Sep 2021 12:44:05 -06:00
Committer:     Borislav Petkov <[email protected]>
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.

---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +1 -1
index 85f6e24..c453b82 100644
@@ -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;