perf/x86/amd: Reject branch stack for IBS events

Message ID 20230602194513.1589179-1-namhyung@kernel.org
State New
Headers
Series perf/x86/amd: Reject branch stack for IBS events |

Commit Message

Namhyung Kim June 2, 2023, 7:45 p.m. UTC
  The AMD IBS PMU doesn't handle branch stacks, so it should not accept
events with brstack.

Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 arch/x86/events/amd/ibs.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Ravi Bangoria June 6, 2023, 4:38 a.m. UTC | #1
On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
> events with brstack.
> 
> Cc: Ravi Bangoria <ravi.bangoria@amd.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>

Thanks!
  
Arnaldo Carvalho de Melo Nov. 23, 2023, 2:45 p.m. UTC | #2
Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
> > The AMD IBS PMU doesn't handle branch stacks, so it should not accept
> > events with brstack.
> > 
> > Cc: Ravi Bangoria <ravi.bangoria@amd.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>

It seems this patch was not merged, can you please check?

- Arnaldo
  
Ravi Bangoria Nov. 24, 2023, 4 a.m. UTC | #3
On 23-Nov-23 8:15 PM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
>> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
>>> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
>>> events with brstack.
>>>
>>> Cc: Ravi Bangoria <ravi.bangoria@amd.com>
>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>
>> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
> 
> It seems this patch was not merged, can you please check?

Right. And it does not apply cleanly on peterz/queue.git/perf/core, since
surrounding code has changed.

Thanks,
Ravi
  
Arnaldo Carvalho de Melo Nov. 27, 2023, 2:32 p.m. UTC | #4
Em Fri, Nov 24, 2023 at 09:30:37AM +0530, Ravi Bangoria escreveu:
> On 23-Nov-23 8:15 PM, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
> >> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
> >>> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
> >>> events with brstack.
> >>>
> >>> Cc: Ravi Bangoria <ravi.bangoria@amd.com>
> >>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> >>
> >> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
> > 
> > It seems this patch was not merged, can you please check?
> 
> Right. And it does not apply cleanly on peterz/queue.git/perf/core, since
> surrounding code has changed.

Can you please refresh it if PeterZ has nothing against?

- Arnaldo
  
Ravi Bangoria Nov. 30, 2023, 6:28 a.m. UTC | #5
On 27-Nov-23 8:02 PM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Nov 24, 2023 at 09:30:37AM +0530, Ravi Bangoria escreveu:
>> On 23-Nov-23 8:15 PM, Arnaldo Carvalho de Melo wrote:
>>> Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
>>>> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
>>>>> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
>>>>> events with brstack.
>>>>>
>>>>> Cc: Ravi Bangoria <ravi.bangoria@amd.com>
>>>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>>>
>>>> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
>>>
>>> It seems this patch was not merged, can you please check?
>>
>> Right. And it does not apply cleanly on peterz/queue.git/perf/core, since
>> surrounding code has changed.
> 
> Can you please refresh it if PeterZ has nothing against?

Posted v2: https://lore.kernel.org/r/20231130062246.290-1-ravi.bangoria@amd.com 

Thanks.
  
Namhyung Kim Dec. 1, 2023, 8:23 p.m. UTC | #6
On Thu, Nov 30, 2023 at 5:03 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Thu, Nov 30, 2023 at 11:58:15AM +0530, Ravi Bangoria escreveu:
> > On 27-Nov-23 8:02 PM, Arnaldo Carvalho de Melo wrote:
> > > Em Fri, Nov 24, 2023 at 09:30:37AM +0530, Ravi Bangoria escreveu:
> > >> On 23-Nov-23 8:15 PM, Arnaldo Carvalho de Melo wrote:
> > >>> Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
> > >>>> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
> > >>>>> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
> > >>>>> events with brstack.
>
> > >>>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > >>>> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
>
> > >>> It seems this patch was not merged, can you please check?
>
> > >> Right. And it does not apply cleanly on peterz/queue.git/perf/core, since
> > >> surrounding code has changed.
>
> > > Can you please refresh it if PeterZ has nothing against?
>
> > Posted v2: https://lore.kernel.org/r/20231130062246.290-1-ravi.bangoria@amd.com
>
> Peter, can you please consider this one?

