[PATCH v2 1/5] perf/amd/ibs: Account interrupt for discarded samples

Ravi Bangoria posted 5 patches 1 month, 2 weeks ago
[PATCH v2 1/5] perf/amd/ibs: Account interrupt for discarded samples
Posted by Ravi Bangoria 1 month, 2 weeks ago
Add interrupt throttling accounting for below cases:

  o IBS Op PMU: A software filter (in addition to the hardware filter)
    drops samples whose load latency is below the user-specified
    threshold.

  o IBS Fetch PMU: Samples discarded due to the zero-RIP erratum (#1197).

Although these samples are discarded, the NMI cost is still incurred, so
they should be counted for interrupt throttling.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
---
 arch/x86/events/amd/ibs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index aca89f23d2e0..705ef43325be 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -1293,8 +1293,10 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
 		 * within [128, 2048] range.
 		 */
 		if (!op_data3.ld_op || !op_data3.dc_miss ||
-		    op_data3.dc_miss_lat <= (event->attr.config1 & 0xFFF))
+		    op_data3.dc_miss_lat <= (event->attr.config1 & 0xFFF)) {
+			throttle = perf_event_account_interrupt(event);
 			goto out;
+		}
 	}
 
 	/*
@@ -1326,8 +1328,10 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
 		regs.flags &= ~PERF_EFLAGS_EXACT;
 	} else {
 		/* Workaround for erratum #1197 */
-		if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
+		if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1])) {
+			throttle = perf_event_account_interrupt(event);
 			goto out;
+		}
 
 		set_linear_ip(&regs, ibs_data.regs[1]);
 		regs.flags |= PERF_EFLAGS_EXACT;
-- 
2.43.0
Re: [PATCH v2 1/5] perf/amd/ibs: Account interrupt for discarded samples
Posted by Michael Petlan 1 month, 1 week ago
Hi Ravi,

On Mon, 16 Feb 2026, Ravi Bangoria wrote:
> Add interrupt throttling accounting for below cases:
> 
>   o IBS Op PMU: A software filter (in addition to the hardware filter)
>     drops samples whose load latency is below the user-specified
>     threshold.
> 
>   o IBS Fetch PMU: Samples discarded due to the zero-RIP erratum (#1197).
> 
> Although these samples are discarded, the NMI cost is still incurred, so
> they should be counted for interrupt throttling.
> 

Maybe worth tagging

Fixes: 26db2e0c51fe83e1dd852c1321407835b481806e ("perf/x86/amd/ibs: Work around erratum #1197")
Fixes: d20610c19b4a22bc69085b7eb7a02741d51de30e ("perf/amd/ibs: Add support for OP Load Latency Filtering")

?

Cheers,
Michael

> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
> ---
>  arch/x86/events/amd/ibs.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index aca89f23d2e0..705ef43325be 100644
> --- a/arch/x86/events/amd/ibs.c
> +++ b/arch/x86/events/amd/ibs.c
> @@ -1293,8 +1293,10 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
>  		 * within [128, 2048] range.
>  		 */
>  		if (!op_data3.ld_op || !op_data3.dc_miss ||
> -		    op_data3.dc_miss_lat <= (event->attr.config1 & 0xFFF))
> +		    op_data3.dc_miss_lat <= (event->attr.config1 & 0xFFF)) {
> +			throttle = perf_event_account_interrupt(event);
>  			goto out;
> +		}
>  	}
>  
>  	/*
> @@ -1326,8 +1328,10 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
>  		regs.flags &= ~PERF_EFLAGS_EXACT;
>  	} else {
>  		/* Workaround for erratum #1197 */
> -		if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
> +		if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1])) {
> +			throttle = perf_event_account_interrupt(event);
>  			goto out;
> +		}
>  
>  		set_linear_ip(&regs, ibs_data.regs[1]);
>  		regs.flags |= PERF_EFLAGS_EXACT;
> -- 
> 2.43.0
> 
> 
>
Re: [PATCH v2 1/5] perf/amd/ibs: Account interrupt for discarded samples
Posted by Ravi Bangoria 1 month, 1 week ago
Hi Michael,

