aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2017-07-24 20:16:38 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-07-25 21:46:36 -0400
commit3f056b66647bafc39f060a57289320765915972c (patch)
tree5e8c6ba82fc3e5743f7f39e93fb241a9b1200282
parenta1a8bed32de197801bb861fbf13cd01496df3e05 (diff)
perf jevents: Make build fail on JSON parse error
Today, when a JSON file fails parsing the build continues, but there are no json files built in, which is difficult to debug later. Make the build stop on a parse error instead. v2: Add fixes from Sukadev. Now we handle architectures with no JSON events correctly. And fix some stale comments. Committer note: Tested by running the cross build container tests, that were all failing for v1. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/20170725001638.19990-1-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/pmu-events/README4
-rw-r--r--tools/perf/pmu-events/jevents.c21
2 files changed, 14 insertions, 11 deletions
diff --git a/tools/perf/pmu-events/README b/tools/perf/pmu-events/README
index 1408ade0d773..c2ee3e4417fe 100644
--- a/tools/perf/pmu-events/README
+++ b/tools/perf/pmu-events/README
@@ -85,10 +85,6 @@ users to specify events by their name:
85 85
86where 'pm_1plus_ppc_cmpl' is a Power8 PMU event. 86where 'pm_1plus_ppc_cmpl' is a Power8 PMU event.
87 87
88In case of errors when processing files in the tools/perf/pmu-events/arch
89directory, 'jevents' tries to create an empty mapping file to allow the perf
90build to succeed even if the PMU event aliases cannot be used.
91
92However some errors in processing may cause the perf build to fail. 88However some errors in processing may cause the perf build to fail.
93 89
94Mapfile format 90Mapfile format
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index bd0aabb2bd0f..2350f6099a46 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -822,10 +822,6 @@ static int process_one_file(const char *fpath, const struct stat *sb,
822 * PMU event tables (see struct pmu_events_map). 822 * PMU event tables (see struct pmu_events_map).
823 * 823 *
824 * Write out the PMU events tables and the mapping table to pmu-event.c. 824 * Write out the PMU events tables and the mapping table to pmu-event.c.
825 *
826 * If unable to process the JSON or arch files, create an empty mapping
827 * table so we can continue to build/use perf even if we cannot use the
828 * PMU event aliases.
829 */ 825 */
830int main(int argc, char *argv[]) 826int main(int argc, char *argv[])
831{ 827{
@@ -836,6 +832,7 @@ int main(int argc, char *argv[])
836 const char *arch; 832 const char *arch;
837 const char *output_file; 833 const char *output_file;
838 const char *start_dirname; 834 const char *start_dirname;
835 struct stat stbuf;
839 836
840 prog = basename(argv[0]); 837 prog = basename(argv[0]);
841 if (argc < 4) { 838 if (argc < 4) {
@@ -857,11 +854,17 @@ int main(int argc, char *argv[])
857 return 2; 854 return 2;
858 } 855 }
859 856
857 sprintf(ldirname, "%s/%s", start_dirname, arch);
858
859 /* If architecture does not have any event lists, bail out */
860 if (stat(ldirname, &stbuf) < 0) {
861 pr_info("%s: Arch %s has no PMU event lists\n", prog, arch);
862 goto empty_map;
863 }
864
860 /* Include pmu-events.h first */ 865 /* Include pmu-events.h first */
861 fprintf(eventsfp, "#include \"../../pmu-events/pmu-events.h\"\n"); 866 fprintf(eventsfp, "#include \"../../pmu-events/pmu-events.h\"\n");
862 867
863 sprintf(ldirname, "%s/%s", start_dirname, arch);
864
865 /* 868 /*
866 * The mapfile allows multiple CPUids to point to the same JSON file, 869 * The mapfile allows multiple CPUids to point to the same JSON file,
867 * so, not sure if there is a need for symlinks within the pmu-events 870 * so, not sure if there is a need for symlinks within the pmu-events
@@ -878,6 +881,9 @@ int main(int argc, char *argv[])
878 if (rc && verbose) { 881 if (rc && verbose) {
879 pr_info("%s: Error walking file tree %s\n", prog, ldirname); 882 pr_info("%s: Error walking file tree %s\n", prog, ldirname);
880 goto empty_map; 883 goto empty_map;
884 } else if (rc < 0) {
885 /* Make build fail */
886 return 1;
881 } else if (rc) { 887 } else if (rc) {
882 goto empty_map; 888 goto empty_map;
883 } 889 }
@@ -892,7 +898,8 @@ int main(int argc, char *argv[])
892 898
893 if (process_mapfile(eventsfp, mapfile)) { 899 if (process_mapfile(eventsfp, mapfile)) {
894 pr_info("%s: Error processing mapfile %s\n", prog, mapfile); 900 pr_info("%s: Error processing mapfile %s\n", prog, mapfile);
895 goto empty_map; 901 /* Make build fail */
902 return 1;
896 } 903 }
897 904
898 return 0; 905 return 0;