1. 09 9月, 2022 3 次提交
    • J
      perf tools: Don't install data files with x permissions · 0a9eaf61
      Jiri Slaby 提交于
      install(1), by default, installs with rwxr-xr-x permissions. Modify
      perf's Makefile to pass '-m 644' when installing:
      
        * Documentation/tips.txt
        * examples/bpf/*
        * perf-completion.sh
        * perf_dlfilter.h header
        * scripts/perl/Perf-Trace-Util/lib/Perf/Trace/*
        * scripts/perl/*.pl
        * tests/attr/*
        * tests/attr.py
        * tests/shell/lib/*.sh
        * trace/strace/groups/*
      
      All those are supposed to be non-executable. Either they are not scripts
      at all, or they don't have shebang.
      
      Signed-off-by: <jslaby@suse.cz>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220908060426.9619-1-jslaby@suse.czSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0a9eaf61
    • Z
      perf script: Fix Cannot print 'iregs' field for hybrid systems · 82b2425f
      Zhengjun Xing 提交于
      Commit b91e5492 ("perf record: Add a dummy event on hybrid
      systems to collect metadata records") adds a dummy event on hybrid
      systems to fix the symbol "unknown" issue when the workload is created
      in a P-core but runs on an E-core. The added dummy event will cause
      "perf script -F iregs" to fail. Dummy events do not have "iregs"
      attribute set, so when we do evsel__check_attr, the "iregs" attribute
      check will fail, so the issue happened.
      
      The following commit [1] has fixed a similar issue by skipping the attr
      check for the dummy event because it does not have any samples anyway. It
      works okay for the normal mode, but the issue still happened when running
      the test in the pipe mode. In the pipe mode, it calls process_attr() which
      still checks the attr for the dummy event. This commit fixed the issue by
      skipping the attr check for the dummy event in the API evsel__check_attr,
      Otherwise, we have to patch everywhere when evsel__check_attr() is called.
      
      Before:
      
        #./perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf script -F iregs |head -5
        Samples for 'dummy:HG' event do not have IREGS attribute set. Cannot print 'iregs' field.
        0x120 [0x90]: failed to process type: 64
        #
      
      After:
      
        # ./perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p -c 1000 --per-thread true 2>/dev/null|./perf script -F iregs |head -5
        ABI:2    CX:0x55b8efa87000    DX:0x55b8efa7e000    DI:0xffffba5e625efbb0    R8:0xffff90e51f8ae100
        ABI:2    CX:0x7f1dae1e4000    DX:0xd0    DI:0xffff90e18c675ac0    R8:0x71
        ABI:2    CX:0xcc0    DX:0x1    DI:0xffff90e199880240    R8:0x0
        ABI:2    CX:0xffff90e180dd7500    DX:0xffff90e180dd7500    DI:0xffff90e180043500    R8:0x1
        ABI:2    CX:0x50    DX:0xffff90e18c583bd0    DI:0xffff90e1998803c0    R8:0x58
        #
      
      [1]https://lore.kernel.org/lkml/20220831124041.219925-1-jolsa@kernel.org/
      
      Fixes: b91e5492 ("perf record: Add a dummy event on hybrid systems to collect metadata records")
      Suggested-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NXing Zhengjun <zhengjun.xing@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220908070030.3455164-1-zhengjun.xing@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      82b2425f
    • Y
      perf lock: Remove redundant word 'contention' in help message · 3705a6ef
      Yang Jihong 提交于
      Before:
        # perf lock -h
      
         Usage: perf lock [<options>] {record|report|script|info|contention|contention}
      
            -D, --dump-raw-trace  dump raw trace in ASCII
            -f, --force           don't complain, do it
            -i, --input <file>    input file name
            -v, --verbose         be more verbose (show symbol address, etc)
                --kallsyms <file>
                                  kallsyms pathname
                --vmlinux <file>  vmlinux pathname
      
      After:
        # perf lock -h
      
         Usage: perf lock [<options>] {record|report|script|info|contention}
      
            -D, --dump-raw-trace  dump raw trace in ASCII
            -f, --force           don't complain, do it
            -i, --input <file>    input file name
            -v, --verbose         be more verbose (show symbol address, etc)
                --kallsyms <file>
                                  kallsyms pathname
                --vmlinux <file>  vmlinux pathname
      
      Fixes: 528b9cab ("perf lock: Add 'contention' subcommand")
      Signed-off-by: NYang Jihong <yangjihong1@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220908014854.151203-1-yangjihong1@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3705a6ef
  2. 08 9月, 2022 2 次提交
    • A
      perf dlfilter dlfilter-show-cycles: Fix types for print format · 1706623e
      Adrian Hunter 提交于
      Avoid compiler warning about format %llu that expects long long unsigned
      int but argument has type __u64.
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Fixes: c3afd6e5 ("perf dlfilter: Add dlfilter-show-cycles")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20220905074735.4513-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1706623e
    • A
      libperf evlist: Fix per-thread mmaps for multi-threaded targets · 7864d8f7
      Adrian Hunter 提交于
      The offending commit removed mmap_per_thread(), which did not consider
      the different set-output rules for per-thread mmaps i.e. in the per-thread
      case set-output is used for file descriptors of the same thread not the
      same cpu.
      
      This was not immediately noticed because it only happens with
      multi-threaded targets and we do not have a test for that yet.
      
      Reinstate mmap_per_thread() expanding it to cover also system-wide per-cpu
      events i.e. to continue to allow the mixing of per-thread and per-cpu
      mmaps.
      
      Debug messages (with -vv) show the file descriptors that are opened with
      sys_perf_event_open. New debug messages are added (needs -vvv) that show
      also which file descriptors are mmapped and which are redirected with
      set-output.
      
      In the per-cpu case (cpu != -1) file descriptors for the same CPU are
      set-output to the first file descriptor for that CPU.
      
      In the per-thread case (cpu == -1) file descriptors for the same thread are
      set-output to the first file descriptor for that thread.
      
      Example (process 17489 has 2 threads):
      
       Before (but with new debug prints):
      
         $ perf record --no-bpf-event -vvv --per-thread -p 17489
         <SNIP>
         sys_perf_event_open: pid 17489  cpu -1  group_fd -1  flags 0x8 = 5
         sys_perf_event_open: pid 17490  cpu -1  group_fd -1  flags 0x8 = 6
         <SNIP>
         libperf: idx 0: mmapping fd 5
         libperf: idx 0: set output fd 6 -> 5
         failed to mmap with 22 (Invalid argument)
      
       After:
      
         $ perf record --no-bpf-event -vvv --per-thread -p 17489
         <SNIP>
         sys_perf_event_open: pid 17489  cpu -1  group_fd -1  flags 0x8 = 5
         sys_perf_event_open: pid 17490  cpu -1  group_fd -1  flags 0x8 = 6
         <SNIP>
         libperf: mmap_per_thread: nr cpu values (may include -1) 1 nr threads 2
         libperf: idx 0: mmapping fd 5
         libperf: idx 1: mmapping fd 6
         <SNIP>
         [ perf record: Woken up 2 times to write data ]
         [ perf record: Captured and wrote 0.018 MB perf.data (15 samples) ]
      
      Per-cpu example (process 20341 has 2 threads, same as above):
      
         $ perf record --no-bpf-event -vvv -p 20341
         <SNIP>
         sys_perf_event_open: pid 20341  cpu 0  group_fd -1  flags 0x8 = 5
         sys_perf_event_open: pid 20342  cpu 0  group_fd -1  flags 0x8 = 6
         sys_perf_event_open: pid 20341  cpu 1  group_fd -1  flags 0x8 = 7
         sys_perf_event_open: pid 20342  cpu 1  group_fd -1  flags 0x8 = 8
         sys_perf_event_open: pid 20341  cpu 2  group_fd -1  flags 0x8 = 9
         sys_perf_event_open: pid 20342  cpu 2  group_fd -1  flags 0x8 = 10
         sys_perf_event_open: pid 20341  cpu 3  group_fd -1  flags 0x8 = 11
         sys_perf_event_open: pid 20342  cpu 3  group_fd -1  flags 0x8 = 12
         sys_perf_event_open: pid 20341  cpu 4  group_fd -1  flags 0x8 = 13
         sys_perf_event_open: pid 20342  cpu 4  group_fd -1  flags 0x8 = 14
         sys_perf_event_open: pid 20341  cpu 5  group_fd -1  flags 0x8 = 15
         sys_perf_event_open: pid 20342  cpu 5  group_fd -1  flags 0x8 = 16
         sys_perf_event_open: pid 20341  cpu 6  group_fd -1  flags 0x8 = 17
         sys_perf_event_open: pid 20342  cpu 6  group_fd -1  flags 0x8 = 18
         sys_perf_event_open: pid 20341  cpu 7  group_fd -1  flags 0x8 = 19
         sys_perf_event_open: pid 20342  cpu 7  group_fd -1  flags 0x8 = 20
         <SNIP>
         libperf: mmap_per_cpu: nr cpu values 8 nr threads 2
         libperf: idx 0: mmapping fd 5
         libperf: idx 0: set output fd 6 -> 5
         libperf: idx 1: mmapping fd 7
         libperf: idx 1: set output fd 8 -> 7
         libperf: idx 2: mmapping fd 9
         libperf: idx 2: set output fd 10 -> 9
         libperf: idx 3: mmapping fd 11
         libperf: idx 3: set output fd 12 -> 11
         libperf: idx 4: mmapping fd 13
         libperf: idx 4: set output fd 14 -> 13
         libperf: idx 5: mmapping fd 15
         libperf: idx 5: set output fd 16 -> 15
         libperf: idx 6: mmapping fd 17
         libperf: idx 6: set output fd 18 -> 17
         libperf: idx 7: mmapping fd 19
         libperf: idx 7: set output fd 20 -> 19
         <SNIP>
         [ perf record: Woken up 7 times to write data ]
         [ perf record: Captured and wrote 0.020 MB perf.data (17 samples) ]
      
      Fixes: ae4f8ae1 ("libperf evlist: Allow mixing per-thread and per-cpu mmaps")
      Reported-by: NTomáš Trnka <trnka@scm.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216441Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220905114209.8389-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7864d8f7
  3. 06 9月, 2022 4 次提交
  4. 03 9月, 2022 1 次提交
    • Z
      perf stat: Fix L2 Topdown metrics disappear for raw events · f0c86a2b
      Zhengjun Xing 提交于
      In perf/Documentation/perf-stat.txt, for "--td-level" the default "0" means
      the max level that the current hardware support.
      
      So we need initialize the stat_config.topdown_level to TOPDOWN_MAX_LEVEL
      when “--td-level=0” or no “--td-level” option. Otherwise, for the
      hardware with a max level is 2, the 2nd level metrics disappear for raw
      events in this case.
      
      The issue cannot be observed for the perf stat default or "--topdown"
      options. This commit fixes the raw events issue and removes the
      duplicated code for the perf stat default.
      
      Before:
      
       # ./perf stat -e "cpu-clock,context-switches,cpu-migrations,page-faults,instructions,cycles,ref-cycles,branches,branch-misses,{slots,topdown-retiring,topdown-bad-spec,topdown-fe-bound,topdown-be-bound,topdown-heavy-ops,topdown-br-mispredict,topdown-fetch-lat,topdown-mem-bound}" sleep 1
      
       Performance counter stats for 'sleep 1':
      
                    1.03 msec cpu-clock                        #    0.001 CPUs utilized
                       1      context-switches                 #  966.216 /sec
                       0      cpu-migrations                   #    0.000 /sec
                      60      page-faults                      #   57.973 K/sec
               1,132,112      instructions                     #    1.41  insn per cycle
                 803,872      cycles                           #    0.777 GHz
               1,909,120      ref-cycles                       #    1.845 G/sec
                 236,634      branches                         #  228.640 M/sec
                   6,367      branch-misses                    #    2.69% of all branches
               4,823,232      slots                            #    4.660 G/sec
               1,210,536      topdown-retiring                 #     25.1% Retiring
                 699,841      topdown-bad-spec                 #     14.5% Bad Speculation
               1,777,975      topdown-fe-bound                 #     36.9% Frontend Bound
               1,134,878      topdown-be-bound                 #     23.5% Backend Bound
                 189,146      topdown-heavy-ops                #  182.756 M/sec
                 662,012      topdown-br-mispredict            #  639.647 M/sec
               1,097,048      topdown-fetch-lat                #    1.060 G/sec
                 416,121      topdown-mem-bound                #  402.063 M/sec
      
             1.002423690 seconds time elapsed
      
             0.002494000 seconds user
             0.000000000 seconds sys
      
      After:
      
       # ./perf stat -e "cpu-clock,context-switches,cpu-migrations,page-faults,instructions,cycles,ref-cycles,branches,branch-misses,{slots,topdown-retiring,topdown-bad-spec,topdown-fe-bound,topdown-be-bound,topdown-heavy-ops,topdown-br-mispredict,topdown-fetch-lat,topdown-mem-bound}" sleep 1
      
       Performance counter stats for 'sleep 1':
      
                    1.13 msec cpu-clock                        #    0.001 CPUs utilized
                       1      context-switches                 #  882.128 /sec
                       0      cpu-migrations                   #    0.000 /sec
                      61      page-faults                      #   53.810 K/sec
               1,137,612      instructions                     #    1.29  insn per cycle
                 881,477      cycles                           #    0.778 GHz
               2,093,496      ref-cycles                       #    1.847 G/sec
                 236,356      branches                         #  208.496 M/sec
                   7,090      branch-misses                    #    3.00% of all branches
               5,288,862      slots                            #    4.665 G/sec
               1,223,697      topdown-retiring                 #     23.1% Retiring
                 767,403      topdown-bad-spec                 #     14.5% Bad Speculation
               2,053,322      topdown-fe-bound                 #     38.8% Frontend Bound
               1,244,438      topdown-be-bound                 #     23.5% Backend Bound
                 186,665      topdown-heavy-ops                #      3.5% Heavy Operations       #     19.6% Light Operations
                 725,922      topdown-br-mispredict            #     13.7% Branch Mispredict      #      0.8% Machine Clears
               1,327,400      topdown-fetch-lat                #     25.1% Fetch Latency          #     13.7% Fetch Bandwidth
                 497,775      topdown-mem-bound                #      9.4% Memory Bound           #     14.1% Core Bound
      
             1.002701530 seconds time elapsed
      
             0.002744000 seconds user
             0.000000000 seconds sys
      
      Fixes: 63e39aa6 ("perf stat: Support L2 Topdown events")
      Reviewed-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NXing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220826140057.3289401-1-zhengjun.xing@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f0c86a2b
  5. 01 9月, 2022 1 次提交
  6. 31 8月, 2022 1 次提交
    • I
      perf metric: Return early if no CPU PMU table exists · 3f5df3ac
      Ian Rogers 提交于
      Previous behavior is to segfault if there is no CPU PMU table and a
      metric is sought. To reproduce compile with NO_JEVENTS=1 then request a
      metric, for example, "perf stat -M IPC true".
      
      Committer testing:
      
      Before:
      
        $ make -k NO_JEVENTS=1 BUILD_BPF_SKEL=1 O=/tmp/build/perf-urgent -C tools/perf install-bin
        $ perf stat -M IPC true
        Segmentation fault (core dumped)
        $
      
      After:
      
        $ perf stat -M IPC true
      
         Usage: perf stat [<options>] [<command>]
      
            -M, --metrics <metric/metric group list>
                                  monitor specified metrics or metric groups (separated by ,)
        $
      
      Fixes: 00facc76 ("perf jevents: Switch build to use jevents.py")
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ian Rogers <rogers.email@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miaoqian Lin <linmq006@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220830164846.401143-3-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3f5df3ac
  7. 27 8月, 2022 8 次提交
  8. 25 8月, 2022 1 次提交
  9. 23 8月, 2022 2 次提交
    • J
      selftests: include bonding tests into the kselftest infra · c078290a
      Jonathan Toppins 提交于
      This creates a test collection in drivers/net/bonding for bonding
      specific kernel selftests.
      
      The first test is a reproducer that provisions a bond and given the
      specific order in how the ip-link(8) commands are issued the bond never
      transmits an LACPDU frame on any of its slaves.
      Signed-off-by: NJonathan Toppins <jtoppins@redhat.com>
      Acked-by: NJay Vosburgh <jay.vosburgh@canonical.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      c078290a
    • Y
      perf tools: Fix compile error for x86 · cfd2b5c1
      Yang Jihong 提交于
      Commit a0a12c3e ("asm goto: eradicate CC_HAS_ASM_GOTO") eradicates
      CC_HAS_ASM_GOTO, and in the process also causes the perf tool on x86 to
      use asm_volatile_goto when compiling __GEN_RMWcc.
      
      However, asm_volatile_goto is not declared in the perf tool headers,
      which causes a compilation error:
      
        In file included from tools/arch/x86/include/asm/atomic.h:7,
                         from tools/include/asm/atomic.h:6,
                         from tools/include/linux/atomic.h:5,
                         from tools/include/linux/refcount.h:41,
                         from tools/lib/perf/include/internal/cpumap.h:5,
                         from tools/perf/util/cpumap.h:7,
                         from tools/perf/util/env.h:7,
                         from tools/perf/util/header.h:12,
                         from pmu-events/pmu-events.c:9:
        tools/arch/x86/include/asm/atomic.h: In function ‘atomic_dec_and_test’:
        tools/arch/x86/include/asm/rmwcc.h:7:2: error: implicit declaration of function ‘asm_volatile_goto’ [-Werror=implicit-function-declaration]
          asm_volatile_goto (fullop "; j" cc " %l[cc_label]"  \
          ^~~~~~~~~~~~~~~~~
      
      Define asm_volatile_goto in compiler_types.h if not declared, like the
      main kernel header files do.
      
      Fixes: a0a12c3e ("asm goto: eradicate CC_HAS_ASM_GOTO")
      Signed-off-by: NYang Jihong <yangjihong1@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cfd2b5c1
  10. 22 8月, 2022 1 次提交
  11. 20 8月, 2022 16 次提交
    • A
      selftests/vm: fix inability to build any vm tests · bdbf0617
      Axel Rasmussen 提交于
      When we stopped using KSFT_KHDR_INSTALL, a side effect is we also
      changed the value of `top_srcdir`. This can be seen by looking at the
      code removed by commit 49de12ba
      ("selftests: drop KSFT_KHDR_INSTALL make target").
      
      (Note though that this commit didn't break this, technically the one
      before it did since that's the one that stopped KSFT_KHDR_INSTALL from
      being used, even though the code was still there.)
      
      Previously lib.mk reconfigured `top_srcdir` when KSFT_KHDR_INSTALL was
      being used. Now, that's no longer the case.
      
      As a result, the path to gup_test.h in vm/Makefile was wrong, and
      since it's a dependency of all of the vm binaries none of them could
      be built. Instead, we'd get an "error" like:
      
          make[1]: *** No rule to make target
              '/[...]/tools/testing/selftests/vm/compaction_test', needed by
      	'all'.  Stop.
      
      So, modify lib.mk so it once again sets top_srcdir to the root of the
      kernel tree.
      
      Fixes: f2745dc0 ("selftests: stop using KSFT_KHDR_INSTALL")
      Signed-off-by: NAxel Rasmussen <axelrasmussen@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      bdbf0617
    • N
      perf tools: Support reading PERF_FORMAT_LOST · f52679b7
      Namhyung Kim 提交于
      The recent kernel added lost count can be read from either read(2) or
      ring buffer data with PERF_SAMPLE_READ.  As it's a variable length data
      we need to access it according to the format info.
      
      But for perf tools use cases, PERF_FORMAT_ID is always set.  So we can
      only check PERF_FORMAT_LOST bit to determine the data format.
      
      Add sample_read_value_size() and next_sample_read_value() helpers to
      make it a bit easier to access.  Use them in all places where it reads
      the struct sample_read_value.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-5-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f52679b7
    • N
      libperf: Add a test case for read formats · 6d395a51
      Namhyung Kim 提交于
      It checks a various combination of the read format settings and verify
      it return the value in a proper position.  The test uses task-clock
      software events to guarantee it's always active and sets enabled/running
      time.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-4-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6d395a51
    • N
      libperf: Handle read format in perf_evsel__read() · 89e3106f
      Namhyung Kim 提交于
      The perf_counts_values should be increased to read the new lost data.
      Also adjust values after read according the read format.
      
      This supports PERF_FORMAT_GROUP which has a different data format but
      it's only available for leader events.  Currently it doesn't have an API
      to read sibling (member) events in the group.  But users may read the
      sibling event directly.
      
      Also reading from mmap would be disabled when the read format has ID or
      LOST bit as it's not exposed via mmap.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-3-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      89e3106f
    • N
      tools headers UAPI: Sync linux/perf_event.h with the kernel sources · 65ba872a
      Namhyung Kim 提交于
      To pick the trivial change in:
      
        119a784c ("perf/core: Add a new read format to get a number of lost samples")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-2-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      65ba872a
    • A
      tools headers UAPI: Sync x86's asm/kvm.h with the kernel sources · e5bc0dea
      Arnaldo Carvalho de Melo 提交于
      To pick the changes in:
      
        43bb9e00 ("KVM: x86: Tweak name of MONITOR/MWAIT #UD quirk to make it #UD specific")
        94dfc73e ("treewide: uapi: Replace zero-length arrays with flexible-array members")
        bfbcc81b ("KVM: x86: Add a quirk for KVM's "MONITOR/MWAIT are NOPs!" behavior")
        b1728622 ("KVM: x86: PIT: Preserve state of speaker port data bit")
        ed235117 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
      
      That just rebuilds kvm-stat.c on x86, no change in functionality.
      
      This silences these perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/kvm.h' differs from latest version at 'arch/x86/include/uapi/asm/kvm.h'
        diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
      
      Cc: Chenyi Qiang <chenyi.qiang@intel.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul Durrant <pdurrant@amazon.com>
      Link: https://lore.kernel.org/lkml/Yv6OMPKYqYSbUxwZ@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e5bc0dea
    • A
      tools headers UAPI: Sync KVM's vmx.h header with the kernel sources · eea085d1
      Arnaldo Carvalho de Melo 提交于
      To pick the changes in:
      
        2f4073e0 ("KVM: VMX: Enable Notify VM exit")
      
      That makes 'perf kvm-stat' aware of this new NOTIFY exit reason, thus
      addressing the following perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/vmx.h' differs from latest version at 'arch/x86/include/uapi/asm/vmx.h'
        diff -u tools/arch/x86/include/uapi/asm/vmx.h arch/x86/include/uapi/asm/vmx.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Tao Xu <tao3.xu@intel.com>
      Link: http://lore.kernel.org/lkml/Yv6LavXMZ+njijpq@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      eea085d1
    • A
      tools include UAPI: Sync linux/vhost.h with the kernel sources · 898d2403
      Arnaldo Carvalho de Melo 提交于
      To get the changes in:
      
        f345a014 ("vhost-vdpa: uAPI to suspend the device")
      
      Silencing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/vhost.h' differs from latest version at 'include/uapi/linux/vhost.h'
        diff -u tools/include/uapi/linux/vhost.h include/uapi/linux/vhost.h
      
      To pick up these changes and support them:
      
        $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
        $ cp include/uapi/linux/vhost.h tools/include/uapi/linux/vhost.h
        $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
        $ diff -u before after
        --- before	2022-08-18 09:46:12.355958316 -0300
        +++ after	2022-08-18 09:46:19.701182822 -0300
        @@ -29,6 +29,7 @@
         	[0x75] = "VDPA_SET_VRING_ENABLE",
         	[0x77] = "VDPA_SET_CONFIG_CALL",
         	[0x7C] = "VDPA_SET_GROUP_ASID",
        +	[0x7D] = "VDPA_SUSPEND",
         };
         = {
         	[0x00] = "GET_FEATURES",
        $
      
      For instance, see how those 'cmd' ioctl arguments get translated, now
      VDPA_SUSPEND will be as well:
      
        # perf trace -a -e ioctl --max-events=10
             0.000 ( 0.011 ms): pipewire/2261 ioctl(fd: 60, cmd: SNDRV_PCM_HWSYNC, arg: 0x1)                        = 0
            21.353 ( 0.014 ms): pipewire/2261 ioctl(fd: 60, cmd: SNDRV_PCM_HWSYNC, arg: 0x1)                        = 0
            25.766 ( 0.014 ms): gnome-shell/2196 ioctl(fd: 14, cmd: DRM_I915_IRQ_WAIT, arg: 0x7ffe4a22c740)            = 0
            25.845 ( 0.034 ms): gnome-shel:cs0/2212 ioctl(fd: 14, cmd: DRM_I915_IRQ_EMIT, arg: 0x7fd43915dc70)            = 0
            25.916 ( 0.011 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ADDFB2, arg: 0x7ffe4a22c8a0)               = 0
            25.941 ( 0.025 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ATOMIC, arg: 0x7ffe4a22c840)               = 0
            32.915 ( 0.009 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_RMFB, arg: 0x7ffe4a22cf9c)                 = 0
            42.522 ( 0.013 ms): gnome-shell/2196 ioctl(fd: 14, cmd: DRM_I915_IRQ_WAIT, arg: 0x7ffe4a22c740)            = 0
            42.579 ( 0.031 ms): gnome-shel:cs0/2212 ioctl(fd: 14, cmd: DRM_I915_IRQ_EMIT, arg: 0x7fd43915dc70)            = 0
            42.644 ( 0.010 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ADDFB2, arg: 0x7ffe4a22c8a0)               = 0
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Eugenio Pérez <eperezma@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/Yv6Kb4OESuNJuH6X@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      898d2403
    • A
      tools headers kvm s390: Sync headers with the kernel sources · 25f30895
      Arnaldo Carvalho de Melo 提交于
      To pick the changes in:
      
        f5ecfee9 ("KVM: s390: resetting the Topology-Change-Report")
      
      None of them trigger any changes in tooling, this time this is just to silence
      these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/kvm.h' differs from latest version at 'arch/s390/include/uapi/asm/kvm.h'
        diff -u tools/arch/s390/include/uapi/asm/kvm.h arch/s390/include/uapi/asm/kvm.h
      
      Cc: Janosch Frank <frankja@linux.ibm.com>
      Cc: Pierre Morel <pmorel@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/YvzwMXzaIzOU4WAY@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      25f30895
    • A
      tools headers UAPI: Sync linux/kvm.h with the kernel sources · bf465ca8
      Arnaldo Carvalho de Melo 提交于
      To pick the changes in:
      
        8a061562 ("RISC-V: KVM: Add extensible CSR emulation framework")
        f5ecfee9 ("KVM: s390: resetting the Topology-Change-Report")
        450a5639 ("KVM: stats: Fix value for KVM_STATS_UNIT_MAX for boolean stats")
        1b870fa5 ("kvm: stats: tell userspace which values are boolean")
        db1c875e ("KVM: s390: add KVM_S390_ZPCI_OP to manage guest zPCI devices")
        94dfc73e ("treewide: uapi: Replace zero-length arrays with flexible-array members")
        084cc29f ("KVM: x86/MMU: Allow NX huge pages to be disabled on a per-vm basis")
        2f4073e0 ("KVM: VMX: Enable Notify VM exit")
        ed235117 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
        e9bf3acb ("KVM: s390: Add KVM_CAP_S390_PROTECTED_DUMP")
        8aba0958 ("KVM: s390: Add CPU dump functionality")
        0460eb35 ("KVM: s390: Add configuration dump functionality")
        fe9a93e0 ("KVM: s390: pv: Add query dump information")
        35d02493 ("KVM: s390: pv: Add query interface")
        c24a950e ("KVM, SEV: Add KVM_EXIT_SHUTDOWN metadata for SEV-ES")
        ffbb61d0 ("KVM: x86: Accept KVM_[GS]ET_TSC_KHZ as a VM ioctl.")
        661a20fa ("KVM: x86/xen: Advertise and document KVM_XEN_HVM_CONFIG_EVTCHN_SEND")
        fde0451b ("KVM: x86/xen: Support per-vCPU event channel upcall via local APIC")
        28d1629f ("KVM: x86/xen: Kernel acceleration for XENVER_version")
        53639526 ("KVM: x86/xen: handle PV timers oneshot mode")
        942c2490 ("KVM: x86/xen: Add KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID")
        2fd6df2f ("KVM: x86/xen: intercept EVTCHNOP_send from guests")
        35025735 ("KVM: x86/xen: Support direct injection of event channel events")
      
      That just rebuilds perf, as these patches add just an ioctl that is S390
      specific and may clash with other arches, so are so far being excluded
      in the harvester script:
      
        $ tools/perf/trace/beauty/kvm_ioctl.sh > before
        $ cp include/uapi/linux/kvm.h tools/include/uapi/linux/kvm.h
        $ tools/perf/trace/beauty/kvm_ioctl.sh > after
        $ diff -u before after
        $ grep 390 tools/perf/trace/beauty/kvm_ioctl.sh
        	egrep -v " ((ARM|PPC|S390)_|[GS]ET_(DEBUGREGS|PIT2|XSAVE|TSC_KHZ)|CREATE_SPAPR_TCE_64)" | \
        $
      
      This is also by now used by tools/testing/selftests/kvm/, a simple test
      build succeeded.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Anup Patel <anup@brainfault.org>
      Cc: Ben Gardon <bgardon@google.com>
      Cc: Chenyi Qiang <chenyi.qiang@intel.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Janosch Frank <frankja@linux.ibm.com>
      Cc: João Martins <joao.m.martins@oracle.com>
      Cc: Matthew Rosato <mjrosato@linux.ibm.com>
      Cc: Oliver Upton <oupton@google.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Gonda <pgonda@google.com>
      Cc: Pierre Morel <pmorel@linux.ibm.com>
      Cc: Tao Xu <tao3.xu@intel.com>
      Link: https://lore.kernel.org/lkml/YvzuryClcn%2FvA0Gn@kernel.org/Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bf465ca8
    • A
      tools headers UAPI: Sync drm/i915_drm.h with the kernel sources · 54cd4cde
      Arnaldo Carvalho de Melo 提交于
      To pick up the changes in:
      
        a913bde8 ("drm/i915: Update i915 uapi documentation")
        525e93f6 ("drm/i915/uapi: add NEEDS_CPU_ACCESS hint")
        141f733b ("drm/i915/uapi: expose the avail tracking")
        3f4309cb ("drm/i915/uapi: add probed_cpu_visible_size")
        a50794f2 ("uapi/drm/i915: Document memory residency and Flat-CCS capability of obj")
      
      That don't add any new ioctl, so no changes in tooling.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h'
        diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Matthew Auld <matthew.auld@intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
      Cc: Ramalingam C <ramalingam.c@intel.com>
      Link: http://lore.kernel.org/lkml/Yvzrp9RFIeEkb5fI@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      54cd4cde
    • A
      tools headers cpufeatures: Sync with the kernel sources · 62ed93d1
      Arnaldo Carvalho de Melo 提交于
      To pick the changes from:
      
        2b129932 ("x86/speculation: Add RSB VM Exit protections")
        28a99e95 ("x86/amd: Use IBPB for firmware calls")
        4ad3278d ("x86/speculation: Disable RRSBA behavior")
        26aae8cc ("x86/cpu/amd: Enumerate BTC_NO")
        9756bba2 ("x86/speculation: Fill RSB on vmexit for IBRS")
        3ebc1700 ("x86/bugs: Add retbleed=ibpb")
        2dbb887e ("x86/entry: Add kernel IBRS implementation")
        6b80b59b ("x86/bugs: Report AMD retbleed vulnerability")
        a149180f ("x86: Add magic AMD return-thunk")
        15e67227 ("x86: Undo return-thunk damage")
        a883d624 ("x86/cpufeatures: Move RETPOLINE flags to word 11")
        aae99a7c ("x86/cpufeatures: Introduce x2AVIC CPUID bit")
        6f33a9da ("x86: Fix comment for X86_FEATURE_ZEN")
        51802186 ("x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug")
      
      This only causes these perf files to be rebuilt:
      
        CC       /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
        CC       /tmp/build/perf/bench/mem-memset-x86-64-asm.o
      
      And addresses this perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexandre Chartre <alexandre.chartre@oracle.com>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Daniel Sneddon <daniel.sneddon@linux.intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Cc: Wyes Karny <wyes.karny@amd.com>
      Link: https://lore.kernel.org/lkml/Yvznmu5oHv0ZDN2w@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      62ed93d1
    • A
      tools headers UAPI: Sync linux/fscrypt.h with the kernel sources · fabe0c61
      Arnaldo Carvalho de Melo 提交于
      To pick the changes from:
      
        6b2a51ff ("fscrypt: Add HCTR2 support for filename encryption")
      
      That don't result in any changes in tooling, just causes this to be
      rebuilt:
      
        CC      /tmp/build/perf-urgent/trace/beauty/sync_file_range.o
        LD      /tmp/build/perf-urgent/trace/beauty/perf-in.o
      
      addressing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/fscrypt.h' differs from latest version at 'include/uapi/linux/fscrypt.h'
        diff -u tools/include/uapi/linux/fscrypt.h include/uapi/linux/fscrypt.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Huckleberry <nhuck@google.com>
      Link: https://lore.kernel.org/lkml/Yvzl8C7O1b+hf9GS@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fabe0c61
    • A
      tools arch x86: Sync the msr-index.h copy with the kernel sources · 7f7f86a7
      Arnaldo Carvalho de Melo 提交于
      To pick up the changes in:
      
        2b129932 ("x86/speculation: Add RSB VM Exit protections")
        4af184ee ("tools/power turbostat: dump secondary Turbo-Ratio-Limit")
        4ad3278d ("x86/speculation: Disable RRSBA behavior")
        d7caac99 ("x86/cpu/amd: Add Spectral Chicken")
        6ad0ad2b ("x86/bugs: Report Intel retbleed vulnerability")
        c59a1f10 ("KVM: x86/pmu: Add IA32_PEBS_ENABLE MSR emulation for extended PEBS")
        465932db ("x86/cpu: Add new VMX feature, Tertiary VM-Execution control")
        027bbb88 ("KVM: x86/speculation: Disable Fill buffer clear within guests")
        51802186 ("x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug")
      
      Addressing these tools/perf build warnings:
      
          diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
          Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
      
      That makes the beautification scripts to pick some new entries:
      
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before
        $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after
        $ diff -u before after
        --- before	2022-08-17 09:05:13.938246475 -0300
        +++ after	2022-08-17 09:05:22.221455851 -0300
        @@ -161,6 +161,7 @@
         	[0x0000048f] = "IA32_VMX_TRUE_EXIT_CTLS",
         	[0x00000490] = "IA32_VMX_TRUE_ENTRY_CTLS",
         	[0x00000491] = "IA32_VMX_VMFUNC",
        +	[0x00000492] = "IA32_VMX_PROCBASED_CTLS3",
         	[0x000004c1] = "IA32_PMC0",
         	[0x000004d0] = "IA32_MCG_EXT_CTL",
         	[0x00000560] = "IA32_RTIT_OUTPUT_BASE",
        @@ -212,6 +213,7 @@
         	[0x0000064D] = "PLATFORM_ENERGY_STATUS",
         	[0x0000064e] = "PPERF",
         	[0x0000064f] = "PERF_LIMIT_REASONS",
        +	[0x00000650] = "SECONDARY_TURBO_RATIO_LIMIT",
         	[0x00000658] = "PKG_WEIGHTED_CORE_C0_RES",
         	[0x00000659] = "PKG_ANY_CORE_C0_RES",
         	[0x0000065A] = "PKG_ANY_GFXE_C0_RES",
        $
      
      Now one can trace systemwide asking to see backtraces to where those
      MSRs are being read/written, see this example with a previous update:
      
        # perf trace -e msr:*_msr/max-stack=32/ --filter="msr>=IA32_U_CET && msr<=IA32_INT_SSP_TAB"
        ^C#
      
      If we use -v (verbose mode) we can see what it does behind the scenes:
      
        # perf trace -v -e msr:*_msr/max-stack=32/ --filter="msr>=IA32_U_CET && msr<=IA32_INT_SSP_TAB"
        Using CPUID AuthenticAMD-25-21-0
        0x6a0
        0x6a8
        New filter for msr:read_msr: (msr>=0x6a0 && msr<=0x6a8) && (common_pid != 597499 && common_pid != 3313)
        0x6a0
        0x6a8
        New filter for msr:write_msr: (msr>=0x6a0 && msr<=0x6a8) && (common_pid != 597499 && common_pid != 3313)
        mmap size 528384B
        ^C#
      
      Example with a frequent msr:
      
        # perf trace -v -e msr:*_msr/max-stack=32/ --filter="msr==IA32_SPEC_CTRL" --max-events 2
        Using CPUID AuthenticAMD-25-21-0
        0x48
        New filter for msr:read_msr: (msr==0x48) && (common_pid != 2612129 && common_pid != 3841)
        0x48
        New filter for msr:write_msr: (msr==0x48) && (common_pid != 2612129 && common_pid != 3841)
        mmap size 528384B
        Looking at the vmlinux_path (8 entries long)
        symsrc__init: build id mismatch for vmlinux.
        Using /proc/kcore for kernel data
        Using /proc/kallsyms for symbols
           0.000 Timer/2525383 msr:write_msr(msr: IA32_SPEC_CTRL, val: 6)
                                             do_trace_write_msr ([kernel.kallsyms])
                                             do_trace_write_msr ([kernel.kallsyms])
                                             __switch_to_xtra ([kernel.kallsyms])
                                             __switch_to ([kernel.kallsyms])
                                             __schedule ([kernel.kallsyms])
                                             schedule ([kernel.kallsyms])
                                             futex_wait_queue_me ([kernel.kallsyms])
                                             futex_wait ([kernel.kallsyms])
                                             do_futex ([kernel.kallsyms])
                                             __x64_sys_futex ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             entry_SYSCALL_64_after_hwframe ([kernel.kallsyms])
                                             __futex_abstimed_wait_common64 (/usr/lib64/libpthread-2.33.so)
           0.030 :0/0 msr:write_msr(msr: IA32_SPEC_CTRL, val: 2)
                                             do_trace_write_msr ([kernel.kallsyms])
                                             do_trace_write_msr ([kernel.kallsyms])
                                             __switch_to_xtra ([kernel.kallsyms])
                                             __switch_to ([kernel.kallsyms])
                                             __schedule ([kernel.kallsyms])
                                             schedule_idle ([kernel.kallsyms])
                                             do_idle ([kernel.kallsyms])
                                             cpu_startup_entry ([kernel.kallsyms])
                                             secondary_startup_64_no_verify ([kernel.kallsyms])
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Daniel Sneddon <daniel.sneddon@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Like Xu <like.xu@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Robert Hoo <robert.hu@linux.intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/lkml/YvzbT24m2o5U%2F7+q@kernel.org/Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7f7f86a7
    • A
      perf beauty: Update copy of linux/socket.h with the kernel sources · cf1258ac
      Arnaldo Carvalho de Melo 提交于
      To pick the changes in:
      
        7fa875b8 ("net: copy from user before calling __copy_msghdr")
        ebe73a28 ("net: Allow custom iter handler in msghdr")
        7c701d92 ("skbuff: carry external ubuf_info in msghdr")
        c0424532 ("net: make __sys_accept4_file() static")
      
      That don't result in any changes in the tables generated from that
      header.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/perf/trace/beauty/include/linux/socket.h' differs from latest version at 'include/linux/socket.h'
        diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
      
      Cc: David Ahern <dsahern@kernel.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Dylan Yudaken <dylany@fb.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Pavel Begunkov <asml.silence@gmail.com>
      Cc: Yajun Deng <yajun.deng@linux.dev>
      Link: https://lore.kernel.org/lkml/YvzYs+F+Xzq8Hvvp@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cf1258ac
    • I
      perf cpumap: Fix alignment for masks in event encoding · b2f10cd4
      Ian Rogers 提交于
      A mask encoding of a cpu map is laid out as:
      
        u16 nr
        u16 long_size
        unsigned long mask[];
      
      However, the mask may be 8-byte aligned meaning there is a 4-byte pad
      after long_size. This means 32-bit and 64-bit builds see the mask as
      being at different offsets. On top of this the structure is in the byte
      data[] encoded as:
      
        u16 type
        char data[]
      
      This means the mask's struct isn't the required 4 or 8 byte aligned, but
      is offset by 2. Consequently the long reads and writes are causing
      undefined behavior as the alignment is broken.
      
      Fix the mask struct by creating explicit 32 and 64-bit variants, use a
      union to avoid data[] and casts; the struct must be packed so the
      layout matches the existing perf.data layout. Taking an address of a
      member of a packed struct breaks alignment so pass the packed
      perf_record_cpu_map_data to functions, so they can access variables with
      the right alignment.
      
      As the 64-bit version has 4 bytes of padding, optimizing writing to only
      write the 32-bit version.
      
      Committer notes:
      
      Disable warnings about 'packed' that break the build in some arches like
      riscv64, but just around that specific struct.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Colin Ian King <colin.king@intel.com>
      Cc: Dave Marchevsky <davemarchevsky@fb.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220614143353.1559597-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b2f10cd4