linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/amd/ibs: Make IBS a core pmu
@ 2022-11-15  9:39 Ravi Bangoria
  2022-11-15 17:07 ` Ian Rogers
  2022-11-24 12:03 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
  0 siblings, 2 replies; 7+ messages in thread
From: Ravi Bangoria @ 2022-11-15  9:39 UTC (permalink / raw)
  To: peterz
  Cc: ravi.bangoria, acme, mark.rutland, jolsa, namhyung, eranian,
	kan.liang, bp, x86, linux-perf-users, linux-kernel, sandipan.das,
	ananth.narayan, santosh.shukla

So far, only one pmu was allowed to be registered as core pmu and thus
IBS pmus were being registered as uncore. However, with the event context
rewrite, that limitation no longer exists and thus IBS pmus can also be
registered as core pmu. This makes IBS much more usable, for ex, user
will be able to do per-process precise monitoring on AMD:

Before patch:
  $ sudo perf record -e cycles:pp ls
  Error:
  Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'

After patch:
  $ sudo perf record -e cycles:pp ls
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.017 MB perf.data (33 samples) ]

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
---
Note:
This patch is dependent on the event context rewrite patch which is
already present in a tip tree:
  https://git.kernel.org/tip/tip/c/bd27568117664

 arch/x86/events/amd/ibs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 3271735f0070..fbc2ce86f4b8 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -631,7 +631,7 @@ static const struct attribute_group *op_attr_update[] = {
 
 static struct perf_ibs perf_ibs_fetch = {
 	.pmu = {
-		.task_ctx_nr	= perf_invalid_context,
+		.task_ctx_nr	= perf_hw_context,
 
 		.event_init	= perf_ibs_init,
 		.add		= perf_ibs_add,
@@ -655,7 +655,7 @@ static struct perf_ibs perf_ibs_fetch = {
 
 static struct perf_ibs perf_ibs_op = {
 	.pmu = {
-		.task_ctx_nr	= perf_invalid_context,
+		.task_ctx_nr	= perf_hw_context,
 
 		.event_init	= perf_ibs_init,
 		.add		= perf_ibs_add,
-- 
2.37.3


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

* Re: [PATCH] perf/amd/ibs: Make IBS a core pmu
  2022-11-15  9:39 [PATCH] perf/amd/ibs: Make IBS a core pmu Ravi Bangoria
@ 2022-11-15 17:07 ` Ian Rogers
  2022-11-16  5:45   ` Ravi Bangoria
  2022-11-24 12:03 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
  1 sibling, 1 reply; 7+ messages in thread
From: Ian Rogers @ 2022-11-15 17:07 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: peterz, acme, mark.rutland, jolsa, namhyung, eranian, kan.liang,
	bp, x86, linux-perf-users, linux-kernel, sandipan.das,
	ananth.narayan, santosh.shukla

On Tue, Nov 15, 2022 at 1:39 AM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>
> So far, only one pmu was allowed to be registered as core pmu and thus
> IBS pmus were being registered as uncore. However, with the event context
> rewrite, that limitation no longer exists and thus IBS pmus can also be
> registered as core pmu. This makes IBS much more usable, for ex, user
> will be able to do per-process precise monitoring on AMD:
>
> Before patch:
>   $ sudo perf record -e cycles:pp ls
>   Error:
>   Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'
>
> After patch:
>   $ sudo perf record -e cycles:pp ls
>   [ perf record: Woken up 1 times to write data ]
>   [ perf record: Captured and wrote 0.017 MB perf.data (33 samples) ]
>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>

Acked-by: Ian Rogers <irogers@google.com>

This is awesome!
Ian

> ---
> Note:
> This patch is dependent on the event context rewrite patch which is
> already present in a tip tree:
>   https://git.kernel.org/tip/tip/c/bd27568117664
>
>  arch/x86/events/amd/ibs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index 3271735f0070..fbc2ce86f4b8 100644
> --- a/arch/x86/events/amd/ibs.c
> +++ b/arch/x86/events/amd/ibs.c
> @@ -631,7 +631,7 @@ static const struct attribute_group *op_attr_update[] = {
>
>  static struct perf_ibs perf_ibs_fetch = {
>         .pmu = {
> -               .task_ctx_nr    = perf_invalid_context,
> +               .task_ctx_nr    = perf_hw_context,
>
>                 .event_init     = perf_ibs_init,
>                 .add            = perf_ibs_add,
> @@ -655,7 +655,7 @@ static struct perf_ibs perf_ibs_fetch = {
>
>  static struct perf_ibs perf_ibs_op = {
>         .pmu = {
> -               .task_ctx_nr    = perf_invalid_context,
> +               .task_ctx_nr    = perf_hw_context,
>
>                 .event_init     = perf_ibs_init,
>                 .add            = perf_ibs_add,
> --
> 2.37.3
>

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

* Re: [PATCH] perf/amd/ibs: Make IBS a core pmu
  2022-11-15 17:07 ` Ian Rogers
