diff mbox series

[RFC,v5,01/13] perf jevents: Add support for an extra directory level

Message ID 1604666153-4187-2-git-send-email-john.garry@huawei.com (mailing list archive)
State New, archived
Headers show
Series perf pmu-events: Support event aliasing for system PMUs | expand

Commit Message

John Garry Nov. 6, 2020, 12:35 p.m. UTC
Currently only upto a level 2 directory is supported, in form
vendor/platform.

Add support for a further level, to support vendor/platform
sub-directories in future.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/pmu-events/jevents.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

kajoljain Nov. 13, 2020, 8:48 a.m. UTC | #1
On 11/6/20 6:05 PM, John Garry wrote:
> Currently only upto a level 2 directory is supported, in form
> vendor/platform.

Hi John,
    Just want to check in case of sub directories,
Will it be good add on/feasible to be able to include events of particular sub-directory for a
platform? Otherwise with this patch in the end all event will be part of
same pmu_event structure. So what is the purpose of sub directories? Let me know if I am missing something.

Thanks,
Kajol Jain
> 
> Add support for a further level, to support vendor/platform
> sub-directories in future.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  tools/perf/pmu-events/jevents.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index 72cfa3b5046d..9022216b1253 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -978,15 +978,20 @@ static int process_one_file(const char *fpath, const struct stat *sb,
>  	int level   = ftwbuf->level;
>  	int err = 0;
>  
> -	if (level == 2 && is_dir) {
> +	if (level >= 2 && is_dir) {
> +		int count = 0;
>  		/*
>  		 * For level 2 directory, bname will include parent name,
>  		 * like vendor/platform. So search back from platform dir
>  		 * to find this.
> +		 * Something similar for level 3 directory, but we're a PMU
> +		 * category folder, like vendor/platform/cpu.
>  		 */
>  		bname = (char *) fpath + ftwbuf->base - 2;
>  		for (;;) {
>  			if (*bname == '/')
> +				count++;
> +			if (count == level - 1)
>  				break;
>  			bname--;
>  		}
> @@ -999,13 +1004,13 @@ static int process_one_file(const char *fpath, const struct stat *sb,
>  		 level, sb->st_size, bname, fpath);
>  
>  	/* base dir or too deep */
> -	if (level == 0 || level > 3)
> +	if (level == 0 || level > 4)
>  		return 0;
>  
>  
>  	/* model directory, reset topic */
>  	if ((level == 1 && is_dir && is_leaf_dir(fpath)) ||
> -	    (level == 2 && is_dir)) {
> +	    (level >= 2 && is_dir && is_leaf_dir(fpath))) {
>  		if (close_table)
>  			print_events_table_suffix(eventsfp);
>  
>
John Garry Nov. 13, 2020, 9:24 a.m. UTC | #2
On 13/11/2020 08:48, kajoljain wrote:
> 
> On 11/6/20 6:05 PM, John Garry wrote:
>> Currently only upto a level 2 directory is supported, in form
>> vendor/platform.
> Hi John,
>      Just want to check in case of sub directories,
> Will it be good add on/feasible to be able to include events of particular sub-directory for a
> platform? Otherwise with this patch in the end all event will be part of
> same pmu_event structure. So what is the purpose of sub directories? Let me know if I am missing something.

Hi Kajol Jain,

So currently we support both of the following structure:
arch/platform
arch/vendor/platform/

arch/vendor/platform/ is for an arch like arm, where the arch provider 
may not be the vendor.

I want to go one step further, to support also:
arch/vendor/platform/cpu
arch/vendor/platform/sys

Here we have separate folders for cpu and sys events. CPU events in 
"cpu" folder are added to pmu_events_map[], as before. And events in 
"sys" folder are added from patch 2/13 to new table pmu_sys_events_table[].

I hope it's clearer now.

Thanks,
John

> 
> Thanks,
> Kajol Jain
>> Add support for a further level, to support vendor/platform
>> sub-directories in future.
kajoljain Nov. 18, 2020, 4:38 a.m. UTC | #3
On 11/13/20 2:54 PM, John Garry wrote:
> On 13/11/2020 08:48, kajoljain wrote:
>>
>> On 11/6/20 6:05 PM, John Garry wrote:
>>> Currently only upto a level 2 directory is supported, in form
>>> vendor/platform.
>> Hi John,
>>      Just want to check in case of sub directories,
>> Will it be good add on/feasible to be able to include events of particular sub-directory for a
>> platform? Otherwise with this patch in the end all event will be part of
>> same pmu_event structure. So what is the purpose of sub directories? Let me know if I am missing something.
> 
> Hi Kajol Jain,
> 
> So currently we support both of the following structure:
> arch/platform
> arch/vendor/platform/
> 
> arch/vendor/platform/ is for an arch like arm, where the arch provider may not be the vendor.
> 
> I want to go one step further, to support also:
> arch/vendor/platform/cpu
> arch/vendor/platform/sys
> 
> Here we have separate folders for cpu and sys events. CPU events in "cpu" folder are added to pmu_events_map[], as before. And events in "sys" folder are added from patch 2/13 to new table pmu_sys_events_table[].
> 
> I hope it's clearer now.

Hi John,
    Thanks for explaining. This patch looks good to me then.

Reviewed-By: Kajol Jain<kjain@linux.ibm.com>

Thanks,
Kajol Jain
> 
> Thanks,
> John
> 
>>
>> Thanks,
>> Kajol Jain
>>> Add support for a further level, to support vendor/platform
>>> sub-directories in future.
>
diff mbox series

Patch

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 72cfa3b5046d..9022216b1253 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -978,15 +978,20 @@  static int process_one_file(const char *fpath, const struct stat *sb,
 	int level   = ftwbuf->level;
 	int err = 0;
 
-	if (level == 2 && is_dir) {
+	if (level >= 2 && is_dir) {
+		int count = 0;
 		/*
 		 * For level 2 directory, bname will include parent name,
 		 * like vendor/platform. So search back from platform dir
 		 * to find this.
+		 * Something similar for level 3 directory, but we're a PMU
+		 * category folder, like vendor/platform/cpu.
 		 */
 		bname = (char *) fpath + ftwbuf->base - 2;
 		for (;;) {
 			if (*bname == '/')
+				count++;
+			if (count == level - 1)
 				break;
 			bname--;
 		}
@@ -999,13 +1004,13 @@  static int process_one_file(const char *fpath, const struct stat *sb,
 		 level, sb->st_size, bname, fpath);
 
 	/* base dir or too deep */
-	if (level == 0 || level > 3)
+	if (level == 0 || level > 4)
 		return 0;
 
 
 	/* model directory, reset topic */
 	if ((level == 1 && is_dir && is_leaf_dir(fpath)) ||
-	    (level == 2 && is_dir)) {
+	    (level >= 2 && is_dir && is_leaf_dir(fpath))) {
 		if (close_table)
 			print_events_table_suffix(eventsfp);