>> Add interrupt throttling accounting for below cases:
>>
>>   o IBS Op PMU: A software filter (in addition to the hardware filter)
>>     drops samples whose load latency is below the user-specified
>>     threshold.
>>
>>   o IBS Fetch PMU: Samples discarded due to the zero-RIP erratum (#1197).
>>
>> Although these samples are discarded, the NMI cost is still incurred, so
>> they should be counted for interrupt throttling.
>>
> 
> Maybe worth tagging
> 
> Fixes: 26db2e0c51fe83e1dd852c1321407835b481806e ("perf/x86/amd/ibs: Work around erratum #1197")
> Fixes: d20610c19b4a22bc69085b7eb7a02741d51de30e ("perf/amd/ibs: Add support for OP Load Latency Filtering")

Yes, makes sense.

Ingo / Peter, Please let me know if you want me to respin.

Thanks,
Ravi
Re: [PATCH v2 1/5] perf/amd/ibs: Account interrupt for discarded samples
Posted by Peter Zijlstra 1 month ago
On Tue, Feb 24, 2026 at 01:41:54PM +0530, Ravi Bangoria wrote:
> Hi Michael,
> 
> >> Add interrupt throttling accounting for below cases:
> >>
> >>   o IBS Op PMU: A software filter (in addition to the hardware filter)
> >>     drops samples whose load latency is below the user-specified
> >>     threshold.
> >>
> >>   o IBS Fetch PMU: Samples discarded due to the zero-RIP erratum (#1197).
> >>
> >> Although these samples are discarded, the NMI cost is still incurred, so
> >> they should be counted for interrupt throttling.
> >>
> > 
> > Maybe worth tagging
> > 
> > Fixes: 26db2e0c51fe83e1dd852c1321407835b481806e ("perf/x86/amd/ibs: Work around erratum #1197")
> > Fixes: d20610c19b4a22bc69085b7eb7a02741d51de30e ("perf/amd/ibs: Add support for OP Load Latency Filtering")
> 
> Yes, makes sense.
> 
> Ingo / Peter, Please let me know if you want me to respin.

I've added them. Thanks!
[tip: perf/core] perf/amd/ibs: Account interrupt for discarded samples
Posted by tip-bot2 for Ravi Bangoria 1 month ago
The following commit has been merged into the perf/core branch of tip:

Commit-ID:     01336b5559785a136de1cac49705f63a70a755bc
Gitweb:        https://git.kernel.org/tip/01336b5559785a136de1cac49705f63a70a755bc
Author:        Ravi Bangoria <ravi.bangoria@amd.com>
AuthorDate:    Mon, 16 Feb 2026 04:22:12 
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 27 Feb 2026 16:40:22 +01:00

perf/amd/ibs: Account interrupt for discarded samples

Add interrupt throttling accounting for below cases:

  o IBS Op PMU: A software filter (in addition to the hardware filter)
    drops samples whose load latency is below the user-specified
    threshold.

  o IBS Fetch PMU: Samples discarded due to the zero-RIP erratum (#1197).

Although these samples are discarded, the NMI cost is still incurred, so
they should be counted for interrupt throttling.

Fixes: 26db2e0c51fe83e1dd852c1321407835b481806e ("perf/x86/amd/ibs: Work around erratum #1197")
Fixes: d20610c19b4a22bc69085b7eb7a02741d51de30e ("perf/amd/ibs: Add support for OP Load Latency Filtering")
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://patch.msgid.link/20260216042216.1440-2-ravi.bangoria@amd.com
---
 arch/x86/events/amd/ibs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index aca89f2..705ef43 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -1293,8 +1293,10 @@ fail:
 		 * within [128, 2048] range.
 		 */
 		if (!op_data3.ld_op || !op_data3.dc_miss ||
-		    op_data3.dc_miss_lat <= (event->attr.config1 & 0xFFF))
+		    op_data3.dc_miss_lat <= (event->attr.config1 & 0xFFF)) {
+			throttle = perf_event_account_interrupt(event);
 			goto out;
+		}
 	}
 
 	/*
@@ -1326,8 +1328,10 @@ fail:
 		regs.flags &= ~PERF_EFLAGS_EXACT;
 	} else {
 		/* Workaround for erratum #1197 */
-		if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
+		if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1])) {
+			throttle = perf_event_account_interrupt(event);
 			goto out;
+		}
 
 		set_linear_ip(&regs, ibs_data.regs[1]);
 		regs.flags |= PERF_EFLAGS_EXACT;