1 #define _XOPEN_SOURCE 500 /* needed for nftw() */
2 #define __BSD_VISIBLE 1 /* needed for asprintf() */
3 /* Parse event JSON files */
6 * Copyright (c) 2014, Intel Corporation
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30 * OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <sys/stddef.h>
48 #include <sys/time.h> /* getrlimit */
49 #include <sys/resource.h> /* getrlimit */
57 int snprintf(char * __restrict, size_t, const char * __restrict,
58 ...) __printflike(3, 4);
59 _Noreturn void _Exit(int);
64 int eprintf(int level, int var, const char *fmt, ...)
75 ret = vfprintf(stderr, fmt, args);
82 __attribute__((weak)) char *get_cpu_str(void)
87 static void addfield(char *map, char **dst, const char *sep,
88 const char *a, jsmntok_t *bt)
90 unsigned int len = strlen(a) + 1 + strlen(sep);
91 int olen = *dst ? strlen(*dst) : 0;
92 int blen = bt ? json_len(bt) : 0;
95 out = realloc(*dst, len + olen + blen);
97 /* Don't add field in this case */
108 strncat(*dst, map + bt->start, blen);
111 static void fixname(char *s)
117 static void fixdesc(char *s)
119 char *e = s + strlen(s);
121 /* Remove trailing dots that look ugly in perf list */
123 while (e >= s && isspace(*e))
129 /* Add escapes for '\' so they are proper C strings. */
130 static char *fixregex(char *s)
137 /* Count the number of '\' in string */
138 for (p = s; *p; p++) {
147 /* allocate space for a new string */
148 fixed = (char *) malloc(len + 1);
152 /* copy over the characters */
154 for (p = s; *p; p++) {
166 static struct msrmap {
170 { "0x3F6", "ldlat=" },
171 { "0x1A6", "offcore_rsp=" },
172 { "0x1A7", "offcore_rsp=" },
173 { "0x3F7", "frontend=" },
177 static struct field {
181 { "UMask", "umask=" },
182 { "CounterMask", "cmask=" },
183 { "Invert", "inv=" },
184 { "AnyThread", "any=" },
185 { "EdgeDetect", "edge=" },
186 { "SampleAfterValue", "period=" },
187 { "FCMask", "fc_mask=" },
188 { "PortMask", "ch_mask=" },
192 static void cut_comma(char *map, jsmntok_t *newval)
196 /* Cut off everything after comma */
197 for (i = newval->start; i < newval->end; i++) {
203 static int match_field(char *map, jsmntok_t *field, int nz,
204 char **event, jsmntok_t *val)
207 jsmntok_t newval = *val;
209 for (f = fields; f->field; f++)
210 if (json_streq(map, field, f->field) && nz) {
211 cut_comma(map, &newval);
212 addfield(map, event, ",", f->kernel, &newval);
218 static struct msrmap *lookup_msr(char *map, jsmntok_t *val)
220 jsmntok_t newval = *val;
224 cut_comma(map, &newval);
225 for (i = 0; msrmap[i].num; i++)
226 if (json_streq(map, &newval, msrmap[i].num))
230 pr_err("%s: Unknown MSR in event file %.*s\n", prog,
231 json_len(val), map + val->start);
240 { "CBO", "uncore_cbox" },
241 { "QPI LL", "uncore_qpi" },
242 { "SBO", "uncore_sbox" },
243 { "iMPH-U", "uncore_arb" },
247 static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val)
251 for (i = 0; table[i].json; i++) {
252 if (json_streq(map, val, table[i].json))
253 return table[i].perf;
258 #define EXPECT(e, t, m) do { if (!(e)) { \
259 jsmntok_t *loc = (t); \
260 if (!(t)->start && (t) > tokens) \
262 pr_err("%s:%d: " m ", got %s\n", fn, \
263 json_line(map, loc), \
271 static char *get_topic(void)
276 /* tp is free'd in process_one_file() */
277 i = asprintf(&tp, "%s", topic);
279 pr_info("%s: asprintf() error %s\n", prog);
283 for (i = 0; i < (int) strlen(tp); i++) {
297 static int add_topic(const char *bname)
300 topic = strdup(bname);
302 pr_info("%s: strdup() error %s for file %s\n", prog,
303 strerror(errno), bname);
309 struct perf_entry_data {
314 static int close_table;
316 static void print_events_table_prefix(FILE *fp, const char *tblname)
318 fprintf(fp, "static struct pmu_event %s[] = {\n", tblname);
322 static int print_events_table_entry(void *data, char *name, const char *event,
323 char *desc, char *long_desc,
324 char *pmu, char *unit, char *perpkg,
326 char *metric_name, char *metric_group)
328 struct perf_entry_data *pd = data;
329 FILE *outfp = pd->outfp;
330 char *etopic = pd->topic;
333 * TODO: Remove formatting chars after debugging to reduce
336 fprintf(outfp, "{\n");
339 fprintf(outfp, "\t.name = \"%s\",\n", name);
341 fprintf(outfp, "\t.event = \"%s\",\n", event);
342 fprintf(outfp, "\t.desc = \"%s\",\n", desc);
343 fprintf(outfp, "\t.topic = \"%s\",\n", etopic);
344 if (long_desc && long_desc[0])
345 fprintf(outfp, "\t.long_desc = \"%s\",\n", long_desc);
347 fprintf(outfp, "\t.pmu = \"%s\",\n", pmu);
349 fprintf(outfp, "\t.unit = \"%s\",\n", unit);
351 fprintf(outfp, "\t.perpkg = \"%s\",\n", perpkg);
353 fprintf(outfp, "\t.metric_expr = \"%s\",\n", metric_expr);
355 fprintf(outfp, "\t.metric_name = \"%s\",\n", metric_name);
357 fprintf(outfp, "\t.metric_group = \"%s\",\n", metric_group);
358 fprintf(outfp, "},\n");
363 struct event_struct {
364 struct list_head list;
377 #define ADD_EVENT_FIELD(field) do { if (field) { \
378 es->field = strdup(field); \
383 #define FREE_EVENT_FIELD(field) free(es->field)
385 #define TRY_FIXUP_FIELD(field) do { if (es->field && !*field) {\
386 *field = strdup(es->field); \
391 #define FOR_ALL_EVENT_STRUCT_FIELDS(op) do { \
404 static LIST_HEAD(arch_std_events);
406 static void free_arch_std_events(void)
408 struct event_struct *es, *next;
410 list_for_each_entry_safe(es, next, &arch_std_events, list) {
411 FOR_ALL_EVENT_STRUCT_FIELDS(FREE_EVENT_FIELD);
417 static int save_arch_std_events(void *data __unused, char *name, const char *event,
418 char *desc, char *long_desc, char *pmu,
419 char *unit, char *perpkg, char *metric_expr,
420 char *metric_name, char *metric_group)
422 struct event_struct *es;
424 es = malloc(sizeof(*es));
427 memset(es, 0, sizeof(*es));
428 FOR_ALL_EVENT_STRUCT_FIELDS(ADD_EVENT_FIELD);
429 list_add_tail(&es->list, &arch_std_events);
432 FOR_ALL_EVENT_STRUCT_FIELDS(FREE_EVENT_FIELD);
437 static void print_events_table_suffix(FILE *outfp)
439 fprintf(outfp, "{\n");
441 fprintf(outfp, "\t.name = 0,\n");
442 fprintf(outfp, "\t.event = 0,\n");
443 fprintf(outfp, "\t.desc = 0,\n");
445 fprintf(outfp, "},\n");
446 fprintf(outfp, "};\n");
450 static struct fixed {
454 { "inst_retired.any", "event=0xc0" },
455 { "inst_retired.any_p", "event=0xc0" },
456 { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
457 { "cpu_clk_unhalted.thread", "event=0x3c" },
458 { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
463 * Handle different fixed counter encodings between JSON and perf.
465 static const char *real_event(const char *name, char *event)
472 for (i = 0; fixed[i].name; i++)
473 if (!strcasecmp(name, fixed[i].name))
474 return fixed[i].event;
479 try_fixup(const char *fn, char *arch_std, char **event, char **desc,
480 char **name, char **long_desc, char **pmu, char **filter __unused,
481 char **perpkg, char **unit, char **metric_expr, char **metric_name,
482 char **metric_group, unsigned long long eventcode)
484 /* try to find matching event from arch standard values */
485 struct event_struct *es;
487 list_for_each_entry(es, &arch_std_events, list) {
488 if (!strcmp(arch_std, es->name)) {
489 if (!eventcode && es->event) {
490 /* allow EventCode to be overridden */
494 FOR_ALL_EVENT_STRUCT_FIELDS(TRY_FIXUP_FIELD);
499 pr_err("%s: could not find matching %s for %s\n",
504 /* Call func with each event in the json file */
505 int json_events(const char *fn,
506 int (*func)(void *data, char *name, const char *event, char *desc,
508 char *pmu, char *unit, char *perpkg,
510 char *metric_name, char *metric_group),
515 jsmntok_t *tokens, *tok;
523 tokens = parse_json(fn, &map, &size, &len);
526 EXPECT(tokens->type == JSMN_ARRAY, tokens, "expected top level array");
528 for (i = 0; i < tokens->size; i++) {
529 char *event = NULL, *desc = NULL, *name = NULL;
530 char *long_desc = NULL;
531 char *extra_desc = NULL;
536 char *metric_expr = NULL;
537 char *metric_name = NULL;
538 char *metric_group = NULL;
539 char *arch_std = NULL;
540 unsigned long long eventcode = 0;
541 struct msrmap *msr = NULL;
542 jsmntok_t *msrval = NULL;
543 jsmntok_t *precise = NULL;
544 jsmntok_t *obj = tok++;
546 EXPECT(obj->type == JSMN_OBJECT, obj, "expected object");
547 for (j = 0; j < obj->size; j += 2) {
548 jsmntok_t *field, *val;
553 EXPECT(field->type == JSMN_STRING, tok + j,
554 "Expected field name");
556 EXPECT(val->type == JSMN_STRING, tok + j + 1,
557 "Expected string value");
559 nz = !json_streq(map, val, "0");
560 if (match_field(map, field, nz, &event, val)) {
562 } else if (json_streq(map, field, "EventCode")) {
564 addfield(map, &code, "", "", val);
565 eventcode |= strtoul(code, NULL, 0);
567 } else if (json_streq(map, field, "ExtSel")) {
569 addfield(map, &code, "", "", val);
570 eventcode |= strtoul(code, NULL, 0) << 21;
572 } else if (json_streq(map, field, "EventName")) {
573 addfield(map, &name, "", "", val);
574 } else if (json_streq(map, field, "BriefDescription")) {
575 addfield(map, &desc, "", "", val);
577 } else if (json_streq(map, field,
578 "PublicDescription")) {
579 addfield(map, &long_desc, "", "", val);
581 } else if (json_streq(map, field, "PEBS") && nz) {
583 } else if (json_streq(map, field, "MSRIndex") && nz) {
584 msr = lookup_msr(map, val);
585 } else if (json_streq(map, field, "MSRValue")) {
587 } else if (json_streq(map, field, "Errata") &&
588 !json_streq(map, val, "null")) {
589 addfield(map, &extra_desc, ". ",
590 " Spec update: ", val);
591 } else if (json_streq(map, field, "Data_LA") && nz) {
592 addfield(map, &extra_desc, ". ",
593 " Supports address when precise",
595 } else if (json_streq(map, field, "Unit")) {
598 ppmu = field_to_perf(unit_to_pmu, map, val);
603 pmu = strdup("uncore_");
604 addfield(map, &pmu, "", "", val);
605 for (s = pmu; *s; s++)
608 addfield(map, &desc, ". ", "Unit: ", NULL);
609 addfield(map, &desc, "", pmu, NULL);
610 addfield(map, &desc, "", " ", NULL);
611 } else if (json_streq(map, field, "Filter")) {
612 addfield(map, &filter, "", "", val);
613 } else if (json_streq(map, field, "ScaleUnit")) {
614 addfield(map, &unit, "", "", val);
615 } else if (json_streq(map, field, "PerPkg")) {
616 addfield(map, &perpkg, "", "", val);
617 } else if (json_streq(map, field, "MetricName")) {
618 addfield(map, &metric_name, "", "", val);
619 } else if (json_streq(map, field, "MetricGroup")) {
620 addfield(map, &metric_group, "", "", val);
621 } else if (json_streq(map, field, "MetricExpr")) {
622 addfield(map, &metric_expr, "", "", val);
623 for (s = metric_expr; *s; s++)
625 } else if (json_streq(map, field, "ArchStdEvent")) {
626 addfield(map, &arch_std, "", "", val);
627 for (s = arch_std; *s; s++)
630 /* ignore unknown fields */
632 if (precise && desc && !strstr(desc, "(Precise Event)")) {
633 if (json_streq(map, precise, "2"))
634 addfield(map, &extra_desc, " ",
635 "(Must be precise)", NULL);
637 addfield(map, &extra_desc, " ",
638 "(Precise event)", NULL);
640 snprintf(buf, sizeof buf, "event=%#llx", eventcode);
641 addfield(map, &event, ",", buf, NULL);
642 if (desc && extra_desc)
643 addfield(map, &desc, " ", extra_desc, NULL);
644 if (long_desc && extra_desc)
645 addfield(map, &long_desc, " ", extra_desc, NULL);
647 addfield(map, &event, ",", filter, NULL);
649 addfield(map, &event, ",", msr->pname, msrval);
655 * An arch standard event is referenced, so try to
656 * fixup any unassigned values.
658 err = try_fixup(fn, arch_std, &event, &desc, &name,
659 &long_desc, &pmu, &filter, &perpkg,
660 &unit, &metric_expr, &metric_name,
661 &metric_group, eventcode);
665 err = func(data, name, real_event(name, event), desc, long_desc,
666 pmu, unit, perpkg, metric_expr, metric_name, metric_group);
686 EXPECT(tok - tokens == len, tok, "unexpected objects at end");
689 free_json(map, size, tokens);
693 static char *file_name_to_table_name(const char *fname)
702 * Ensure tablename starts with alphabetic character.
703 * Derive rest of table name from basename of the JSON file,
704 * replacing hyphens and stripping out .json suffix.
706 n = asprintf(&tblname, "pme_%s", fname);
708 pr_info("%s: asprintf() error %s for file %s\n", prog,
709 strerror(errno), fname);
713 for (i = 0; i < strlen(tblname); i++) {
716 if (c == '-' || c == '/')
721 } else if (!isalnum(c) && c != '_') {
722 char *tmp = strdup(fname);
723 pr_err("%s: Invalid character '%c' in file name %s\n",
724 prog, c, basename(tmp));
735 static void print_mapping_table_prefix(FILE *outfp)
737 fprintf(outfp, "struct pmu_events_map pmu_events_map[] = {\n");
740 static void print_mapping_table_suffix(FILE *outfp)
743 * Print the terminating, NULL entry.
745 fprintf(outfp, "{\n");
746 fprintf(outfp, "\t.cpuid = 0,\n");
747 fprintf(outfp, "\t.version = 0,\n");
748 fprintf(outfp, "\t.type = 0,\n");
749 fprintf(outfp, "\t.table = 0,\n");
750 fprintf(outfp, "},\n");
752 /* and finally, the closing curly bracket for the struct */
753 fprintf(outfp, "};\n");
756 static int process_mapfile(FILE *outfp, char *fpath)
765 pr_info("%s: Processing mapfile %s\n", prog, fpath);
771 mapfp = fopen(fpath, "r");
773 pr_info("%s: Error %s opening %s\n", prog, strerror(errno),
778 print_mapping_table_prefix(outfp);
780 /* Skip first line (header) */
781 p = fgets(line, n, mapfp);
787 char *cpuid, *version, *type, *fname;
790 p = fgets(line, n, mapfp);
794 if (line[0] == '#' || line[0] == '\n')
797 if (line[strlen(line)-1] != '\n') {
798 /* TODO Deal with lines longer than 16K */
799 pr_info("%s: Mapfile %s: line %d too long, aborting\n",
800 prog, fpath, line_num);
803 line[strlen(line)-1] = '\0';
805 cpuid = fixregex(strtok_r(p, ",", &save));
806 version = strtok_r(NULL, ",", &save);
807 fname = strtok_r(NULL, ",", &save);
808 type = strtok_r(NULL, ",", &save);
810 tblname = file_name_to_table_name(fname);
811 fprintf(outfp, "{\n");
812 fprintf(outfp, "\t.cpuid = \"%s\",\n", cpuid);
813 fprintf(outfp, "\t.version = \"%s\",\n", version);
814 fprintf(outfp, "\t.type = \"%s\",\n", type);
817 * CHECK: We can't use the type (eg "core") field in the
818 * table name. For us to do that, we need to somehow tweak
819 * the other caller of file_name_to_table(), process_json()
820 * to determine the type. process_json() file has no way
821 * of knowing these are "core" events unless file name has
822 * core in it. If filename has core in it, we can safely
823 * ignore the type field here also.
825 fprintf(outfp, "\t.table = %s\n", tblname);
826 fprintf(outfp, "},\n");
830 print_mapping_table_suffix(outfp);
835 * If we fail to locate/process JSON and map files, create a NULL mapping
836 * table. This would at least allow perf to build even if we can't find/use
839 static void create_empty_mapping(const char *output_file)
843 pr_info("%s: Creating empty pmu_events_map[] table\n", prog);
845 /* Truncate file to clear any partial writes to it */
846 outfp = fopen(output_file, "w");
852 fprintf(outfp, "#include \"pmu-events/pmu-events.h\"\n");
853 print_mapping_table_prefix(outfp);
854 print_mapping_table_suffix(outfp);
858 static int get_maxfds(void)
862 if (getrlimit(RLIMIT_NOFILE, &rlim) == 0)
863 return min((int)rlim.rlim_max / 2, 512);
869 * nftw() doesn't let us pass an argument to the processing function,
870 * so use a global variables.
872 static FILE *eventsfp;
873 static char *mapfile;
875 static int is_leaf_dir(const char *fpath)
885 while ((dir = readdir(d)) != NULL) {
886 if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
889 if (dir->d_type == DT_DIR) {
892 } else if (dir->d_type == DT_UNKNOWN) {
896 sprintf(path, "%s/%s", fpath, dir->d_name);
900 if (S_ISDIR(st.st_mode)) {
912 static int is_json_file(const char *name)
916 if (strlen(name) < 5)
919 suffix = name + strlen(name) - 5;
921 if (strncmp(suffix, ".json", 5) == 0)
926 static int preprocess_arch_std_files(const char *fpath, const struct stat *sb,
927 int typeflag, struct FTW *ftwbuf)
929 int level = ftwbuf->level;
930 int is_file = typeflag == FTW_F;
932 if (level == 1 && is_file && is_json_file(fpath))
933 return json_events(fpath, save_arch_std_events, (void *)(uintptr_t)sb);
938 static int process_one_file(const char *fpath, const struct stat *sb,
939 int typeflag, struct FTW *ftwbuf)
943 int is_dir = typeflag == FTW_D;
944 int is_file = typeflag == FTW_F;
945 int level = ftwbuf->level;
948 if (level == 2 && is_dir) {
950 * For level 2 directory, bname will include parent name,
951 * like vendor/platform. So search back from platform dir
954 bname = fpath + ftwbuf->base - 2;
962 bname = fpath + ftwbuf->base;
964 pr_debug("%s %d %7jd %-20s %s\n",
965 is_file ? "f" : is_dir ? "d" : "x",
966 level, sb->st_size, bname, fpath);
968 /* base dir or too deep */
969 if (level == 0 || level > 3)
973 /* model directory, reset topic */
974 if ((level == 1 && is_dir && is_leaf_dir(fpath)) ||
975 (level == 2 && is_dir)) {
977 print_events_table_suffix(eventsfp);
980 * Drop file name suffix. Replace hyphens with underscores.
981 * Fail if file name contains any alphanum characters besides
984 tblname = file_name_to_table_name(bname);
986 pr_info("%s: Error determining table name for %s\n", prog,
991 print_events_table_prefix(eventsfp, tblname);
996 * Save the mapfile name for now. We will process mapfile
997 * after processing all JSON files (so we can write out the
998 * mapping table after all PMU events tables).
1001 if (level == 1 && is_file) {
1002 if (!strcmp(bname, "mapfile.csv")) {
1003 mapfile = strdup(fpath);
1007 pr_info("%s: Ignoring file %s\n", prog, fpath);
1012 * If the file name does not have a .json extension,
1013 * ignore it. It could be a readme.txt for instance.
1016 if (!is_json_file(bname)) {
1017 pr_info("%s: Ignoring file without .json suffix %s\n", prog,
1023 if (level > 1 && add_topic(bname))
1027 * Assume all other files are JSON files.
1029 * If mapfile refers to 'power7_core.json', we create a table
1030 * named 'power7_core'. Any inconsistencies between the mapfile
1031 * and directory tree could result in build failure due to table
1032 * names not being found.
1034 * Atleast for now, be strict with processing JSON file names.
1035 * i.e. if JSON file name cannot be mapped to C-style table name,
1039 struct perf_entry_data data = {
1040 .topic = get_topic(),
1044 err = json_events(fpath, print_events_table_entry, &data);
1053 #define PATH_MAX 4096
1057 * Starting in directory 'start_dirname', find the "mapfile.csv" and
1058 * the set of JSON files for the architecture 'arch'.
1060 * From each JSON file, create a C-style "PMU events table" from the
1061 * JSON file (see struct pmu_event).
1063 * From the mapfile, create a mapping between the CPU revisions and
1064 * PMU event tables (see struct pmu_events_map).
1066 * Write out the PMU events tables and the mapping table to pmu-event.c.
1068 int main(int argc, char *argv[])
1072 char ldirname[PATH_MAX];
1075 const char *output_file;
1076 const char *start_dirname;
1079 prog = basename(argv[0]);
1081 pr_err("Usage: %s <arch> <starting_dir> <output_file>\n", prog);
1086 start_dirname = argv[2];
1087 output_file = argv[3];
1090 verbose = atoi(argv[4]);
1092 eventsfp = fopen(output_file, "w");
1094 pr_err("%s Unable to create required file %s (%s)\n",
1095 prog, output_file, strerror(errno));
1099 sprintf(ldirname, "%s/%s", start_dirname, arch);
1101 /* If architecture does not have any event lists, bail out */
1102 if (stat(ldirname, &stbuf) < 0) {
1103 pr_info("%s: Arch %s has no PMU event lists\n", prog, arch);
1107 /* Include pmu-events.h first */
1108 fprintf(eventsfp, "#include \"pmu-events/pmu-events.h\"\n");
1111 * The mapfile allows multiple CPUids to point to the same JSON file,
1112 * so, not sure if there is a need for symlinks within the pmu-events
1115 * For now, treat symlinks of JSON files as regular files and create
1116 * separate tables for each symlink (presumably, each symlink refers
1117 * to specific version of the CPU).
1120 maxfds = get_maxfds();
1122 rc = nftw(ldirname, preprocess_arch_std_files, maxfds, 0);
1123 if (rc && verbose) {
1124 pr_info("%s: Error preprocessing arch standard files %s\n",
1127 } else if (rc < 0) {
1128 /* Make build fail */
1129 free_arch_std_events();
1135 rc = nftw(ldirname, process_one_file, maxfds, 0);
1136 if (rc && verbose) {
1137 pr_info("%s: Error walking file tree %s\n", prog, ldirname);
1139 } else if (rc < 0) {
1140 /* Make build fail */
1141 free_arch_std_events();
1148 print_events_table_suffix(eventsfp);
1151 pr_info("%s: No CPU->JSON mapping?\n", prog);
1155 if (process_mapfile(eventsfp, mapfile)) {
1156 pr_info("%s: Error processing mapfile %s\n", prog, mapfile);
1157 /* Make build fail */
1165 create_empty_mapping(output_file);
1166 free_arch_std_events();