Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf/x86/amd/core: always clear status for idx
@ 2023-03-21 11:33 Breno Leitao
  2023-03-21 11:56 ` Sandipan Das
  2023-03-21 12:42 ` Peter Zijlstra
  0 siblings, 2 replies; 5+ messages in thread
From: Breno Leitao @ 2023-03-21 11:33 UTC (permalink / raw)
  To: peterz, mingo, acme, jolsa, namhyung, sandipan.das,
	thomas.lendacky
  Cc: linux-perf-users, x86, leit

The variable 'status' (which contains the unhandled overflow bits) is
not being properly masked in some cases, displaying the following
warning:

  WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270

This seems to be happening because the loop is being continued before
the status bit being unset, in case x86_perf_event_set_period()
returns 0. This is also causing an inconsistency because the "handled"
counter is incremented, but the status bit is not cleaned.

Move the bit cleaning together above, together when the "handled"
counter is incremented.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 arch/x86/events/amd/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 8c45b198b62f..bccea57dee81 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -923,6 +923,7 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
 
 		/* Event overflow */
 		handled++;
+		status &= ~mask;
 		perf_sample_data_init(&data, 0, hwc->last_period);
 
 		if (!x86_perf_event_set_period(event))
@@ -933,8 +934,6 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
 
 		if (perf_event_overflow(event, &data, regs))
 			x86_pmu_stop(event, 0);
