[PATCH 01/11] perf/amd/ibs: Throttle interrupts with filtered ldlat samples

Ravi Bangoria posted 11 patches 3 weeks, 3 days ago
[PATCH 01/11] perf/amd/ibs: Throttle interrupts with filtered ldlat samples
Posted by Ravi Bangoria 3 weeks, 3 days ago
IBS NMI handler has a software filter (on top of hardware filter) to
discard samples with load latency value lesser than user requested
threshold. However, since software filter still involves NMI, check
for NMI overhead and throttle the sample rate if needed.

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

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index aca89f23d2e0..96bb0974057f 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;
+		}
 	}
 
 	/*
-- 
2.43.0
Re: [PATCH 01/11] perf/amd/ibs: Throttle interrupts with filtered ldlat samples
Posted by Mi, Dapeng 3 weeks ago
On 1/16/2026 11:34 AM, Ravi Bangoria wrote:
> IBS NMI handler has a software filter (on top of hardware filter) to
> discard samples with load latency value lesser than user requested
> threshold. However, since software filter still involves NMI, check
> for NMI overhead and throttle the sample rate if needed.
>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
> ---
>  arch/x86/events/amd/ibs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index aca89f23d2e0..96bb0974057f 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;
> +		}
>  	}

Not quite familiar with IBS code, but should the below code call the
throttle as well?

        /* Workaround for erratum #1197 */
        if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
            goto out;


>  
>  	/*
Re: [PATCH 01/11] perf/amd/ibs: Throttle interrupts with filtered ldlat samples
Posted by Ravi Bangoria 3 weeks ago
Hi Dapeng,

>> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
>> index aca89f23d2e0..96bb0974057f 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;
>> +		}
>>  	}
> 
> Not quite familiar with IBS code, but should the below code call the
> throttle as well?
> 
>         /* Workaround for erratum #1197 */
>         if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
>             goto out;
> 

Yes, it should. I'll add a patch in next version.

Thanks,
Ravi