• Ian Rogers's avatar
    perf jevents: Add python converter script · ffc606ad
    Ian Rogers authored
    jevents.c is large, has a dependency on an old forked version of jsmn,
    and is challenging to work upon. A lot of jevents.c's complexity comes
    from needing to write json and csv parsing from first principles. In
    contrast python has this functionality in standard libraries and is
    already a build pre-requisite for tools like asciidoc (that builds all
    of the perf man pages).
    
    Introduce jevents.py that produces identical output to jevents.c. Add a
    test that runs both converter tools and validates there are no output
    differences. The test can be invoked with a phony build target like:
    
      $ make -C tools/perf jevents-py-test
    
    The python code deliberately tries to replicate the behavior of
    jevents.c so that the output matches and transitioning tools shouldn't
    introduce regressions. In some cases the code isn't as elegant as hoped,
    but fixing this can be done as follow up.
    
    Committer testing:
    
      $ make -C tools/perf jevents-py-test
      make: Entering directory '/var/home/acme/git/perf/tools/perf'
        BUILD:   Doing 'make -j32' parallel build
        HOSTCC  fixdep.o
        HOSTLD  fixdep-in.o
        LINK    fixdep
    
      Auto-detecting system features:
      ...                         dwarf: [ on  ]
      ...            dwarf_getlocations: [ on  ]
      ...                         glibc: [ on  ]
      ...                        libbfd: [ on  ]
      ...                libbfd-buildid: [ on  ]
      ...                        libcap: [ on  ]
      ...                        libelf: [ on  ]
      ...                       libnuma: [ on  ]
      ...        numa_num_possible_cpus: [ on  ]
      ...                       libperl: [ on  ]
      ...                     libpython: [ on  ]
      ...                     libcrypto: [ OFF ]
      ...                     libunwind: [ on  ]
      ...            libdw-dwarf-unwind: [ on  ]
      ...                          zlib: [ on  ]
      ...                          lzma: [ on  ]
      ...                     get_cpuid: [ on  ]
      ...                           bpf: [ on  ]
      ...                        libaio: [ on  ]
      ...                       libzstd: [ on  ]
      ...        disassembler-four-args: [ on  ]
    
        HOSTCC  pmu-events/json.o
        HOSTCC  pmu-events/jsmn.o
        HOSTCC  pmu-events/jevents.o
        HOSTLD  pmu-events/jevents-in.o
        LINK    pmu-events/jevents
      Checking architecture: arm64
      Generating using jevents.c
      Generating using jevents.py
      Diffing
      Checking architecture: nds32
      Generating using jevents.c
      Generating using jevents.py
      Diffing
      Checking architecture: powerpc
      Generating using jevents.c
      Generating using jevents.py
      Diffing
      Checking architecture: s390
      Generating using jevents.c
      Generating using jevents.py
      Diffing
      Checking architecture: x86
      Generating using jevents.c
      Generating using jevents.py
      Diffing
      make: Leaving directory '/var/home/acme/git/perf/tools/perf'
      $
    Signed-off-by: default avatarIan Rogers <irogers@google.com>
    Tested-by: default avatarJohn Garry <john.garry@huawei.com>
    Tested-by: default avatarThomas Richter <tmricht@linux.ibm.com>
    Tested-by: default avatarXing Zhengjun <zhengjun.xing@linux.intel.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ananth Narayan <ananth.narayan@amd.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Andrew Kilroy <andrew.kilroy@arm.com>
    Cc: Caleb Biggers <caleb.biggers@intel.com>
    Cc: Felix Fietkau <nbd@nbd.name>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
    Cc: Like Xu <likexu@tencent.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Nick Forrington <nick.forrington@arm.com>
    Cc: Paul Clarke <pc@us.ibm.com>
    Cc: Perry Taylor <perry.taylor@intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Qi Liu <liuqi115@huawei.com>
    Cc: Ravi Bangoria <ravi.bangoria@amd.com>
    Cc: Sandipan Das <sandipan.das@amd.com>
    Cc: Santosh Shukla <santosh.shukla@amd.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Will Deacon <will@kernel.org>
    Link: https://lore.kernel.org/r/20220629182505.406269-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    ffc606ad
Makefile.perf 40.2 KB