The v2 is already in the tip tree.  Thanks Ravi for doing this!
Namhyung
  
Arnaldo Carvalho de Melo Dec. 1, 2023, 8:31 p.m. UTC | #7
Em Fri, Dec 01, 2023 at 12:23:16PM -0800, Namhyung Kim escreveu:
> On Thu, Nov 30, 2023 at 5:03 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Em Thu, Nov 30, 2023 at 11:58:15AM +0530, Ravi Bangoria escreveu:
> > > On 27-Nov-23 8:02 PM, Arnaldo Carvalho de Melo wrote:
> > > > Em Fri, Nov 24, 2023 at 09:30:37AM +0530, Ravi Bangoria escreveu:
> > > >> On 23-Nov-23 8:15 PM, Arnaldo Carvalho de Melo wrote:
> > > >>> Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
> > > >>>> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
> > > >>>>> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
> > > >>>>> events with brstack.
> >
> > > >>>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > >>>> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
> >
> > > >>> It seems this patch was not merged, can you please check?
> >
> > > >> Right. And it does not apply cleanly on peterz/queue.git/perf/core, since
> > > >> surrounding code has changed.
> >
> > > > Can you please refresh it if PeterZ has nothing against?
> >
> > > Posted v2: https://lore.kernel.org/r/20231130062246.290-1-ravi.bangoria@amd.com
> >
> > Peter, can you please consider this one?
> 
> The v2 is already in the tip tree.  Thanks Ravi for doing this!
> Namhyung

yay!

- Arnaldo
  
Arnaldo Carvalho de Melo Dec. 4, 2023, 7:37 p.m. UTC | #8
Em Fri, Dec 01, 2023 at 12:23:16PM -0800, Namhyung Kim escreveu:
> On Thu, Nov 30, 2023 at 5:03 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > Em Thu, Nov 30, 2023 at 11:58:15AM +0530, Ravi Bangoria escreveu:
> > > On 27-Nov-23 8:02 PM, Arnaldo Carvalho de Melo wrote:
> > > > Em Fri, Nov 24, 2023 at 09:30:37AM +0530, Ravi Bangoria escreveu:
> > > >> On 23-Nov-23 8:15 PM, Arnaldo Carvalho de Melo wrote:
> > > >>> Em Tue, Jun 06, 2023 at 10:08:43AM +0530, Ravi Bangoria escreveu:
> > > >>>> On 03-Jun-23 1:15 AM, Namhyung Kim wrote:
> > > >>>>> The AMD IBS PMU doesn't handle branch stacks, so it should not accept
> > > >>>>> events with brstack.
> >
> > > >>>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > >>>> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
> >
> > > >>> It seems this patch was not merged, can you please check?
> >
> > > >> Right. And it does not apply cleanly on peterz/queue.git/perf/core, since
> > > >> surrounding code has changed.

> > > > Can you please refresh it if PeterZ has nothing against?

> > > Posted v2: https://lore.kernel.org/r/20231130062246.290-1-ravi.bangoria@amd.com

> > Peter, can you please consider this one?

> The v2 is already in the tip tree.  Thanks Ravi for doing this!

Yeap, I just checked and Ingo merged it, thanks everybody!

- Arnaldo
  

Patch

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 371014802191..607a692ba8ce 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -265,6 +265,9 @@  static int perf_ibs_init(struct perf_event *event)
 	if (config & ~perf_ibs->config_mask)
 		return -EINVAL;
 
+	if (has_branch_stack(event))
+		return -EOPNOTSUPP;
+
 	if (hwc->sample_period) {
 		if (config & perf_ibs->cnt_mask)
 			/* raw max_cnt may not be set */