2021-09-10 18:45:42

by Tim Gardner

[permalink] [raw]
Subject: [PATCH] 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: [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]>
Cc: [email protected]
Signed-off-by: Tim Gardner <[email protected]>
---
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


2021-09-15 07:14:59

by Giovanni Gherdovich

[permalink] [raw]
Subject: Re: [PATCH] x86/smp: Unused value freq_scale

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 <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: [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]>
> Cc: [email protected]
> Signed-off-by: Tim Gardner <[email protected]>
> ---
> 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 <[email protected]>


Thanks,
Giovanni

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

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.

Signed-off-by: Tim Gardner <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Giovanni Gherdovich <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
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;