Skip to content
  1. Dec 08, 2021
    • Ian Rogers's avatar
      perf parse-events: Architecture specific leader override · 94dbfd67
      Ian Rogers authored
      
      
      Currently topdown events must appear after a slots event:
      
        $ perf stat -e '{slots,topdown-fe-bound}' /bin/true
      
         Performance counter stats for '/bin/true':
      
               3,183,090      slots
                 986,133      topdown-fe-bound
      
      Reversing the events yields:
      
        $ perf stat -e '{topdown-fe-bound,slots}' /bin/true
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (topdown-fe-bound).
      
      For metrics the order of events is determined by iterating over a
      hashmap, and so slots isn't guaranteed to be first which can yield this
      error.
      
      Change the set_leader in parse-events, called when a group is closed, so
      that rather than always making the first event the leader, if the slots
      event exists then it is made the leader. It is then moved to the head of
      the evlist otherwise it won't be opened in the correct order.
      
      The result is:
      
        $ perf stat -e '{topdown-fe-bound,slots}' /bin/true
      
         Performance counter stats for '/bin/true':
      
               3,274,795      slots
               1,001,702      topdown-fe-bound
      
      A problem with this approach is the slots event is identified by name,
      names can be overwritten like 'cpu/slots,name=foo/' and this causes the
      leader change to fail.
      
      The change also modifies and fixes mixed groups like, with the change:
      
        $ perf stat -e '{instructions,slots,topdown-fe-bound}' -a -- sleep 2
      
         Performance counter stats for 'system wide':
      
              5574985410      slots
               971981616      instructions
              1348461887      topdown-fe-bound
      
             2.001263120 seconds time elapsed
      
      Without the change:
      
        $ perf stat -e '{instructions,slots,topdown-fe-bound}' -a -- sleep 2
      
         Performance counter stats for 'system wide':
      
           <not counted>      instructions
           <not counted>      slots
         <not supported>      topdown-fe-bound
      
             2.006247990 seconds time elapsed
      
      Something that may be undesirable here is that the events are reordered
      in the output.
      
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vineet Singh <vineet.singh@intel.com>
      Link: http://lore.kernel.org/lkml/20211130174945.247604-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      94dbfd67
    • Ian Rogers's avatar
      perf evlist: Allow setting arbitrary leader · ecdcf630
      Ian Rogers authored
      
      
      The leader of a group is the first, but allow it to be an arbitrary list
      member so that for Intel topdown events slots may always be the group
      leader.
      
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vineet Singh <vineet.singh@intel.com>
      Link: http://lore.kernel.org/lkml/20211130174945.247604-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ecdcf630
    • Ian Rogers's avatar
      perf metric: Reduce multiplexing with duration_time · 6b6b16b3
      Ian Rogers authored
      
      
      It is common to use the same counters with and without duration_time.
      The ID sharing code treats duration_time as if it were a hardware event
      placed in the same group. This causes unnecessary multiplexing such as
      in the following example where l3_cache_access isn't shared:
      
        $ perf stat -M l3 -a sleep 1
      
         Performance counter stats for 'system wide':
      
               3,117,007      l3_cache_miss         #    199.5 MB/s  l3_rd_bw
                                                    #     43.6 %  l3_hits
                                                    #     56.4 %  l3_miss                 (50.00%)
               5,526,447      l3_cache_access                                             (50.00%)
               5,392,435      l3_cache_access       # 5389191.2 access/s  l3_access_rate  (50.00%)
           1,000,601,901 ns   duration_time
      
             1.000601901 seconds time elapsed
      
      Fix this by placing duration_time in all groups unless metric
      sharing has been disabled on the command line:
      
        $ perf stat -M l3 -a sleep 1
      
         Performance counter stats for 'system wide':
      
               3,597,972      l3_cache_miss         #    230.3 MB/s  l3_rd_bw
                                                    #     48.0 %  l3_hits
                                                    #     52.0 %  l3_miss
               6,914,459      l3_cache_access       # 6909935.9 access/s  l3_access_rate
           1,000,654,579 ns   duration_time
      
             1.000654579 seconds time elapsed
      
        $ perf stat --metric-no-merge -M l3 -a sleep 1
      
         Performance counter stats for 'system wide':
      
               3,501,834      l3_cache_miss         #     53.5 %  l3_miss                (24.99%)
               6,548,173      l3_cache_access                                            (24.99%)
               3,417,622      l3_cache_miss         #     45.7 %  l3_hits                (25.04%)
               6,294,062      l3_cache_access                                            (25.04%)
               5,923,238      l3_cache_access       # 5919688.1 access/s  l3_access_rate (24.99%)
           1,000,599,683 ns   duration_time
               3,607,486      l3_cache_miss         #    230.9 MB/s  l3_rd_bw            (49.97%)
      
             1.000599683 seconds time elapsed
      
      v2. Doesn't count duration_time in the metric_list_cmp function that
          sorts larger metrics first. Without this a metric with duration_time
          and an event is sorted the same as a metric with two events,
          possibly not allowing the first metric to share with the second.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20211124015226.3317994-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6b6b16b3
    • Gang Li's avatar
      perf trace: Enable ignore_missing_thread for trace · b4515ad6
      Gang Li authored
      
      
      perf already support ignore_missing_thread for -u/-p, but not yet
      applied to `perf trace`. This patch enables ignore_missing_thread
      for `perf trace`.
      
      Signed-off-by: default avatarGang Li <ligang.bdlg@bytedance.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1481538943-21874-6-git-send-email-jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1513148513-6974-1-git-send-email-zhangmengting@huawei.com
      Link: http://lore.kernel.org/lkml/20211123074018.11406-1-ligang.bdlg@bytedance.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b4515ad6
    • Sandipan Das's avatar
      perf docs: Update link to AMD documentation · 7a2e1496
      Sandipan Das authored
      
      
      This updates the link to documentation on AMD processors.  The new link
      points to a page where users can find the Processor Programming
      Reference (PPR) documents for the family and model codes corresponding
      to processors they are using.
      
      Signed-off-by: default avatarSandipan Das <sandipan.das@amd.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Ananth Narayan <ananth.narayan@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Robert Richter <rrichter@amd.com>
      Cc: Santosh Shukla <santosh.shukla@amd.com>
      Link: https://lore.kernel.org/r/20211123084613.243792-2-sandipan.das@amd.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7a2e1496
    • Sandipan Das's avatar
      perf docs: Add info on AMD raw event encoding · 4edb117e
      Sandipan Das authored
      
      
      AMD processors have events with event select codes and unit masks larger
      than a byte. The core PMU, for example, uses 12-bit event select codes
      split between bits 0-7 and 32-35 of the PERF_CTL MSRs as can be seen
      from /sys/bus/event_sources/devices/cpu/format/*.
      
      The Processor Programming Reference (PPR) lists the event codes as
      unified 12-bit hexadecimal values instead and the split between the bits
      is not apparent to someone who is not aware of the layout of the
      PERF_CTL MSRs.
      
      8-bit event select codes continue to work as the layout matches that of
      the PERF_CTL MSRs i.e. bits 0-7 for event select and 8-15 for unit mask.
      
      This adds more details in the perf man pages about using
      /sys/bus/event_sources/devices/*/format/* for determining the correct
      raw event encoding scheme.
      
      E.g. the "op_cache_hit_miss.op_cache_hit" event with code 0x28f and
      umask 0x03 can be programmed using its symbolic name as:
      
        $ sudo perf --debug perf-event-open stat -e op_cache_hit_miss.op_cache_hit sleep 1
        ------------------------------------------------------------
        perf_event_attr:
          type                             4
          size                             128
          config                           0x20000038f
          sample_type                      IDENTIFIER
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          inherit                          1
          enable_on_exec                   1
          exclude_guest                    1
        ------------------------------------------------------------
        [...]
      
      One might use a simple eventsel+umask combination based on what the
      current man pages say and incorrectly program the event as:
      
        $ sudo perf --debug perf-event-open stat -e r0328f sleep 1
        ------------------------------------------------------------
        perf_event_attr:
          type                             4
          size                             128
          config                           0x328f
          sample_type                      IDENTIFIER
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          inherit                          1
          enable_on_exec                   1
          exclude_guest                    1
        ------------------------------------------------------------
        [...]
      
      When it should have been based on the format from sysfs:
      
        $ cat /sys/bus/event_source/devices/cpu/format/event
        config:0-7,32-35
      
        $ sudo perf --debug perf-event-open stat -e r20000038f sleep 1
        ------------------------------------------------------------
        perf_event_attr:
          type                             4
          size                             128
          config                           0x20000038f
          sample_type                      IDENTIFIER
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          inherit                          1
          enable_on_exec                   1
          exclude_guest                    1
        ------------------------------------------------------------
        [...]
      
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Signed-off-by: default avatarSandipan Das <sandipan.das@amd.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Ananth Narayan <ananth.narayan@amd.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Robert Richter <rrichter@amd.com>
      Cc: Santosh Shukla <santosh.shukla@amd.com>
      Link: https://lore.kernel.org/r/20211123084613.243792-1-sandipan.das@amd.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4edb117e
    • Shunsuke Nakamura's avatar
      libperf tests: Add test_stat_multiplexing test · a7f3713f
      Shunsuke Nakamura authored
      
      
      Adds a test for a counter obtained using read() system call during
      multiplexing.
      
        $ sudo make tests -C ./tools/lib/perf/ V=1
        make: Entering directory '/home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/lib/perf'
        make -f /home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/build/Makefile.build dir=. obj=libperf
        make -C /home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/lib/api/ O= libapi.a
        make -f /home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/build/Makefile.build dir=./fd obj=libapi
        make -f /home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/build/Makefile.build dir=./fs obj=libapi
        make -f /home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/build/Makefile.build dir=. obj=tests
        make -f /home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/build/Makefile.build dir=./tests obj=tests
        running static:
        - running tests/test-cpumap.c...OK
        - running tests/test-threadmap.c...OK
        - running tests/test-evlist.c...
        Event  0 -- Raw count = 298049842, run = 270269503, enable = 456262127
                 Scaled count = 503160191 (59.24%, 270269503/456262127)
        Event  1 -- Raw count = 299134173, run = 271075173, enable = 456257234
                 Scaled count = 503484435 (59.41%, 271075173/456257234)
        Event  2 -- Raw count = 300461996, run = 272069283, enable = 456253417
                 Scaled count = 503867290 (59.63%, 272069283/456253417)
        Event  3 -- Raw count = 301308704, run = 273063387, enable = 456249352
                 Scaled count = 503443183 (59.85%, 273063387/456249352)
        Event  4 -- Raw count = 302531164, run = 274102932, enable = 456244712
                 Scaled count = 503563543 (60.08%, 274102932/456244712)
        Event  5 -- Raw count = 303710254, run = 275406214, enable = 456228165
                 Scaled count = 503115633 (60.37%, 275406214/456228165)
        Event  6 -- Raw count = 304531302, run = 276396076, enable = 456221130
                 Scaled count = 502661313 (60.58%, 276396076/456221130)
        Event  7 -- Raw count = 304486460, run = 276601890, enable = 456213754
                 Scaled count = 502205212 (60.63%, 276601890/456213754)
        Event  8 -- Raw count = 304116681, run = 276631326, enable = 456205562
                 Scaled count = 501532936 (60.64%, 276631326/456205562)
        Event  9 -- Raw count = 303567766, run = 276188567, enable = 456196839
                 Scaled count = 501420666 (60.54%, 276188567/456196839)
        Event 10 -- Raw count = 302238014, run = 275144001, enable = 456185300
                 Scaled count = 501106833 (60.31%, 275144001/456185300)
        Event 11 -- Raw count = 300805716, run = 273824589, enable = 456175608
                 Scaled count = 501124573 (60.03%, 273824589/456175608)
        Event 12 -- Raw count = 299959051, run = 272834556, enable = 456166593
                 Scaled count = 501517477 (59.81%, 272834556/456166593)
        Event 13 -- Raw count = 299037090, run = 271820805, enable = 456157086
                 Scaled count = 501830195 (59.59%, 271820805/456157086)
        Event 14 -- Raw count = 298327042, run = 270784311, enable = 456147546
                 Scaled count = 502544433 (59.36%, 270784311/456147546)
           Expected: 501614268
           High: 503867290   Low:  298049842   Average:  502438527
           Average Error = 0.16%
        OK
        - running tests/test-evsel.c...
                loop = 65536, count = 328182
                loop = 131072, count = 660214
                loop = 262144, count = 1315534
                loop = 524288, count = 2635364
                loop = 1048576, count = 5271971
                loop = 65536, count = 491952
                loop = 131072, count = 850061
                loop = 262144, count = 1648608
                loop = 524288, count = 3162059
                loop = 1048576, count = 6353393
        OK
        running dynamic:
        - running tests/test-cpumap.c...OK
        - running tests/test-threadmap.c...OK
        - running tests/test-evlist.c...
        Event  0 -- Raw count = 300218292, run = 297528154, enable = 496789343
                 Scaled count = 501281125 (59.89%, 297528154/496789343)
        Event  1 -- Raw count = 301438606, run = 298515328, enable = 496784768
                 Scaled count = 501649643 (60.09%, 298515328/496784768)
        Event  2 -- Raw count = 302342618, run = 298798983, enable = 496782015
                 Scaled count = 502673648 (60.15%, 298798983/496782015)
        Event  3 -- Raw count = 303132319, run = 299230407, enable = 496778508
                 Scaled count = 503256412 (60.23%, 299230407/496778508)
        Event  4 -- Raw count = 302758195, run = 299218047, enable = 496774243
                 Scaled count = 502651743 (60.23%, 299218047/496774243)
        Event  5 -- Raw count = 303158458, run = 299204274, enable = 496769146
                 Scaled count = 503334281 (60.23%, 299204274/496769146)
        Event  6 -- Raw count = 303471397, run = 299197479, enable = 496763124
                 Scaled count = 503859189 (60.23%, 299197479/496763124)
        Event  7 -- Raw count = 303583387, run = 299196861, enable = 496756458
                 Scaled count = 504039405 (60.23%, 299196861/496756458)
        Event  8 -- Raw count = 303096897, run = 299186924, enable = 496748667
                 Scaled count = 503240507 (60.23%, 299186924/496748667)
        Event  9 -- Raw count = 301424173, run = 297845086, enable = 496739994
                 Scaled count = 502709122 (59.96%, 297845086/496739994)
        Event 10 -- Raw count = 300876415, run = 296851339, enable = 496729034
                 Scaled count = 503464297 (59.76%, 296851339/496729034)
        Event 11 -- Raw count = 300239338, run = 296547963, enable = 496719538
                 Scaled count = 502902612 (59.70%, 296547963/496719538)
        Event 12 -- Raw count = 299751948, run = 296547195, enable = 496710036
                 Scaled count = 502077926 (59.70%, 296547195/496710036)
        Event 13 -- Raw count = 299341883, run = 296549981, enable = 496700423
                 Scaled count = 501376663 (59.70%, 296549981/496700423)
        Event 14 -- Raw count = 299145476, run = 296561684, enable = 496690949
                 Scaled count = 501018366 (59.71%, 296561684/496690949)
           Expected: 501669431
           High: 504039405   Low:  300218292   Average:  502635662
           Average Error = 0.19%
        OK
        - running tests/test-evsel.c...
                loop = 65536, count = 329275
                loop = 131072, count = 664638
                loop = 262144, count = 1315367
                loop = 524288, count = 2629617
                loop = 1048576, count = 5273657
                loop = 65536, count = 459641
                loop = 131072, count = 978402
                loop = 262144, count = 1581219
                loop = 524288, count = 3774908
                loop = 1048576, count = 7694417
        OK
        make: Leaving directory '/home/nakamura/build_work/build_kernel/linux_kernel/linux/tools/lib/perf'
      
      Signed-off-by: default avatarShunsuke Nakamura <nakamura.shun@fujitsu.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20211109085831.3770594-4-nakamura.shun@fujitsu.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a7f3713f
    • Shunsuke Nakamura's avatar
      libperf: Remove scaling process from perf_mmap__read_self() · f2c4dcf1
      Shunsuke Nakamura authored
      
      
      Remove the scaling process from perf_mmap__read_self(), and unify the
      counters that can be obtained from perf_evsel__read() to "no scaling".
      
      Signed-off-by: default avatarShunsuke Nakamura <nakamura.shun@fujitsu.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20211109085831.3770594-3-nakamura.shun@fujitsu.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f2c4dcf1
    • Shunsuke Nakamura's avatar
      libperf: Adopt perf_counts_values__scale() from tools/perf/util · 9a5b2d1a
      Shunsuke Nakamura authored
      
      
      Move perf_counts_values__scale() from tools/perf/util to tools/lib/perf
      so that it can be used with libperf.
      
      Committer notes:
      
      As noted by Jiri, use __s8 instead of s8 on the exported function.
      
      Signed-off-by: default avatarShunsuke Nakamura <nakamura.shun@fujitsu.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20211109085831.3770594-2-nakamura.shun@fujitsu.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9a5b2d1a
    • John Garry's avatar
      tools build: Enable warnings through HOSTCFLAGS · c77a78c2
      John Garry authored
      
      
      The tools build system uses KBUILD_HOSTCFLAGS symbol for obvious purposes.
      
      However this is not set for anything under tools/
      
      As such, host tools apps built have no compiler warnings enabled.
      
      Declare HOSTCFLAGS for perf tools build, and also use that symbol in
      declaration of host_c_flags. HOSTCFLAGS comes from EXTRA_WARNINGS, which
      is independent of target platform/arch warning flags.
      
      Suggested-by: default avatarJiri Olsa <jolsa@redhat.com>
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/1635525041-151876-1-git-send-email-john.garry@huawei.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c77a78c2
    • Arnaldo Carvalho de Melo's avatar
      perf test sigtrap: Print errno string when failing · e9c08f72
      Arnaldo Carvalho de Melo authored
      Helps a bit the user figuring out why it is failing:
      
      Before:
      
        $ perf test sigtrap
        73: Sigtrap                                                         : FAILED!
        $ perf test -v sigtrap
        73: Sigtrap                                                         :
        --- start ---
        test child forked, pid 3816772
        FAILED sys_perf_event_open()
        test child finished with -1
        ---- end ----
        Sigtrap: FAILED!
        $
      
      After:
      
        $ perf test sigtrap
        73: Sigtrap                                                         : FAILED!
        $ perf test -v sigtrap
        73: Sigtrap                                                         :
        --- start ---
        test child forked, pid 3816772
        FAILED sys_perf_event_open(): Permission denied
        test child finished with -1
        ---- end ----
        Sigtrap: FAILED!
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kasan-dev@googlegroups.com
      Link: http://lore.kernel.org/lkml/YZOpSVOCXe0zWeRs@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e9c08f72
    • Marco Elver's avatar
      perf test sigtrap: Add basic stress test for sigtrap handling · 5504f679
      Marco Elver authored
      
      
      Add basic stress test for sigtrap handling as a perf tool built-in test.
      This allows sanity checking the basic sigtrap functionality from within
      the perf tool.
      
      Committer notes:
      
      Reported that !root was getting -EPERM, applied a fixup from Marco to
      set .exclude_{hv,kernel} that made it work.
      
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kasan-dev@googlegroups.com
      Link: http://lore.kernel.org/lkml/20211115112822.4077224-1-elver@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5504f679
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-07' of... · 2a987e65
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix SMT detection fast read path on sysfs.
      
       - Fix memory leaks when processing feature headers in perf.data files.
      
       - Fix 'Simple expression parser' 'perf test' on arch without CPU die
         topology info, such as s/390.
      
       - Fix building perf with BUILD_BPF_SKEL=1.
      
       - Fix 'perf bench' by reverting "perf bench: Fix two memory leaks
         detected with ASan".
      
       - Fix itrace space allowed for new attributes in 'perf script'.
      
       - Fix the build feature detection fast path, that was always failing on
         systems with python3 development packages, speeding up the build.
      
       - Reset shadow counts before loading, fixing metrics using
         duration_time.
      
       - Sync more kernel headers changed by the new futex_waitv syscall: s390
         and powerpc.
      
      * tag 'perf-tools-fixes-for-v5.16-2021-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf bpf_skel: Do not use typedef to avoid error on old clang
        perf bpf: Fix building perf with BUILD_BPF_SKEL=1 by default in more distros
        perf header: Fix memory leaks when processing feature headers
        perf test: Reset shadow counts before loading
        perf test: Fix 'Simple expression parser' test on arch without CPU die topology info
        tools build: Remove needless libpython-version feature check that breaks test-all fast path
        perf tools: Fix SMT detection fast read path
        tools headers UAPI: Sync powerpc syscall table file changed by new futex_waitv syscall
        perf inject: Fix itrace space allowed for new attributes
        tools headers UAPI: Sync s390 syscall table file changed by new futex_waitv syscall
        Revert "perf bench: Fix two memory leaks detected with ASan"
      2a987e65
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v5.16-3' of... · 95723243
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Hans de Goede:
       "Various bug-fixes and hardware-id additions"
      
      * tag 'platform-drivers-x86-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        platform/x86/intel: hid: add quirk to support Surface Go 3
        platform/x86: amd-pmc: Fix s2idle failures on certain AMD laptops
        platform/x86: touchscreen_dmi: Add TrekStor SurfTab duo W1 touchscreen info
        platform/x86: lg-laptop: Recognize more models
        platform/x86: thinkpad_acpi: Add lid_logo_dot to the list of safe LEDs
        platform/x86: thinkpad_acpi: Restore missing hotkey_tablet_mode and hotkey_radio_sw sysfs-attr
      95723243
  2. Dec 07, 2021
    • Song Liu's avatar
      perf bpf_skel: Do not use typedef to avoid error on old clang · 5a897531
      Song Liu authored
      
      
      When building bpf_skel with clang-10, typedef causes confusions like:
      
        libbpf: map 'prev_readings': unexpected def kind var.
      
      Fix this by removing the typedef.
      
      Fixes: 7fac83aa ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF")
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/BEF5C312-4331-4A60-AEC0-AD7617CB2BC4@fb.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5a897531
    • Song Liu's avatar
      perf bpf: Fix building perf with BUILD_BPF_SKEL=1 by default in more distros · f7c4e85b
      Song Liu authored
      
      
      Arnaldo reported that building all his containers with BUILD_BPF_SKEL=1
      to then make this the default he found problems in some distros where
      the system linux/bpf.h file was being used and lacked this:
      
         util/bpf_skel/bperf_leader.bpf.c:13:20: error: use of undeclared identifier 'BPF_F_PRESERVE_ELEMS'
                 __uint(map_flags, BPF_F_PRESERVE_ELEMS);
      
      So use instead the vmlinux.h file generated by bpftool from BTF info.
      
      This fixed these as well, getting the build back working on debian:11,
      debian:experimental and ubuntu:21.10:
      
        In file included from In file included from util/bpf_skel/bperf_leader.bpf.cutil/bpf_skel/bpf_prog_profiler.bpf.c::33:
        :
        In file included from In file included from /usr/include/linux/bpf.h/usr/include/linux/bpf.h::1111:
        :
        /usr/include/linux/types.h/usr/include/linux/types.h::55::1010:: In file included from  util/bpf_skel/bperf_follower.bpf.c:3fatal errorfatal error:
        : : In file included from /usr/include/linux/bpf.h:'asm/types.h' file not found11'asm/types.h' file not found:
      
        /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
        #include <asm/types.h>#include <asm/types.h>
      
                 ^~~~~~~~~~~~~         ^~~~~~~~~~~~~
      
        #include <asm/types.h>
                 ^~~~~~~~~~~~~
        1 error generated.
      
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Tested-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/CF175681-8101-43D1-ABDB-449E644BE986@fb.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f7c4e85b
    • Ian Rogers's avatar
      perf header: Fix memory leaks when processing feature headers · 47473950
      Ian Rogers authored
      
      
      These leaks were found with leak sanitizer running "perf pipe recording
      and injection test".
      
      In pipe mode feat_fd may hold onto an events struct that needs freeing.
      
      When string features are processed they may overwrite an already created
      string, so free this before the overwrite.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20211118201730.2302927-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47473950
    • Ian Rogers's avatar
      perf test: Reset shadow counts before loading · 1aa79e57
      Ian Rogers authored
      Otherwise load counting is an average. Without this change
      duration_time in test_memory_bandwidth will alter its value if an
      earlier test contains duration_time.
      
      This patch fixes an issue that's introduced in the proposed patch:
      https://lore.kernel.org/lkml/20211124015226.3317994-1-irogers@google.com/
      
      
      in perf test "Parse and process metrics".
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20211128085810.4027314-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1aa79e57
    • Thomas Richter's avatar
      perf test: Fix 'Simple expression parser' test on arch without CPU die topology info · 6c481031
      Thomas Richter authored
      
      
      Some platforms do not have CPU die support, for example s390.
      
      Commit
      Cc: Ian Rogers <irogers@google.com>
      Fixes: fdf1e29b ("perf expr: Add metric literals for topology.")
      fails on s390:
      
        # perf test -Fv 7
          ...
        # FAILED tests/expr.c:173 #num_dies >= #num_packages
          ---- end ----
          Simple expression parser: FAILED!
        #
      
      Investigating this issue leads to these functions:
      
       build_cpu_topology()
         +--> has_die_topology(void)
              {
                 struct utsname uts;
      
                 if (uname(&uts) < 0)
                        return false;
                 if (strncmp(uts.machine, "x86_64", 6))
                        return false;
                 ....
              }
      
      which always returns false on s390. The caller build_cpu_topology()
      checks has_die_topology() return value. On false the the struct
      cpu_topology::die_cpu_list is not contructed and has zero entries. This
      leads to the failing comparison: #num_dies >= #num_packages.  s390 of
      course has a positive number of packages.
      
      Fix this and check if the function build_cpu_topology() did build up
      a die_cpus_list. The number of entries in this list should be larger
      than 0. If the number of list element is zero, the die_cpus_list has
      not been created and the check in function test__expr():
      
          TEST_ASSERT_VAL("#num_dies >= #num_packages", \
      		    num_dies >= num_packages)
      
      always fails.
      
      Output after:
      
        # perf test -Fv 7
         7: Simple expression parser                                        :
         --- start ---
         division by zero
         syntax error
         ---- end ----
         Simple expression parser: Ok
        #
      
      Fixes: fdf1e29b ("perf expr: Add metric literals for topology.")
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20211129112339.3003036-1-tmricht@linux.ibm.com
      
      
      [ Added comment in the added 'if (num_dies)' line about architectures not having die topology ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6c481031
    • Arnaldo Carvalho de Melo's avatar
      tools build: Remove needless libpython-version feature check that breaks test-all fast path · 3d1d57de
      Arnaldo Carvalho de Melo authored
      
      
      Since 66dfdff0 ("perf tools: Add Python 3 support") we don't use
      the tools/build/feature/test-libpython-version.c version in any Makefile
      feature check:
      
        $ find tools/ -type f | xargs grep feature-libpython-version
        $
      
      The only place where this was used was removed in 66dfdff0:
      
        -        ifneq ($(feature-libpython-version), 1)
        -          $(warning Python 3 is not yet supported; please set)
        -          $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
        -          $(warning If you also have Python 2 installed, then)
        -          $(warning try something like:)
        -          $(warning $(and ,))
        -          $(warning $(and ,)  make PYTHON=python2)
        -          $(warning $(and ,))
        -          $(warning Otherwise, disable Python support entirely:)
        -          $(warning $(and ,))
        -          $(warning $(and ,)  make NO_LIBPYTHON=1)
        -          $(warning $(and ,))
        -          $(error   $(and ,))
        -        else
        -          LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
        -          EXTLIBS += $(PYTHON_EMBED_LIBADD)
        -          LANG_BINDINGS += $(obj-perf)python/perf.so
        -          $(call detected,CONFIG_LIBPYTHON)
        -        endif
      
      And nowadays we either build with PYTHON=python3 or just install the
      python3 devel packages and perf will build against it.
      
      But the leftover feature-libpython-version check made the fast path
      feature detection to break in all cases except when python2 devel files
      were installed:
      
        $ rpm -qa | grep python.*devel
        python3-devel-3.9.7-1.fc34.x86_64
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;
        $ make -C tools/perf O=/tmp/build/perf install-bin
        make: Entering directory '/var/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j32' parallel build
          HOSTCC  /tmp/build/perf/fixdep.o
        <SNIP>
        $ cat /tmp/build/perf/feature/test-all.make.output
        In file included from test-all.c:18:
        test-libpython-version.c:5:10: error: #error
            5 |         #error
              |          ^~~~~
        $ ldd ~/bin/perf | grep python
      	libpython3.9.so.1.0 => /lib64/libpython3.9.so.1.0 (0x00007fda6dbcf000)
        $
      
      As python3 is the norm these days, fix this by just removing the unused
      feature-libpython-version feature check, making the test-all fast path
      to work with the common case.
      
      With this:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;
        $ make -C tools/perf O=/tmp/build/perf install-bin |& head
        make: Entering directory '/var/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j32' parallel build
          HOSTCC  /tmp/build/perf/fixdep.o
          HOSTLD  /tmp/build/perf/fixdep-in.o
          LINK    /tmp/build/perf/fixdep
      
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        $ ldd ~/bin/perf | grep python
      	libpython3.9.so.1.0 => /lib64/libpython3.9.so.1.0 (0x00007f58800b0000)
        $ cat /tmp/build/perf/feature/test-all.make.output
        $
      
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Fixes: 66dfdff0 ("perf tools: Add Python 3 support")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jaroslav Škarvada <jskarvad@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/YaYmeeC6CS2b8OSz@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3d1d57de
    • Ian Rogers's avatar
      perf tools: Fix SMT detection fast read path · 4ffbe87e
      Ian Rogers authored
      
      
      sysfs__read_int() returns 0 on success, and so the fast read path was
      always failing.
      
      Fixes: bb629484 ("perf tools: Simplify checking if SMT is active.")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20211124001231.3277836-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4ffbe87e
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync powerpc syscall table file changed by new futex_waitv syscall · cba43fcf
      Arnaldo Carvalho de Melo authored
      
      
      To pick the changes in this cset:
      
        a0eb2da9 ("futex: Wireup futex_waitv syscall")
      
      That add support for this new syscall in tools such as 'perf trace'.
      
      For instance, this is now possible (adapted from the x86_64 test output):
      
        # perf trace -e futex_waitv
        ^C#
        # perf trace -v -e futex_waitv
        event qualifier tracepoint filter: (common_pid != 807333 && common_pid != 3564) && (id == 449)
        ^C#
        # perf trace -v -e futex* --max-events 10
        event qualifier tracepoint filter: (common_pid != 812168 && common_pid != 3564) && (id == 221 || id == 449)
        mmap size 528384B
                 ? (         ): Timer/219310  ... [continued]: futex())                                            = -1 ETIMEDOUT (Connection timed out)
             0.012 ( 0.002 ms): Timer/219310 futex(uaddr: 0x7fd0b152d3c8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
             0.024 ( 0.060 ms): Timer/219310 futex(uaddr: 0x7fd0b152d420, op: WAIT_BITSET|PRIVATE_FLAG, utime: 0x7fd0b1657840, val3: MATCH_ANY) = 0
             0.086 ( 0.001 ms): Timer/219310 futex(uaddr: 0x7fd0b152d3c8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
             0.088 (         ): Timer/219310 futex(uaddr: 0x7fd0b152d424, op: WAIT_BITSET|PRIVATE_FLAG, utime: 0x7fd0b1657840, val3: MATCH_ANY) ...
             0.075 ( 0.005 ms): Web Content/219299 futex(uaddr: 0x7fd0b152d420, op: WAKE|PRIVATE_FLAG, val: 1)     = 1
             0.169 ( 0.004 ms): Web Content/219299 futex(uaddr: 0x7fd0b152d424, op: WAKE|PRIVATE_FLAG, val: 1)     = 1
             0.088 ( 0.089 ms): Timer/219310  ... [continued]: futex())                                            = 0
             0.179 ( 0.001 ms): Timer/219310 futex(uaddr: 0x7fd0b152d3c8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
             0.181 (         ): Timer/219310 futex(uaddr: 0x7fd0b152d420, op: WAIT_BITSET|PRIVATE_FLAG, utime: 0x7fd0b1657840, val3: MATCH_ANY) ...
        #
      
      That is the filter expression attached to the raw_syscalls:sys_{enter,exit}
      tracepoints.
      
        $ grep futex tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
        221	32	futex				sys_futex_time32
        221	64	futex				sys_futex
        221	spu	futex				sys_futex
        422	32	futex_time64			sys_futex			sys_futex
        449	common  futex_waitv                     sys_futex_waitv
        $
      
      This addresses this perf build warnings:
      
        Warning: Kernel ABI header at 'tools/perf/arch/powerpc/entry/syscalls/syscall.tbl' differs from latest version at 'arch/powerpc/kernel/syscalls/syscall.tbl'
        diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
      
      Reviewed-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Tested-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>,
      Cc: André Almeida <andrealmeid@collabora.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/YZ%2F1OU9mJuyS2HMa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cba43fcf
    • Adrian Hunter's avatar
      perf inject: Fix itrace space allowed for new attributes · c29d9792
      Adrian Hunter authored
      
      
      The space allowed for new attributes can be too small if existing header
      information is large. That can happen, for example, if there are very
      many CPUs, due to having an event ID per CPU per event being stored in the
      header information.
      
      Fix by adding the existing header.data_offset. Also increase the extra
      space allowed to 8KiB and align to a 4KiB boundary for neatness.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20211125071457.2066863-1-adrian.hunter@intel.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c29d9792
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync s390 syscall table file changed by new futex_waitv syscall · 71a16df1
      Arnaldo Carvalho de Melo authored
      
      
      To pick the changes in these csets:
      
        6c122360 ("s390: wire up sys_futex_waitv system call")
      
      That add support for this new syscall in tools such as 'perf trace'.
      
      For instance, this is now possible (adapted from the x86_64 test output):
      
        # perf trace -e futex_waitv
        ^C#
        # perf trace -v -e futex_waitv
        event qualifier tracepoint filter: (common_pid != 807333 && common_pid != 3564) && (id == 449)
        ^C#
        # perf trace -v -e futex* --max-events 10
        event qualifier tracepoint filter: (common_pid != 812168 && common_pid != 3564) && (id == 238 || id == 449)
                 ? (         ): Timer/219310  ... [continued]: futex())                                            = -1 ETIMEDOUT (Connection timed out)
             0.012 ( 0.002 ms): Timer/219310 futex(uaddr: 0x7fd0b152d3c8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
             0.024 ( 0.060 ms): Timer/219310 futex(uaddr: 0x7fd0b152d420, op: WAIT_BITSET|PRIVATE_FLAG, utime: 0x7fd0b1657840, val3: MATCH_ANY) = 0
             0.086 ( 0.001 ms): Timer/219310 futex(uaddr: 0x7fd0b152d3c8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
             0.088 (         ): Timer/219310 futex(uaddr: 0x7fd0b152d424, op: WAIT_BITSET|PRIVATE_FLAG, utime: 0x7fd0b1657840, val3: MATCH_ANY) ...
             0.075 ( 0.005 ms): Web Content/219299 futex(uaddr: 0x7fd0b152d420, op: WAKE|PRIVATE_FLAG, val: 1)     = 1
             0.169 ( 0.004 ms): Web Content/219299 futex(uaddr: 0x7fd0b152d424, op: WAKE|PRIVATE_FLAG, val: 1)     = 1
             0.088 ( 0.089 ms): Timer/219310  ... [continued]: futex())                                            = 0
             0.179 ( 0.001 ms): Timer/219310 futex(uaddr: 0x7fd0b152d3c8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
             0.181 (         ): Timer/219310 futex(uaddr: 0x7fd0b152d420, op: WAIT_BITSET|PRIVATE_FLAG, utime: 0x7fd0b1657840, val3: MATCH_ANY) ...
        #
      
      That is the filter expression attached to the raw_syscalls:sys_{enter,exit}
      tracepoints.
      
        $ grep futex tools/perf/arch/s390/entry/syscalls/syscall.tbl
        238  common	futex			sys_futex			sys_futex_time32
        422	32	futex_time64		-				sys_futex
        449  common	futex_waitv		sys_futex_waitv			sys_futex_waitv
        $
      
      This addresses this perf build warnings:
      
        Warning: Kernel ABI header at 'tools/perf/arch/s390/entry/syscalls/syscall.tbl' differs from latest version at 'arch/s390/kernel/syscalls/syscall.tbl'
        diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
      
      Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>,
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/lkml/YZ%2F2qRW%2FTScYTP1U@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      71a16df1
    • Jiri Olsa's avatar
      Revert "perf bench: Fix two memory leaks detected with ASan" · 3f8d6577
      Jiri Olsa authored
      
      
      This: This reverts commit 92723ea0.
      
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRRRRRR FAILED!
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRRRRRR FAILED!
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRRRRR FAILED!
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRRRRRRRRRRR Ok
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRR FAILED!
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRRRR Ok
        # perf test 91
        91: perf stat --bpf-counters test           :RRRRRRRRRRRRRRR Ok
      
      yep, it seems the perf bench is broken so the counts won't correlated if
      I revert this one:
      
        92723ea0 perf bench: Fix two memory leaks detected with ASan
      
      it works for me again.. it seems to break -t option
      
         [root@dell-r440-01 perf]# ./perf bench sched messaging -g 1 -l 100 -t
         # Running 'sched/messaging' benchmark:
         RRRperf: CLIENT: ready write: Bad file descriptor
         Rperf: SENDER: write: Bad file descriptor
      
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Sohaib Mohamed <sohaib.amhmd@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/lkml/YZev7KClb%2Fud43Lc@krava/
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3f8d6577
    • Salvatore Bonaccorso's avatar
      Makefile: Do not quote value for CONFIG_CC_IMPLICIT_FALLTHROUGH · cd8c917a
      Salvatore Bonaccorso authored
      
      
      Andreas reported that a specific build environment for an external
      module, being a bit broken, does pass CC_IMPLICIT_FALLTHROUGH quoted as
      argument to gcc, causing an error
      
        gcc-11: error: "-Wimplicit-fallthrough=5": linker input file not found: No such file or directory
      
      Until this is more generally fixed as outlined in [1], by fixing
      scripts/link-vmlinux.sh, scripts/gen_autoksyms.sh, etc to not directly
      include the include/config/auto.conf, and in a second step, change
      Kconfig to generate the auto.conf without "", workaround the issue by
      explicitly unquoting CC_IMPLICIT_FALLTHROUGH.
      
      Reported-by: default avatarAndreas Beckmann <anbe@debian.org>
      Link: https://bugs.debian.org/1001083
      Link: https://lore.kernel.org/linux-kbuild/CAK7LNAR-VXwHFEJqCcrFDZj+_4+Xd6oynbj_0eS8N504_ydmyw@mail.gmail.com/
      
       [1]
      Signed-off-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cd8c917a
    • Alex Hung's avatar
      platform/x86/intel: hid: add quirk to support Surface Go 3 · 7d0c0090
      Alex Hung authored
      Similar to other systems Surface Go 3 requires a DMI quirk to enable
      5 button array for power and volume buttons.
      
      Buglink: https://github.com/linux-surface/linux-surface/issues/595
      
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlex Hung <alex.hung@canonical.com>
      Link: https://lore.kernel.org/r/20211203212810.2666508-1-alex.hung@canonical.com
      
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      7d0c0090
    • Linus Torvalds's avatar
      Merge tag 'docs-5.16-3' of git://git.lwn.net/linux · f80ef9e4
      Linus Torvalds authored
      Pull documentation fixes from Jonathan Corbet:
       "A few important documentation fixes, including breakage that comes
        with v1.0 of the ReadTheDocs theme"
      
      * tag 'docs-5.16-3' of git://git.lwn.net/linux:
        Documentation: Add minimum pahole version
        Documentation/process: fix self reference
        docs: admin-guide/blockdev: Remove digraph of node-states
        docs: conf.py: fix support for Readthedocs v 1.0.0
      f80ef9e4
    • Linus Torvalds's avatar
      Merge tag 'spi-fix-v5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 9d6cf472
      Linus Torvalds authored
      Pull spi fix from Mark Brown:
       "Just one trivial update adding a device ID to the DT bindings"
      
      * tag 'spi-fix-v5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: spi-rockchip: Add rk3568-spi compatible
      9d6cf472
    • Linus Torvalds's avatar
      Merge tag 'regulator-fix-v5.16-rc4' of... · b806bec5
      Linus Torvalds authored
      Merge tag 'regulator-fix-v5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
      
      Pull regulator fix from Mark Brown:
       "Documentation fix for v5.17.
      
        A fix for bitrot in the documentation for protection interrupts that
        crept in as the code was revised during review"
      
      * tag 'regulator-fix-v5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
        regulator: Update protection IRQ helper docs
      b806bec5
    • Linus Torvalds's avatar
      Merge tag 'efi-urgent-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi · 55a677b2
      Linus Torvalds authored
      Pull EFI fix from Ard Biesheuvel:
       "Ensure that the EFI memory map resides in encrypted memory even after
        it has been reallocated"
      
      * tag 'efi-urgent-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
        x86/sme: Explicitly map new EFI memmap table as encrypted
      55a677b2
  3. Dec 06, 2021
    • Linus Torvalds's avatar
      Linux 5.16-rc4 · 0fcfb00b
      Linus Torvalds authored
      0fcfb00b
    • Linus Torvalds's avatar
      Merge tag 'for-5.16/parisc-6' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux · 268ba095
      Linus Torvalds authored
      Pull parisc fixes from Helge Deller:
       "Some bug and warning fixes:
      
         - Fix "make install" to use debians "installkernel" script which is
           now in /usr/sbin
      
         - Fix the bindeb-pkg make target by giving the correct KBUILD_IMAGE
           file name
      
         - Fix compiler warnings by annotating parisc agp init functions with
           __init
      
         - Fix timekeeping on SMP machines with dual-core CPUs
      
         - Enable some more config options in the 64-bit defconfig"
      
      * tag 'for-5.16/parisc-6' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        parisc: Mark cr16 CPU clocksource unstable on all SMP machines
        parisc: Fix "make install" on newer debian releases
        parisc/agp: Annotate parisc agp init functions with __init
        parisc: Enable sata sil, audit and usb support on 64-bit defconfig
        parisc: Fix KBUILD_IMAGE for self-extracting kernel
      268ba095
    • Linus Torvalds's avatar
      Merge tag 'usb-5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 94420704
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some small USB fixes for a few reported issues. Included in
        here are:
      
         - xhci fix for a _much_ reported regression. I don't think there's a
           community distro that has not reported this problem yet :(
      
         - new USB quirk addition
      
         - cdns3 minor fixes
      
         - typec regression fix.
      
        All of these have been in linux-next with no reported problems, and
        the xhci fix has been reported by many to resolve their reported
        problem"
      
      * tag 'usb-5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        usb: cdnsp: Fix a NULL pointer dereference in cdnsp_endpoint_init()
        usb: cdns3: gadget: fix new urb never complete if ep cancel previous requests
        usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect
        USB: NO_LPM quirk Lenovo Powered USB-C Travel Hub
        xhci: Fix commad ring abort, write all 64 bits to CRCR register.
      94420704
    • Linus Torvalds's avatar
      Merge tag 'tty-5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 51639539
      Linus Torvalds authored
      Pull tty/serial fixes from Greg KH:
       "Here are some small TTY and Serial driver fixes for 5.16-rc4 to
        resolve a number of reported problems.
      
        They include:
      
         - liteuart serial driver fixes
      
         - 8250_pci serial driver fixes for pericom devices
      
         - 8250 RTS line control fix while in RS-485 mode
      
         - tegra serial driver fix
      
         - msm_serial driver fix
      
         - pl011 serial driver new id
      
         - fsl_lpuart revert of broken change
      
         - 8250_bcm7271 serial driver fix
      
         - MAINTAINERS file update for rpmsg tty driver that came in 5.16-rc1
      
         - vgacon fix for reported problem
      
        All of these, except for the 8250_bcm7271 fix have been in linux-next
        with no reported problem. The 8250_bcm7271 fix was added to the tree
        on Friday so no chance to be linux-next yet. But it should be fine as
        the affected developers submitted it"
      
      * tag 'tty-5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        serial: 8250_bcm7271: UART errors after resuming from S2
        serial: 8250_pci: rewrite pericom_do_set_divisor()
        serial: 8250_pci: Fix ACCES entries in pci_serial_quirks array
        serial: 8250: Fix RTS modem control while in rs485 mode
        Revert "tty: serial: fsl_lpuart: drop earlycon entry for i.MX8QXP"
        serial: tegra: Change lower tolerance baud rate limit for tegra20 and tegra30
        serial: liteuart: relax compile-test dependencies
        serial: liteuart: fix minor-number leak on probe errors
        serial: liteuart: fix use-after-free and memleak on unbind
        serial: liteuart: Fix NULL pointer dereference in ->remove()
        vgacon: Propagate console boot parameters before calling `vc_resize'
        tty: serial: msm_serial: Deactivate RX DMA for polling support
        serial: pl011: Add ACPI SBSA UART match id
        serial: core: fix transmit-buffer reset and memleak
        MAINTAINERS: Add rpmsg tty driver maintainer
      51639539
    • Linus Torvalds's avatar
      Merge tag 'timers_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 7587a4a5
      Linus Torvalds authored
      Pull timer fix from Borislav Petkov:
      
       - Prevent a tick storm when a dedicated timekeeper CPU in nohz_full
         mode runs for prolonged periods with interrupts disabled and ends up
         programming the next tick in the past, leading to that storm
      
      * tag 'timers_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        timers/nohz: Last resort update jiffies on nohz_full IRQ entry
      7587a4a5
    • Linus Torvalds's avatar
      Merge tag 'sched_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 1d213767
      Linus Torvalds authored
      Pull scheduler fixes from Borislav Petkov:
      
       - Properly init uclamp_flags of a runqueue, on first enqueuing
      
       - Fix preempt= callback return values
      
       - Correct utime/stime resource usage reporting on nohz_full to return
         the proper times instead of shorter ones
      
      * tag 'sched_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched/uclamp: Fix rq->uclamp_max not set on first enqueue
        preempt/dynamic: Fix setup_preempt_mode() return value
        sched/cputime: Fix getrusage(RUSAGE_THREAD) with nohz_full
      1d213767
    • Linus Torvalds's avatar
      Merge tag 'x86_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · f5d54a42
      Linus Torvalds authored
      Pull x86 fixes from Borislav Petkov:
      
       - Fix a couple of SWAPGS fencing issues in the x86 entry code
      
       - Use the proper operand types in __{get,put}_user() to prevent
         truncation in SEV-ES string io
      
       - Make sure the kernel mappings are present in trampoline_pgd in order
         to prevent any potential accesses to unmapped memory after switching
         to it
      
       - Fix a trivial list corruption in objtool's pv_ops validation
      
       - Disable the clocksource watchdog for TSC on platforms which claim
         that the TSC is constant, doesn't stop in sleep states, CPU has TSC
         adjust and the number of sockets of the platform are max 2, to
         prevent erroneous markings of the TSC as unstable.
      
       - Make sure TSC adjust is always checked not only when going idle
      
       - Prevent a stack leak by initializing struct _fpx_sw_bytes properly in
         the FPU code
      
       - Fix INTEL_FAM6_RAPTORLAKE define naming to adhere to the convention
      
      * tag 'x86_urgent_for_v5.16_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/xen: Add xenpv_restore_regs_and_return_to_usermode()
        x86/entry: Use the correct fence macro after swapgs in kernel CR3
        x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry()
        x86/sev: Fix SEV-ES INS/OUTS instructions for word, dword, and qword
        x86/64/mm: Map all kernel memory into trampoline_pgd
        objtool: Fix pv_ops noinstr validation
        x86/tsc: Disable clocksource watchdog for TSC on qualified platorms
        x86/tsc: Add a timer to make sure TSC_adjust is always checked
        x86/fpu/signal: Initialize sw_bytes in save_xstate_epilog()
        x86/cpu: Drop spurious underscore from RAPTOR_LAKE #define
      f5d54a42
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 90bf8d98
      Linus Torvalds authored
      Pull more kvm fixes from Paolo Bonzini:
      
       - Static analysis fix
      
       - New SEV-ES protocol for communicating invalid VMGEXIT requests
      
       - Ensure APICv is considered inactive if there is no APIC
      
       - Fix reserved bits for AMD PerfEvtSeln register
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: SVM: Do not terminate SEV-ES guests on GHCB validation failure
        KVM: SEV: Fall back to vmalloc for SEV-ES scratch area if necessary
        KVM: SEV: Return appropriate error codes if SEV-ES scratch setup fails
        KVM: x86/mmu: Retry page fault if root is invalidated by memslot update
        KVM: VMX: Set failure code in prepare_vmcs02()
        KVM: ensure APICv is considered inactive if there is no APIC
        KVM: x86/pmu: Fix reserved bits for AMD PerfEvtSeln register
      90bf8d98
  4. Dec 05, 2021
    • Tom Lendacky's avatar
      x86/sme: Explicitly map new EFI memmap table as encrypted · 1ff2fc02
      Tom Lendacky authored
      Reserving memory using efi_mem_reserve() calls into the x86
      efi_arch_mem_reserve() function. This function will insert a new EFI
      memory descriptor into the EFI memory map representing the area of
      memory to be reserved and marking it as EFI runtime memory. As part
      of adding this new entry, a new EFI memory map is allocated and mapped.
      The mapping is where a problem can occur. This new memory map is mapped
      using early_memremap() and generally mapped encrypted, unless the new
      memory for the mapping happens to come from an area of memory that is
      marked as EFI_BOOT_SERVICES_DATA memory. In this case, the new memory will
      be mapped unencrypted. However, during replacement of the old memory map,
      efi_mem_type() is disabled, so the new memory map will now be long-term
      mapped encrypted (in efi.memmap), resulting in the map containing invalid
      data and causing the kernel boot to crash.
      
      Since it is known that the area will be mapped encrypted going forward,
      explicitly map the new memory map as encrypted using early_memremap_prot().
      
      Cc: <stable@vger.kernel.org> # 4.14.x
      Fixes: 8f716c9b ("x86/mm: Add support to access boot related data in the clear")
      Link: https://lore.kernel.org/all/ebf1eb2940405438a09d51d121ec0d02c8755558.1634752931.git.thomas.lendacky@amd.com/
      
      
      Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      [ardb: incorporate Kconfig fix by Arnd]
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      1ff2fc02