perf/amd/ibs: Make IBS a core pmu

Message ID 20221115093904.1799-1-ravi.bangoria@amd.com
State New
Headers
Series perf/amd/ibs: Make IBS a core pmu |

Commit Message

Ravi Bangoria Nov. 15, 2022, 9:39 a.m. UTC
  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(-)
  

Comments

Ian Rogers Nov. 15, 2022, 5:07 p.m. UTC | #1
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
>
  
Ravi Bangoria Nov. 16, 2022, 5:45 a.m. UTC | #2
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
  
Ravi Bangoria Nov. 22, 2022, 8:13 a.m. UTC | #3
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
  

Patch

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,