Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] perf/x86/intel: Don't clear perf metrics overflow bit" failed to apply to 6.12-stable tree
@ 2025-04-21 14:10 gregkh
  2025-09-06 14:38 ` [PATCH 6.12.y] perf/x86/intel: Don't clear perf metrics overflow bit unconditionally Sasha Levin
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2025-04-21 14:10 UTC (permalink / raw)
  To: dapeng1.mi, kan.liang, mingo, peterz; +Cc: stable


The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x a5f5e1238f4ff919816f69e77d2537a48911767b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025042126-outgrow-kiln-e518@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a5f5e1238f4ff919816f69e77d2537a48911767b Mon Sep 17 00:00:00 2001
From: Dapeng Mi <dapeng1.mi@linux.intel.com>
Date: Tue, 15 Apr 2025 10:41:34 +0000
Subject: [PATCH] perf/x86/intel: Don't clear perf metrics overflow bit
 unconditionally

The below code would always unconditionally clear other status bits like
perf metrics overflow bit once PEBS buffer overflows:

        status &= intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;

This is incorrect. Perf metrics overflow bit should be cleared only when
fixed counter 3 in PEBS counter group. Otherwise perf metrics overflow
could be missed to handle.

Closes: https://lore.kernel.org/all/20250225110012.GK31462@noisy.programming.kicks-ass.net/
Fixes: 7b2c05a15d29 ("perf/x86/intel: Generic support for hardware TopDown metrics")
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250415104135.318169-1-dapeng1.mi@linux.intel.com

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 09d2d66c9f21..2b70a3adde2f 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3049,7 +3049,6 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
 	int bit;
 	int handled = 0;
-	u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl);
 
 	inc_irq_stat(apic_perf_irqs);
 
@@ -3093,7 +3092,6 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 		handled++;
 		x86_pmu_handle_guest_pebs(regs, &data);
 		static_call(x86_pmu_drain_pebs)(regs, &data);
-		status &= intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;
 
 		/*
 		 * PMI throttle may be triggered, which stops the PEBS event.
@@ -3104,6 +3102,15 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 		 */
 		if (pebs_enabled != cpuc->pebs_enabled)
 			wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
+
+		/*
+		 * Above PEBS handler (PEBS counters snapshotting) has updated fixed
+		 * counter 3 and perf metrics counts if they are in counter group,
+		 * unnecessary to update again.
+		 */
+		if (cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS] &&
+		    is_pebs_counter_event_group(cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS]))
+			status &= ~GLOBAL_STATUS_PERF_METRICS_OVF_BIT;
 	}
 
 	/*
@@ -3123,6 +3130,8 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 		static_call(intel_pmu_update_topdown_event)(NULL, NULL);
 	}
 
+	status &= hybrid(cpuc->pmu, intel_ctrl);
+
 	/*
 	 * Checkpointed counters can lead to 'spurious' PMIs because the
 	 * rollback caused by the PMI will have cleared the overflow status


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

* [PATCH 6.12.y] perf/x86/intel: Don't clear perf metrics overflow bit unconditionally
  2025-04-21 14:10 FAILED: patch "[PATCH] perf/x86/intel: Don't clear perf metrics overflow bit" failed to apply to 6.12-stable tree gregkh
@ 2025-09-06 14:38 ` Sasha Levin
  2025-09-07  7:43   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2025-09-06 14:38 UTC (permalink / raw)
  To: stable
  Cc: Dapeng Mi, Peter Zijlstra (Intel), Ingo Molnar, Kan Liang,
	Sasha Levin

From: Dapeng Mi <dapeng1.mi@linux.intel.com>

[ Upstream commit a5f5e1238f4ff919816f69e77d2537a48911767b ]

The below code would always unconditionally clear other status bits like
perf metrics overflow bit once PEBS buffer overflows:

        status &= intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;

This is incorrect. Perf metrics overflow bit should be cleared only when
fixed counter 3 in PEBS counter group. Otherwise perf metrics overflow
could be missed to handle.

Closes: https://lore.kernel.org/all/20250225110012.GK31462@noisy.programming.kicks-ass.net/
Fixes: 7b2c05a15d29 ("perf/x86/intel: Generic support for hardware TopDown metrics")
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250415104135.318169-1-dapeng1.mi@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/x86/events/intel/core.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 5e43d390f7a3d..063147d7161b6 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3029,7 +3029,6 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
 	int bit;
 	int handled = 0;
-	u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl);
 
 	inc_irq_stat(apic_perf_irqs);
 
@@ -3073,7 +3072,6 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 		handled++;
 		x86_pmu_handle_guest_pebs(regs, &data);
 		static_call(x86_pmu_drain_pebs)(regs, &data);
