linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch/x86/amd: Remove set but not used variable 'active'
@ 2019-11-10  9:44 Zheng Yongjun
  2019-11-11  7:02 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zheng Yongjun @ 2019-11-10  9:44 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin
  Cc: linux-kernel, zhengyongjun3, Hulk Robot

Fixes gcc '-Wunused-but-set-variable' warning:

arch/x86/events/amd/core.c: In function amd_pmu_handle_irq:
arch/x86/events/amd/core.c:656:6: warning: variable active set but not used [-Wunused-but-set-variable]

active is never used, so remove it.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 arch/x86/events/amd/core.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 64c3e70b0556..1ff652a167db 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -653,14 +653,7 @@ static void amd_pmu_disable_event(struct perf_event *event)
 static int amd_pmu_handle_irq(struct pt_regs *regs)
 {
 	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
-	int active, handled;
-
-	/*
-	 * Obtain the active count before calling x86_pmu_handle_irq() since
-	 * it is possible that x86_pmu_handle_irq() may make a counter
-	 * inactive (through x86_pmu_stop).
-	 */
-	active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
+	int handled;
 
 	/* Process any counter overflows */
 	handled = x86_pmu_handle_irq(regs);
-- 
2.23.0


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

* [tip: perf/core] perf/x86/amd: Remove set but not used variable 'active'
  2019-11-10  9:44 [PATCH] arch/x86/amd: Remove set but not used variable 'active' Zheng Yongjun
@ 2019-11-11  7:02 ` tip-bot2 for Zheng Yongjun
  2019-11-11  7:31 ` [PATCH] arch/x86/amd: " Ingo Molnar
  2019-11-11  9:32 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Zheng Yongjun @ 2019-11-11  7:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Hulk Robot, Zheng Yongjun, acme, alexander.shishkin,
	mark.rutland, peterz, Linus Torvalds, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     010fe58de2d5ebb86903f74db4402c474434e08c
Gitweb:        https://git.kernel.org/tip/010fe58de2d5ebb86903f74db4402c474434e08c
Author:        Zheng Yongjun <zhengyongjun3@huawei.com>
AuthorDate:    Sun, 10 Nov 2019 17:44:53 +08:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 11 Nov 2019 08:01:16 +01:00

perf/x86/amd: Remove set but not used variable 'active'

'-Wunused-but-set-variable' triggers this warning:

  arch/x86/events/amd/core.c: In function amd_pmu_handle_irq:
  arch/x86/events/amd/core.c:656:6: warning: variable active set but not used [-Wunused-but-set-variable]

GCC is right, 'active' is not used anymore.

This variable was introduced earlier this year and then removed in:

  df4d29732fdad perf/x86/amd: Change/fix NMI latency mitigation to use a timestamp

[ mingo: Improved the changelog. ]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Cc: <acme@kernel.org>
Cc: <alexander.shishkin@linux.intel.com>
Cc: <mark.rutland@arm.com>
Cc: <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20191110094453.113001-1-zhengyongjun3@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/amd/core.c |  9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 64c3e70..1ff652a 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -653,14 +653,7 @@ static void amd_pmu_disable_event(struct perf_event *event)
 static int amd_pmu_handle_irq(struct pt_regs *regs)
 {
 	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
-	int active, handled;
-
-	/*
-	 * Obtain the active count before calling x86_pmu_handle_irq() since
-	 * it is possible that x86_pmu_handle_irq() may make a counter
-	 * inactive (through x86_pmu_stop).
-	 */
-	active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
+	int handled;
 
 	/* Process any counter overflows */
 	handled = x86_pmu_handle_irq(regs);

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

* Re: [PATCH] arch/x86/amd: Remove set but not used variable 'active'
  2019-11-10  9:44 [PATCH] arch/x86/amd: Remove set but not used variable 'active' Zheng Yongjun
  2019-11-11  7:02 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun
@ 2019-11-11  7:31 ` Ingo Molnar
  2019-11-11  9:32 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2019-11-11  7:31 UTC (permalink / raw)
  To: Zheng Yongjun
  Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin,
	linux-kernel, Hulk Robot


* Zheng Yongjun <zhengyongjun3@huawei.com> wrote:

> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> arch/x86/events/amd/core.c: In function amd_pmu_handle_irq:
> arch/x86/events/amd/core.c:656:6: warning: variable active set but not used [-Wunused-but-set-variable]
> 
> active is never used, so remove it.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  arch/x86/events/amd/core.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
> index 64c3e70b0556..1ff652a167db 100644
> --- a/arch/x86/events/amd/core.c
> +++ b/arch/x86/events/amd/core.c
> @@ -653,14 +653,7 @@ static void amd_pmu_disable_event(struct perf_event *event)
>  static int amd_pmu_handle_irq(struct pt_regs *regs)
>  {
>  	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> -	int active, handled;
> -
> -	/*
> -	 * Obtain the active count before calling x86_pmu_handle_irq() since
> -	 * it is possible that x86_pmu_handle_irq() may make a counter
> -	 * inactive (through x86_pmu_stop).
> -	 */
> -	active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
> +	int handled;
>  
>  	/* Process any counter overflows */
>  	handled = x86_pmu_handle_irq(regs);

I'm sad that not only was this changelog of poor quality (you didn't 
follow title patterns, you didn't explain why the variable went unused, 
etc. etc.), you didn't even *build* the resulting file, which now 
produces a new warning on x86-64-defconfig:

  arch/x86/events/amd/core.c:655:24: warning: unused variable ‘cpuc’ [-Wunused-variable]

I fixed this up, but please be much more careful even with 'trivial' 
patches - we expect them to be perfect.

Thanks,

	Ingo

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

* [tip: perf/core] perf/x86/amd: Remove set but not used variable 'active'
  2019-11-10  9:44 [PATCH] arch/x86/amd: Remove set but not used variable 'active' Zheng Yongjun
  2019-11-11  7:02 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun
  2019-11-11  7:31 ` [PATCH] arch/x86/amd: " Ingo Molnar
@ 2019-11-11  9:32 ` tip-bot2 for Zheng Yongjun
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Zheng Yongjun @ 2019-11-11  9:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Hulk Robot, Zheng Yongjun, acme, alexander.shishkin,
	mark.rutland, peterz, Linus Torvalds, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     8f05c1ff8bfb8cbae0898e5dc6791927d1e5c503
Gitweb:        https://git.kernel.org/tip/8f05c1ff8bfb8cbae0898e5dc6791927d1e5c503
Author:        Zheng Yongjun <zhengyongjun3@huawei.com>
AuthorDate:    Sun, 10 Nov 2019 17:44:53 +08:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 11 Nov 2019 08:31:55 +01:00

perf/x86/amd: Remove set but not used variable 'active'

'-Wunused-but-set-variable' triggers this warning:

  arch/x86/events/amd/core.c: In function amd_pmu_handle_irq:
  arch/x86/events/amd/core.c:656:6: warning: variable active set but not used [-Wunused-but-set-variable]

GCC is right, 'active' is not used anymore.

This variable was introduced earlier this year and then removed in:

  df4d29732fdad perf/x86/amd: Change/fix NMI latency mitigation to use a timestamp

[ mingo: Improved the changelog, fixed build warning caused by this fix, improved surrounding code. ]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Cc: <acme@kernel.org>
Cc: <alexander.shishkin@linux.intel.com>
Cc: <mark.rutland@arm.com>
Cc: <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20191110094453.113001-1-zhengyongjun3@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/amd/core.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 64c3e70..a7752cd 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -652,15 +652,7 @@ static void amd_pmu_disable_event(struct perf_event *event)
  */
 static int amd_pmu_handle_irq(struct pt_regs *regs)
 {
-	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
-	int active, handled;
-
-	/*
-	 * Obtain the active count before calling x86_pmu_handle_irq() since
-	 * it is possible that x86_pmu_handle_irq() may make a counter
-	 * inactive (through x86_pmu_stop).
-	 */
-	active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX);
+	int handled;
 
 	/* Process any counter overflows */
 	handled = x86_pmu_handle_irq(regs);
@@ -670,8 +662,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)
 	 * NMIs will be claimed if arriving within that window.
 	 */
 	if (handled) {
-		this_cpu_write(perf_nmi_tstamp,
-			       jiffies + perf_nmi_window);
+		this_cpu_write(perf_nmi_tstamp, jiffies + perf_nmi_window);
 
 		return handled;
 	}

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

end of thread, other threads:[~2019-11-11  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-10  9:44 [PATCH] arch/x86/amd: Remove set but not used variable 'active' Zheng Yongjun
2019-11-11  7:02 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun
2019-11-11  7:31 ` [PATCH] arch/x86/amd: " Ingo Molnar
2019-11-11  9:32 ` [tip: perf/core] perf/x86/amd: " tip-bot2 for Zheng Yongjun

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