@ 2022-11-16  5:45   ` Ravi Bangoria
  2022-11-22  8:13     ` Ravi Bangoria
  0 siblings, 1 reply; 7+ messages in thread
From: Ravi Bangoria @ 2022-11-16  5:45 UTC (permalink / raw)
  To: peterz, Ian Rogers
  Cc: acme, mark.rutland, jolsa, namhyung, eranian, kan.liang, bp, x86,
	linux-perf-users, linux-kernel, sandipan.das, ananth.narayan,
	santosh.shukla, Ravi Bangoria

On 15-Nov-22 10:37 PM, Ian Rogers wrote:
> On Tue, Nov 15, 2022 at 1:39 AM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>>
>> So far, only one pmu was allowed to be registered as core pmu and thus
>> IBS pmus were being registered as uncore. However, with the event context
>> rewrite, that limitation no longer exists and thus IBS pmus can also be
>> registered as core pmu. This makes IBS much more usable, for ex, user
>> will be able to do per-process precise monitoring on AMD:
>>
>> Before patch:
>>   $ sudo perf record -e cycles:pp ls
>>   Error:
>>   Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'
>>
>> After patch:
>>   $ sudo perf record -e cycles:pp ls
>>   [ perf record: Woken up 1 times to write data ]
>>   [ perf record: Captured and wrote 0.017 MB perf.data (33 samples) ]
>>
>> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
> 
> Acked-by: Ian Rogers <irogers@google.com>
> 
> This is awesome!
> Ian

Thanks Ian.

Peter, can we push this along with rewrite patch?

Thanks,
Ravi

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

* Re: [PATCH] perf/amd/ibs: Make IBS a core pmu
  2022-11-16  5:45   ` Ravi Bangoria
@ 2022-11-22  8:13     ` Ravi Bangoria
  0 siblings, 0 replies; 7+ messages in thread
From: Ravi Bangoria @ 2022-11-22  8:13 UTC (permalink / raw)
  To: peterz
  Cc: Ian Rogers, acme, mark.rutland, jolsa, namhyung, eranian,
	kan.liang, bp, x86, linux-perf-users, linux-kernel, sandipan.das,
	ananth.narayan, santosh.shukla, Ravi Bangoria

On 16-Nov-22 11:15 AM, Ravi Bangoria wrote:
> On 15-Nov-22 10:37 PM, Ian Rogers wrote:
>> On Tue, Nov 15, 2022 at 1:39 AM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>>>
>>> So far, only one pmu was allowed to be registered as core pmu and thus
>>> IBS pmus were being registered as uncore. However, with the event context
>>> rewrite, that limitation no longer exists and thus IBS pmus can also be
>>> registered as core pmu. This makes IBS much more usable, for ex, user
>>> will be able to do per-process precise monitoring on AMD:
>>>
>>> Before patch:
>>>   $ sudo perf record -e cycles:pp ls
>>>   Error:
>>>   Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'
>>>
>>> After patch:
>>>   $ sudo perf record -e cycles:pp ls
>>>   [ perf record: Woken up 1 times to write data ]
>>>   [ perf record: Captured and wrote 0.017 MB perf.data (33 samples) ]
>>>
>>> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
>>
>> Acked-by: Ian Rogers <irogers@google.com>
>>
>> This is awesome!
>> Ian
> 
> Thanks Ian.
> 
> Peter, can we push this along with rewrite patch?