-
-		status &= ~mask;
 	}
 
 	/*
-- 
2.34.1


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

* Re: [PATCH] perf/x86/amd/core: always clear status for idx
  2023-03-21 11:33 [PATCH] perf/x86/amd/core: always clear status for idx Breno Leitao
@ 2023-03-21 11:56 ` Sandipan Das
  2023-03-21 12:42 ` Peter Zijlstra
  1 sibling, 0 replies; 5+ messages in thread
From: Sandipan Das @ 2023-03-21 11:56 UTC (permalink / raw)
  To: Breno Leitao
  Cc: linux-perf-users, x86, leit, peterz, mingo, acme, jolsa, namhyung,
	thomas.lendacky

On 3/21/2023 5:03 PM, Breno Leitao wrote:
> The variable 'status' (which contains the unhandled overflow bits) is
> not being properly masked in some cases, displaying the following
> warning:
> 
>   WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270
> 
> This seems to be happening because the loop is being continued before
> the status bit being unset, in case x86_perf_event_set_period()
> returns 0. This is also causing an inconsistency because the "handled"
> counter is incremented, but the status bit is not cleaned.
> 
> Move the bit cleaning together above, together when the "handled"
> counter is incremented.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  arch/x86/events/amd/core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
> index 8c45b198b62f..bccea57dee81 100644
> --- a/arch/x86/events/amd/core.c
> +++ b/arch/x86/events/amd/core.c
> @@ -923,6 +923,7 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
>  
>  		/* Event overflow */
>  		handled++;
> +		status &= ~mask;
>  		perf_sample_data_init(&data, 0, hwc->last_period);
>  
>  		if (!x86_perf_event_set_period(event))
> @@ -933,8 +934,6 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
>  
>  		if (perf_event_overflow(event, &data, regs))
>  			x86_pmu_stop(event, 0);
> -
> -		status &= ~mask;
>  	}
>  
>  	/*

Thanks for fixing this.

Reviewed-by: Sandipan Das <sandipan.das@amd.com>


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

* Re: [PATCH] perf/x86/amd/core: always clear status for idx
  2023-03-21 11:33 [PATCH] perf/x86/amd/core: always clear status for idx Breno Leitao
  2023-03-21 11:56 ` Sandipan Das
@ 2023-03-21 12:42 ` Peter Zijlstra
  2023-03-21 12:56   ` Sandipan Das
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2023-03-21 12:42 UTC (permalink / raw)
  To: Breno Leitao
  Cc: mingo, acme, jolsa, namhyung, sandipan.das, thomas.lendacky,
	linux-perf-users, x86, leit

On Tue, Mar 21, 2023 at 04:33:38AM -0700, Breno Leitao wrote:
> The variable 'status' (which contains the unhandled overflow bits) is
> not being properly masked in some cases, displaying the following
> warning:
> 
>   WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270
> 
> This seems to be happening because the loop is being continued before
> the status bit being unset, in case x86_perf_event_set_period()
> returns 0. This is also causing an inconsistency because the "handled"
> counter is incremented, but the status bit is not cleaned.
> 
> Move the bit cleaning together above, together when the "handled"
> counter is incremented.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Can I get a Fixes: tag so I can consider it for perf/urgent ?

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

* Re: [PATCH] perf/x86/amd/core: always clear status for idx
  2023-03-21 12:42 ` Peter Zijlstra
@ 2023-03-21 12:56   ` Sandipan Das
  2023-03-21 13:43     ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Sandipan Das @ 2023-03-21 12:56 UTC (permalink / raw)
  To: Peter Zijlstra, Breno Leitao
  Cc: mingo, acme, jolsa, namhyung, thomas.lendacky, linux-perf-users,
	x86, leit

On 3/21/2023 6:12 PM, Peter Zijlstra wrote:
> On Tue, Mar 21, 2023 at 04:33:38AM -0700, Breno Leitao wrote:
>> The variable 'status' (which contains the unhandled overflow bits) is
>> not being properly masked in some cases, displaying the following
>> warning:
>>
>>   WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270
>>
>> This seems to be happening because the loop is being continued before
>> the status bit being unset, in case x86_perf_event_set_period()
>> returns 0. This is also causing an inconsistency because the "handled"
>> counter is incremented, but the status bit is not cleaned.
>>
>> Move the bit cleaning together above, together when the "handled"
>> counter is incremented.
>>
>> Signed-off-by: Breno Leitao <leitao@debian.org>
> 
> Can I get a Fixes: tag so I can consider it for perf/urgent ?

That would be

Fixes: 7685665c390d ("perf/x86/amd/core: Add PerfMonV2 overflow handling")


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

* Re: [PATCH] perf/x86/amd/core: always clear status for idx
  2023-03-21 12:56   ` Sandipan Das
@ 2023-03-21 13:43     ` Peter Zijlstra
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2023-03-21 13:43 UTC (permalink / raw)
  To: Sandipan Das
  Cc: Breno Leitao, mingo, acme, jolsa, namhyung, thomas.lendacky,
	linux-perf-users, x86, leit

On Tue, Mar 21, 2023 at 06:26:11PM +0530, Sandipan Das wrote:
> On 3/21/2023 6:12 PM, Peter Zijlstra wrote:
> > On Tue, Mar 21, 2023 at 04:33:38AM -0700, Breno Leitao wrote:
> >> The variable 'status' (which contains the unhandled overflow bits) is
> >> not being properly masked in some cases, displaying the following
> >> warning:
> >>
> >>   WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270
> >>
> >> This seems to be happening because the loop is being continued before
> >> the status bit being unset, in case x86_perf_event_set_period()
> >> returns 0. This is also causing an inconsistency because the "handled"
> >> counter is incremented, but the status bit is not cleaned.
> >>
> >> Move the bit cleaning together above, together when the "handled"
> >> counter is incremented.
> >>
> >> Signed-off-by: Breno Leitao <leitao@debian.org>
> > 
> > Can I get a Fixes: tag so I can consider it for perf/urgent ?
> 
> That would be
> 
> Fixes: 7685665c390d ("perf/x86/amd/core: Add PerfMonV2 overflow handling")
> 

Cheers!

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

end of thread, other threads:[~2023-03-21 13:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-21 11:33 [PATCH] perf/x86/amd/core: always clear status for idx Breno Leitao
2023-03-21 11:56 ` Sandipan Das
2023-03-21 12:42 ` Peter Zijlstra
2023-03-21 12:56   ` Sandipan Das
2023-03-21 13:43     ` Peter Zijlstra

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