perf jevents: Add support for an extra directory level
authorJohn Garry <john.garry@huawei.com>
Fri, 4 Dec 2020 11:10:07 +0000 (19:10 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Dec 2020 17:36:17 +0000 (14:36 -0300)
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, which will be vendor/platform/cpu and
vendor/platform/sys.

Signed-off-by: John Garry <john.garry@huawei.com>
Acked-by: Kajol Jain <kjain@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linuxarm@huawei.com
Link: http://lore.kernel.org/lkml/1607080216-36968-2-git-send-email-john.garry@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/pmu-events/jevents.c

index 72cfa3b..9022216 100644 (file)
@@ -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);