[v4,4/5] hwtracing: hisi_ptt: Advertise PERF_PMU_CAP_NO_EXCLUDE for PTT PMU

Message ID 20230606142244.10939-5-yangyicong@huawei.com
State New
Headers
Series Improve PTT filter interface and some fixes |

Commit Message

Yicong Yang June 6, 2023, 2:22 p.m. UTC
  From: Yicong Yang <yangyicong@hisilicon.com>

The PTT trace collects PCIe TLP headers from the PCIe link and don't
have the ability to exclude certain context. It doesn't support itrace
as well. So only advertise PERF_PMU_CAP_NO_EXCLUDE. This will greatly
save the storage of final data. Tested tracing idle link for ~15s,
without this patch we'll collect ~28.682MB data for context related
information and with this patch it reduced to ~0.226MB.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/hwtracing/ptt/hisi_ptt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

hejunhao June 19, 2023, 1 p.m. UTC | #1
Hi, Yicong


On 2023/6/6 22:22, Yicong Yang wrote:
> From: Yicong Yang <yangyicong@hisilicon.com>
>
> The PTT trace collects PCIe TLP headers from the PCIe link and don't
> have the ability to exclude certain context. It doesn't support itrace
> as well. So only advertise PERF_PMU_CAP_NO_EXCLUDE. This will greatly
> save the storage of final data. Tested tracing idle link for ~15s,
> without this patch we'll collect ~28.682MB data for context related
> information and with this patch it reduced to ~0.226MB.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
> ---
>   drivers/hwtracing/ptt/hisi_ptt.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
> index 5c7e93e7705f..ff2c16efe5b1 100644
> --- a/drivers/hwtracing/ptt/hisi_ptt.c
> +++ b/drivers/hwtracing/ptt/hisi_ptt.c
> @@ -1210,7 +1210,7 @@ static int hisi_ptt_register_pmu(struct hisi_ptt *hisi_ptt)
>   
>   	hisi_ptt->hisi_ptt_pmu = (struct pmu) {
>   		.module		= THIS_MODULE,
> -		.capabilities	= PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE,
> +		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,

According to the error prompt of function hisi_ptt_trace_start().
https://elixir.bootlin.com/linux/v6.4-rc7/source/drivers/hwtracing/ptt/hisi_ptt.c#L197

You may be need to keep advertise PERF_PMU_CAP_EXCLUSIVE?
Such pmus can only have one event scheduled at a time, if not the perf
tool will report device busy.

Best regards,
Junhao.

>   		.task_ctx_nr	= perf_sw_context,
>   		.attr_groups	= hisi_ptt_pmu_groups,
>   		.event_init	= hisi_ptt_pmu_event_init,
  
Yicong Yang June 20, 2023, 9:09 a.m. UTC | #2
Hi Junhao,

On 2023/6/19 21:00, hejunhao wrote:
> Hi, Yicong
> 
> 
> On 2023/6/6 22:22, Yicong Yang wrote:
>> From: Yicong Yang <yangyicong@hisilicon.com>
>>
>> The PTT trace collects PCIe TLP headers from the PCIe link and don't
>> have the ability to exclude certain context. It doesn't support itrace
>> as well. So only advertise PERF_PMU_CAP_NO_EXCLUDE. This will greatly
>> save the storage of final data. Tested tracing idle link for ~15s,
>> without this patch we'll collect ~28.682MB data for context related
>> information and with this patch it reduced to ~0.226MB.
>>
>> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
>> ---
>>   drivers/hwtracing/ptt/hisi_ptt.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
>> index 5c7e93e7705f..ff2c16efe5b1 100644
>> --- a/drivers/hwtracing/ptt/hisi_ptt.c
>> +++ b/drivers/hwtracing/ptt/hisi_ptt.c
>> @@ -1210,7 +1210,7 @@ static int hisi_ptt_register_pmu(struct hisi_ptt *hisi_ptt)
>>         hisi_ptt->hisi_ptt_pmu = (struct pmu) {
>>           .module        = THIS_MODULE,
>> -        .capabilities    = PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE,
>> +        .capabilities    = PERF_PMU_CAP_NO_EXCLUDE,
> 
> According to the error prompt of function hisi_ptt_trace_start().
> https://elixir.bootlin.com/linux/v6.4-rc7/source/drivers/hwtracing/ptt/hisi_ptt.c#L197
> 
> You may be need to keep advertise PERF_PMU_CAP_EXCLUSIVE?
> Such pmus can only have one event scheduled at a time, if not the perf
> tool will report device busy.
> 

Thanks for point it out. Checking [1] I think we still need this flag here, will add
it back.

[1] https://github.com/torvalds/linux/blob/v6.4-rc6/kernel/events/core.c#L5054

Thanks.
  

Patch

diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
index 5c7e93e7705f..ff2c16efe5b1 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -1210,7 +1210,7 @@  static int hisi_ptt_register_pmu(struct hisi_ptt *hisi_ptt)
 
 	hisi_ptt->hisi_ptt_pmu = (struct pmu) {
 		.module		= THIS_MODULE,
-		.capabilities	= PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE,
+		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
 		.task_ctx_nr	= perf_sw_context,
 		.attr_groups	= hisi_ptt_pmu_groups,
 		.event_init	= hisi_ptt_pmu_event_init,