-		status &= intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;
 
 		/*
 		 * PMI throttle may be triggered, which stops the PEBS event.
@@ -3084,6 +3082,15 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 		 */
 		if (pebs_enabled != cpuc->pebs_enabled)
 			wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
+
+		/*
+		 * Above PEBS handler (PEBS counters snapshotting) has updated fixed
+		 * counter 3 and perf metrics counts if they are in counter group,
+		 * unnecessary to update again.
+		 */
+		if (cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS] &&
+		    is_pebs_counter_event_group(cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS]))
+			status &= ~GLOBAL_STATUS_PERF_METRICS_OVF_BIT;
 	}
 
 	/*
@@ -3103,6 +3110,8 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
 		static_call(intel_pmu_update_topdown_event)(NULL);
 	}
 
+	status &= hybrid(cpuc->pmu, intel_ctrl);
+
 	/*
 	 * Checkpointed counters can lead to 'spurious' PMIs because the
 	 * rollback caused by the PMI will have cleared the overflow status
-- 
2.51.0


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

* Re: [PATCH 6.12.y] perf/x86/intel: Don't clear perf metrics overflow bit unconditionally
  2025-09-06 14:38 ` [PATCH 6.12.y] perf/x86/intel: Don't clear perf metrics overflow bit unconditionally Sasha Levin
@ 2025-09-07  7:43   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-09-07  7:43 UTC (permalink / raw)
  To: Sasha Levin
  Cc: stable, Dapeng Mi, Peter Zijlstra (Intel), Ingo Molnar, Kan Liang

On Sat, Sep 06, 2025 at 10:38:26AM -0400, Sasha Levin wrote:
> From: Dapeng Mi <dapeng1.mi@linux.intel.com>
> 
> [ Upstream commit a5f5e1238f4ff919816f69e77d2537a48911767b ]
> 
> The below code would always unconditionally clear other status bits like
> perf metrics overflow bit once PEBS buffer overflows:
> 
>         status &= intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;
> 
> This is incorrect. Perf metrics overflow bit should be cleared only when
> fixed counter 3 in PEBS counter group. Otherwise perf metrics overflow
> could be missed to handle.
> 
> Closes: https://lore.kernel.org/all/20250225110012.GK31462@noisy.programming.kicks-ass.net/
> Fixes: 7b2c05a15d29 ("perf/x86/intel: Generic support for hardware TopDown metrics")
> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/20250415104135.318169-1-dapeng1.mi@linux.intel.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  arch/x86/events/intel/core.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index 5e43d390f7a3d..063147d7161b6 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -3029,7 +3029,6 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
>  	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
>  	int bit;
>  	int handled = 0;
> -	u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl);
>  
>  	inc_irq_stat(apic_perf_irqs);
>  
> @@ -3073,7 +3072,6 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
>  		handled++;
>  		x86_pmu_handle_guest_pebs(regs, &data);
>  		static_call(x86_pmu_drain_pebs)(regs, &data);
> -		status &= intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;
>  
>  		/*
>  		 * PMI throttle may be triggered, which stops the PEBS event.
> @@ -3084,6 +3082,15 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
>  		 */
>  		if (pebs_enabled != cpuc->pebs_enabled)
>  			wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
> +
> +		/*
> +		 * Above PEBS handler (PEBS counters snapshotting) has updated fixed
> +		 * counter 3 and perf metrics counts if they are in counter group,
> +		 * unnecessary to update again.
> +		 */
> +		if (cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS] &&
> +		    is_pebs_counter_event_group(cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS]))
> +			status &= ~GLOBAL_STATUS_PERF_METRICS_OVF_BIT;
>  	}
>  
>  	/*
> @@ -3103,6 +3110,8 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
>  		static_call(intel_pmu_update_topdown_event)(NULL);
>  	}
>  
> +	status &= hybrid(cpuc->pmu, intel_ctrl);
> +
>  	/*
>  	 * Checkpointed counters can lead to 'spurious' PMIs because the
>  	 * rollback caused by the PMI will have cleared the overflow status
> -- 
> 2.51.0
> 
> 

This breaks the build:

arch/x86/events/intel/core.c: In function ‘handle_pmi_common’:
arch/x86/events/intel/core.c:3092:21: error: implicit declaration of function ‘is_pebs_counter_event_group’ [-Wimplicit-function-declaration]
 3092 |                     is_pebs_counter_event_group(cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS]))
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

so I'll not apply it.

thanks,

greg k-h

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

end of thread, other threads:[~2025-09-07  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 14:10 FAILED: patch "[PATCH] perf/x86/intel: Don't clear perf metrics overflow bit" failed to apply to 6.12-stable tree gregkh
2025-09-06 14:38 ` [PATCH 6.12.y] perf/x86/intel: Don't clear perf metrics overflow bit unconditionally Sasha Levin
2025-09-07  7:43   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox