Message ID | 1520506716-197429-5-git-send-email-john.garry@huawei.com |
---|---|
State | New |
Headers | show |
Series | perf events patches for improved ARM64 support | expand |
Em Thu, Mar 08, 2018 at 06:58:29PM +0800, John Garry escreveu: > index 1d02faf..7b9e210 100644 > --- a/tools/perf/pmu-events/jevents.c > @@ -739,25 +739,77 @@ static int get_maxfds(void) > static FILE *eventsfp; > static char *mapfile; > > +static int is_leaf_dir(const char *fpath) > +{ > + DIR *d; > + struct dirent *dir; > + int res = 1; > + > + d = opendir(fpath); > + if (!d) > + return 0; > + > + while ((dir = readdir(d)) != NULL) { > + if (dir->d_type == DT_DIR && dir->d_name[0] != '.') { > + res = 0; > + break; > + } else if (dir->d_type == DT_UNKNOWN) { > + char path[PATH_MAX]; You forgot to add: #include <limits.h> Which broke the build on at least: [root@jouet ~]# time dm 1 13.78 alpine:3.4 : FAIL gcc (Alpine 5.3.0) 5.3.0 2 14.40 alpine:3.5 : FAIL gcc (Alpine 6.2.1) 6.2.1 20160822 3 13.59 alpine:3.6 : FAIL gcc (Alpine 6.3.0) 6.3.0 4 14.94 alpine:3.7 : FAIL gcc (Alpine 6.4.0) 6.4.0 5 14.70 alpine:edge : FAIL gcc (Alpine 6.4.0) 6.4.0 6: amazonlinux:1^C^C I just fixed it. build failure: MKDIR /tmp/build/perf/pmu-events/ HOSTCC /tmp/build/perf/pmu-events/json.o MKDIR /tmp/build/perf/pmu-events/ HOSTCC /tmp/build/perf/pmu-events/jsmn.o HOSTCC /tmp/build/perf/pmu-events/jevents.o LD /tmp/build/perf/libtraceevent-in.o LINK /tmp/build/perf/libtraceevent.a LD /tmp/build/perf/libsubcmd-in.o CC /tmp/build/perf/plugin_jbd2.o CC /tmp/build/perf/plugin_hrtimer.o pmu-events/jevents.c: In function 'is_leaf_dir': pmu-events/jevents.c:879:14: error: 'PATH_MAX' undeclared (first use in this function) char path[PATH_MAX]; ^~~~~~~~ pmu-events/jevents.c:879:14: note: each undeclared identifier is reported only once for each function it appears in AR /tmp/build/perf/libsubcmd.a mv: can't rename '/tmp/build/perf/pmu-events/.jevents.o.tmp': No such file or directory make[3]: *** [/git/linux/tools/build/Makefile.build:96: /tmp/build/perf/pmu-events/jevents.o] Error 1 CC /tmp/build/perf/plugin_kmem.o LD /tmp/build/perf/plugin_jbd2-in.o make[2]: *** [Makefile.perf:501: /tmp/build/perf/pmu-events/jevents-in.o] Error 2 make[2]: *** Waiting for unfinished jobs.... GEN perf-archive CC /tmp/build/perf/plugin_kvm.o
On 12/03/2018 18:28, Arnaldo Carvalho de Melo wrote: > Em Thu, Mar 08, 2018 at 06:58:29PM +0800, John Garry escreveu: >> index 1d02faf..7b9e210 100644 >> --- a/tools/perf/pmu-events/jevents.c >> @@ -739,25 +739,77 @@ static int get_maxfds(void) >> static FILE *eventsfp; >> static char *mapfile; >> >> +static int is_leaf_dir(const char *fpath) >> +{ >> + DIR *d; >> + struct dirent *dir; >> + int res = 1; >> + >> + d = opendir(fpath); >> + if (!d) >> + return 0; >> + >> + while ((dir = readdir(d)) != NULL) { >> + if (dir->d_type == DT_DIR && dir->d_name[0] != '.') { >> + res = 0; >> + break; >> + } else if (dir->d_type == DT_UNKNOWN) { >> + char path[PATH_MAX]; > > > You forgot to add: > > #include <limits.h> > > Which broke the build on at least: > > [root@jouet ~]# time dm > 1 13.78 alpine:3.4 : FAIL gcc (Alpine 5.3.0) 5.3.0 > 2 14.40 alpine:3.5 : FAIL gcc (Alpine 6.2.1) 6.2.1 20160822 > 3 13.59 alpine:3.6 : FAIL gcc (Alpine 6.3.0) 6.3.0 > 4 14.94 alpine:3.7 : FAIL gcc (Alpine 6.4.0) 6.4.0 > 5 14.70 alpine:edge : FAIL gcc (Alpine 6.4.0) 6.4.0 > 6: amazonlinux:1^C^C > > I just fixed it. > > build failure: > > MKDIR /tmp/build/perf/pmu-events/ > HOSTCC /tmp/build/perf/pmu-events/json.o > MKDIR /tmp/build/perf/pmu-events/ > HOSTCC /tmp/build/perf/pmu-events/jsmn.o > HOSTCC /tmp/build/perf/pmu-events/jevents.o > LD /tmp/build/perf/libtraceevent-in.o > LINK /tmp/build/perf/libtraceevent.a > LD /tmp/build/perf/libsubcmd-in.o > CC /tmp/build/perf/plugin_jbd2.o > CC /tmp/build/perf/plugin_hrtimer.o > pmu-events/jevents.c: In function 'is_leaf_dir': > pmu-events/jevents.c:879:14: error: 'PATH_MAX' undeclared (first use in this function) > char path[PATH_MAX]; > ^~~~~~~~ > pmu-events/jevents.c:879:14: note: each undeclared identifier is reported only once for each function it appears in > AR /tmp/build/perf/libsubcmd.a > mv: can't rename '/tmp/build/perf/pmu-events/.jevents.o.tmp': No such file or directory > make[3]: *** [/git/linux/tools/build/Makefile.build:96: /tmp/build/perf/pmu-events/jevents.o] Error 1 > CC /tmp/build/perf/plugin_kmem.o > LD /tmp/build/perf/plugin_jbd2-in.o > make[2]: *** [Makefile.perf:501: /tmp/build/perf/pmu-events/jevents-in.o] Error 2 > make[2]: *** Waiting for unfinished jobs.... > GEN perf-archive > CC /tmp/build/perf/plugin_kvm.o > > > . > OK, thanks for the notification. I will check this. All the best, John
diff --git a/tools/perf/pmu-events/README b/tools/perf/pmu-events/README index 2407abc..655286f 100644 --- a/tools/perf/pmu-events/README +++ b/tools/perf/pmu-events/README @@ -28,6 +28,10 @@ sub directory. Thus for the Silvermont X86 CPU: Cache.json Memory.json Virtual-Memory.json Frontend.json Pipeline.json +The JSONs folder for a CPU model/family may be placed in the root arch +folder, or may be placed in a vendor sub-folder under the arch folder +for instances where the arch and vendor are not the same. + Using the JSON files and the mapfile, 'jevents' generates the C source file, 'pmu-events.c', which encodes the two sets of tables: diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 1d02faf..7b9e210 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -572,7 +572,7 @@ static char *file_name_to_table_name(char *fname) * Derive rest of table name from basename of the JSON file, * replacing hyphens and stripping out .json suffix. */ - n = asprintf(&tblname, "pme_%s", basename(fname)); + n = asprintf(&tblname, "pme_%s", fname); if (n < 0) { pr_info("%s: asprintf() error %s for file %s\n", prog, strerror(errno), fname); @@ -582,7 +582,7 @@ static char *file_name_to_table_name(char *fname) for (i = 0; i < strlen(tblname); i++) { c = tblname[i]; - if (c == '-') + if (c == '-' || c == '/') tblname[i] = '_'; else if (c == '.') { tblname[i] = '\0'; @@ -739,25 +739,77 @@ static int get_maxfds(void) static FILE *eventsfp; static char *mapfile; +static int is_leaf_dir(const char *fpath) +{ + DIR *d; + struct dirent *dir; + int res = 1; + + d = opendir(fpath); + if (!d) + return 0; + + while ((dir = readdir(d)) != NULL) { + if (dir->d_type == DT_DIR && dir->d_name[0] != '.') { + res = 0; + break; + } else if (dir->d_type == DT_UNKNOWN) { + char path[PATH_MAX]; + struct stat st; + + sprintf(path, "%s/%s", fpath, dir->d_name); + if (stat(path, &st)) + break; + + if (S_ISDIR(st.st_mode)) { + res = 0; + break; + } + } + } + + closedir(d); + + return res; +} + static int process_one_file(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) { - char *tblname, *bname = (char *) fpath + ftwbuf->base; + char *tblname, *bname; int is_dir = typeflag == FTW_D; int is_file = typeflag == FTW_F; int level = ftwbuf->level; int err = 0; + if (level == 2 && is_dir) { + /* + * For level 2 directory, bname will include parent name, + * like vendor/platform. So search back from platform dir + * to find this. + */ + bname = (char *) fpath + ftwbuf->base - 2; + for (;;) { + if (*bname == '/') + break; + bname--; + } + bname++; + } else + bname = (char *) fpath + ftwbuf->base; + pr_debug("%s %d %7jd %-20s %s\n", is_file ? "f" : is_dir ? "d" : "x", level, sb->st_size, bname, fpath); - /* base dir */ - if (level == 0) + /* base dir or too deep */ + if (level == 0 || level > 3) return 0; + /* model directory, reset topic */ - if (level == 1 && is_dir) { + if ((level == 1 && is_dir && is_leaf_dir(fpath)) || + (level == 2 && is_dir)) { if (close_table) print_events_table_suffix(eventsfp);