Gentle Ping, Peter!

Thanks,
Ravi

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

* [tip: perf/core] perf/amd/ibs: Make IBS a core pmu
  2022-11-15  9:39 [PATCH] perf/amd/ibs: Make IBS a core pmu Ravi Bangoria
  2022-11-15 17:07 ` Ian Rogers
@ 2022-11-24 12:03 ` tip-bot2 for Ravi Bangoria
  2022-12-08 15:19   ` Borislav Petkov
  1 sibling, 1 reply; 7+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2022-11-24 12:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Peter Zijlstra (Intel), Ian Rogers, x86, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     30093056f7b2f759ff180d3a86d29f68315e469b
Gitweb:        https://git.kernel.org/tip/30093056f7b2f759ff180d3a86d29f68315e469b
Author:        Ravi Bangoria <ravi.bangoria@amd.com>
AuthorDate:    Tue, 15 Nov 2022 15:09:04 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 24 Nov 2022 11:09:19 +01:00

perf/amd/ibs: Make IBS a core pmu

So far, only one pmu was allowed to be registered as core pmu and thus
IBS pmus were being registered as uncore. However, with the event context
rewrite, that limitation no longer exists and thus IBS pmus can also be
registered as core pmu. This makes IBS much more usable, for ex, user
will be able to do per-process precise monitoring on AMD:

Before patch:
  $ sudo perf record -e cycles:pp ls
  Error:
  Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'

After patch:
  $ sudo perf record -e cycles:pp ls
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.017 MB perf.data (33 samples) ]

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Ian Rogers <irogers@google.com>
Link: https://lkml.kernel.org/r/20221115093904.1799-1-ravi.bangoria@amd.com
---
 arch/x86/events/amd/ibs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 3271735..fbc2ce8 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -631,7 +631,7 @@ static const struct attribute_group *op_attr_update[] = {
 
 static struct perf_ibs perf_ibs_fetch = {
 	.pmu = {
-		.task_ctx_nr	= perf_invalid_context,
+		.task_ctx_nr	= perf_hw_context,
 
 		.event_init	= perf_ibs_init,
 		.add		= perf_ibs_add,
@@ -655,7 +655,7 @@ static struct perf_ibs perf_ibs_fetch = {
 
 static struct perf_ibs perf_ibs_op = {
 	.pmu = {
-		.task_ctx_nr	= perf_invalid_context,
+		.task_ctx_nr	= perf_hw_context,
 
 		.event_init	= perf_ibs_init,
 		.add		= perf_ibs_add,

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

* Re: [tip: perf/core] perf/amd/ibs: Make IBS a core pmu
  2022-11-24 12:03 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
@ 2022-12-08 15:19   ` Borislav Petkov
  2022-12-09  3:32     ` Ravi Bangoria
  0 siblings, 1 reply; 7+ messages in thread
From: Borislav Petkov @ 2022-12-08 15:19 UTC (permalink / raw)
  To: linux-kernel, Linus Torvalds
  Cc: linux-tip-commits, Ravi Bangoria, Peter Zijlstra (Intel),
	Ian Rogers, x86

I believe this is one of the things Linus wanted to have on AMD hw.

On Thu, Nov 24, 2022 at 12:03:03PM -0000, tip-bot2 for Ravi Bangoria wrote:
> The following commit has been merged into the perf/core branch of tip:
> 
> Commit-ID:     30093056f7b2f759ff180d3a86d29f68315e469b
> Gitweb:        https://git.kernel.org/tip/30093056f7b2f759ff180d3a86d29f68315e469b
> Author:        Ravi Bangoria <ravi.bangoria@amd.com>
> AuthorDate:    Tue, 15 Nov 2022 15:09:04 +05:30
> Committer:     Peter Zijlstra <peterz@infradead.org>
> CommitterDate: Thu, 24 Nov 2022 11:09:19 +01:00
> 
> perf/amd/ibs: Make IBS a core pmu
> 
> So far, only one pmu was allowed to be registered as core pmu and thus
> IBS pmus were being registered as uncore. However, with the event context
> rewrite, that limitation no longer exists and thus IBS pmus can also be
> registered as core pmu. This makes IBS much more usable, for ex, user
> will be able to do per-process precise monitoring on AMD:
> 
> Before patch:
>   $ sudo perf record -e cycles:pp ls
>   Error:
>   Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'
> 
> After patch:
>   $ sudo perf record -e cycles:pp ls
>   [ perf record: Woken up 1 times to write data ]
>   [ perf record: Captured and wrote 0.017 MB perf.data (33 samples) ]
> 
> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Acked-by: Ian Rogers <irogers@google.com>
> Link: https://lkml.kernel.org/r/20221115093904.1799-1-ravi.bangoria@amd.com
> ---
>  arch/x86/events/amd/ibs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index 3271735..fbc2ce8 100644
> --- a/arch/x86/events/amd/ibs.c
> +++ b/arch/x86/events/amd/ibs.c
> @@ -631,7 +631,7 @@ static const struct attribute_group *op_attr_update[] = {
>  
>  static struct perf_ibs perf_ibs_fetch = {
>  	.pmu = {
> -		.task_ctx_nr	= perf_invalid_context,
> +		.task_ctx_nr	= perf_hw_context,
>  
>  		.event_init	= perf_ibs_init,
>  		.add		= perf_ibs_add,
> @@ -655,7 +655,7 @@ static struct perf_ibs perf_ibs_fetch = {
>  
>  static struct perf_ibs perf_ibs_op = {
>  	.pmu = {
> -		.task_ctx_nr	= perf_invalid_context,
> +		.task_ctx_nr	= perf_hw_context,
>  
>  		.event_init	= perf_ibs_init,
>  		.add		= perf_ibs_add,

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

* Re: [tip: perf/core] perf/amd/ibs: Make IBS a core pmu
  2022-12-08 15:19   ` Borislav Petkov
@ 2022-12-09  3:32     ` Ravi Bangoria
  0 siblings, 0 replies; 7+ messages in thread
From: Ravi Bangoria @ 2022-12-09  3:32 UTC (permalink / raw)
  To: Borislav Petkov, Linus Torvalds
  Cc: linux-tip-commits, Peter Zijlstra (Intel),
	Ian Rogers, x86, linux-kernel, Ravi Bangoria

On 08-Dec-22 8:49 PM, Borislav Petkov wrote:
> I believe this is one of the things Linus wanted to have on AMD hw.

Yes, https://lore.kernel.org/r/CAHk-=wgRm26_oT-JR+TRzDsfhD1TRxfWDM=j6kJerv+m=NU-yQ@mail.gmail.com

This patch solves per-thread profiling issue. However, -e cycles:p is
still root only because IBS hw does not support user/kernel filtering.

Thanks,
Ravi

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

end of thread, other threads:[~2022-12-09  3:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15  9:39 [PATCH] perf/amd/ibs: Make IBS a core pmu Ravi Bangoria
2022-11-15 17:07 ` Ian Rogers
2022-11-16  5:45   ` Ravi Bangoria
2022-11-22  8:13     ` Ravi Bangoria
2022-11-24 12:03 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2022-12-08 15:19   ` Borislav Petkov
2022-12-09  3:32     ` Ravi Bangoria

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).