Commit 6f2f2ca3 authored by John Garry's avatar John Garry Committed by Arnaldo Carvalho de Melo

perf vendor events: Drop support for unused topic directories

Currently a topic subdirectory is supported in the pmu-events dir, in
the following sample structure: /arch/platform/subtopic/mysubtopic.json

Upto 256 levels of topic subdirectories are supported. So this means
that JSONs may be located in a topic dir as well as the platform dir.

This topic subdirectory causes problems if we want to add support for a
vendor dir in the pmu-events structure (in the form
arch/platform/vendor), in that we cannot differentiate between a vendor
dir and a topic dir.

Since the topic dir feature is not used, drop it so it does not block
adding vendor subdirectory support.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: William Cohen <wcohen@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linuxarm@huawei.com
Link: http://lkml.kernel.org/r/1520506716-197429-4-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 931ef5dc
...@@ -256,26 +256,19 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val) ...@@ -256,26 +256,19 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val)
goto out_free; \ goto out_free; \
} } while (0) } } while (0)
#define TOPIC_DEPTH 256 static char *topic;
static char *topic_array[TOPIC_DEPTH];
static int topic_level;
static char *get_topic(void) static char *get_topic(void)
{ {
char *tp_old, *tp = NULL; char *tp;
int i; int i;
for (i = 0; i < topic_level + 1; i++) { /* tp is free'd in process_one_file() */
int n; i = asprintf(&tp, "%s", topic);
if (i < 0) {
tp_old = tp;
n = asprintf(&tp, "%s%s", tp ?: "", topic_array[i]);
if (n < 0) {
pr_info("%s: asprintf() error %s\n", prog); pr_info("%s: asprintf() error %s\n", prog);
return NULL; return NULL;
} }
free(tp_old);
}
for (i = 0; i < (int) strlen(tp); i++) { for (i = 0; i < (int) strlen(tp); i++) {
char c = tp[i]; char c = tp[i];
...@@ -291,25 +284,15 @@ static char *get_topic(void) ...@@ -291,25 +284,15 @@ static char *get_topic(void)
return tp; return tp;
} }
static int add_topic(int level, char *bname) static int add_topic(char *bname)
{ {
char *topic; free(topic);
level -= 2;
if (level >= TOPIC_DEPTH)
return -EINVAL;
topic = strdup(bname); topic = strdup(bname);
if (!topic) { if (!topic) {
pr_info("%s: strdup() error %s for file %s\n", prog, pr_info("%s: strdup() error %s for file %s\n", prog,
strerror(errno), bname); strerror(errno), bname);
return -ENOMEM; return -ENOMEM;
} }
free(topic_array[topic_level]);
topic_array[topic_level] = topic;
topic_level = level;
return 0; return 0;
} }
...@@ -824,7 +807,7 @@ static int process_one_file(const char *fpath, const struct stat *sb, ...@@ -824,7 +807,7 @@ static int process_one_file(const char *fpath, const struct stat *sb,
} }
} }
if (level > 1 && add_topic(level, bname)) if (level > 1 && add_topic(bname))
return -ENOMEM; return -ENOMEM;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment