1. 19 May, 2021 5 commits
    • Namhyung Kim's avatar
      perf tools: Add 'cgroup-switches' software event · fb6c79d7
      Namhyung Kim authored
      It counts how often cgroups are changed actually during the context
      switches.
      
        # perf stat -a -e context-switches,cgroup-switches -a sleep 1
      
         Performance counter stats for 'system wide':
      
                    11,267      context-switches
                    10,950      cgroup-switches
      
               1.015634369 seconds time elapsed
      
      Committer notes:
      
      The kernel patches landed in v5.13, but this entry wasn't filled in
      perf's parse-events tables, which was leading to a segfault when running
      'perf list' on a kernel with that feature, as reported by Thomas
      Richter.
      
      Also removed the part touching tools/include/uapi/linux/perf_event.h as
      it was updated in the usual sync with the kernel UAPI headers, in a
      previous, already upstream, patch.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20210210083327.22726-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fb6c79d7
    • Adrian Hunter's avatar
      perf intel-pt: Remove redundant setting of ptq->insn_len · 0a0c5972
      Adrian Hunter authored
      Remove redundant "ptq->insn_len = 0" statement.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20210519074515.9262-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a0c5972
    • Adrian Hunter's avatar
      perf intel-pt: Fix sample instruction bytes · c954eb72
      Adrian Hunter authored
      The decoder reports the current instruction if it was decoded. In some
      cases the current instruction is not decoded, in which case the instruction
      bytes length must be set to zero. Ensure that is always done.
      
      Note perf script can anyway get the instruction bytes for any samples where
      they are not present.
      
      Also note, that there is a redundant "ptq->insn_len = 0" statement which is
      not removed until a subsequent patch in order to make this patch apply
      cleanly to stable branches.
      
      Example:
      
      A machne that supports TSX is required. It will have flag "rtm". Kernel
      parameter tsx=on may be required.
      
       # for w in `cat /proc/cpuinfo | grep -m1 flags `;do echo $w | grep rtm ; done
       rtm
      
      Test program:
      
       #include <stdio.h>
       #include <immintrin.h>
      
       int main()
       {
              int x = 0;
      
              if (_xbegin() == _XBEGIN_STARTED) {
                      x = 1;
                      _xabort(1);
              } else {
                      printf("x = %d\n", x);
              }
              return 0;
       }
      
      Compile with -mrtm i.e.
      
       gcc -Wall -Wextra -mrtm xabort.c -o xabort
      
      Record:
      
       perf record -e intel_pt/cyc/u --filter 'filter main @ ./xabort' ./xabort
      
      Before:
      
       # perf script --itrace=xe -F+flags,+insn,-period --xed --ns
                xabort  1478 [007] 92161.431348581:   transactions:   x                              400b81 main+0x14 (/root/xabort)          mov $0xffffffff, %eax
                xabort  1478 [007] 92161.431348624:   transactions:   tx abrt                        400b93 main+0x26 (/root/xabort)          mov $0xffffffff, %eax
      
      After:
      
       # perf script --itrace=xe -F+flags,+insn,-period --xed --ns
                xabort  1478 [007] 92161.431348581:   transactions:   x                              400b81 main+0x14 (/root/xabort)          xbegin 0x6
                xabort  1478 [007] 92161.431348624:   transactions:   tx abrt                        400b93 main+0x26 (/root/xabort)          xabort $0x1
      
      Fixes: faaa8768 ("perf intel-pt/bts: Report instruction bytes and length in sample")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20210519074515.9262-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c954eb72
    • Adrian Hunter's avatar
      perf intel-pt: Fix transaction abort handling · cb798783
      Adrian Hunter authored
      When adding support for power events, some handling of FUP packets was
      unified. That resulted in breaking reporting of TSX aborts, by not
      considering the associated TIP packet. Fix that.
      
      Example:
      
      A machine that supports TSX is required. It will have flag "rtm". Kernel
      parameter tsx=on may be required.
      
       # for w in `cat /proc/cpuinfo | grep -m1 flags `;do echo $w | grep rtm ; done
       rtm
      
      Test program:
      
       #include <stdio.h>
       #include <immintrin.h>
      
       int main()
       {
              int x = 0;
      
              if (_xbegin() == _XBEGIN_STARTED) {
                      x = 1;
                      _xabort(1);
              } else {
                      printf("x = %d\n", x);
              }
              return 0;
       }
      
      Compile with -mrtm i.e.
      
       gcc -Wall -Wextra -mrtm xabort.c -o xabort
      
      Record:
      
       perf record -e intel_pt/cyc/u --filter 'filter main @ ./xabort' ./xabort
      
      Before:
      
       # perf script --itrace=be -F+flags,+addr,-period,-event --ns
                xabort  1478 [007] 92161.431348552:   tr strt                             0 [unknown] ([unknown]) =>           400b6d main+0x0 (/root/xabort)
                xabort  1478 [007] 92161.431348624:   jmp                            400b96 main+0x29 (/root/xabort) =>           400bae main+0x41 (/root/xabort)
                xabort  1478 [007] 92161.431348624:   return                         400bb4 main+0x47 (/root/xabort) =>           400b87 main+0x1a (/root/xabort)
                xabort  1478 [007] 92161.431348637:   jcc                            400b8a main+0x1d (/root/xabort) =>           400b98 main+0x2b (/root/xabort)
                xabort  1478 [007] 92161.431348644:   tr end  call                   400ba9 main+0x3c (/root/xabort) =>           40f690 printf+0x0 (/root/xabort)
                xabort  1478 [007] 92161.431360859:   tr strt                             0 [unknown] ([unknown]) =>           400bae main+0x41 (/root/xabort)
                xabort  1478 [007] 92161.431360882:   tr end  return                 400bb4 main+0x47 (/root/xabort) =>           401139 __libc_start_main+0x309 (/root/xabort)
      
      After:
      
       # perf script --itrace=be -F+flags,+addr,-period,-event --ns
                xabort  1478 [007] 92161.431348552:   tr strt                             0 [unknown] ([unknown]) =>           400b6d main+0x0 (/root/xabort)
                xabort  1478 [007] 92161.431348624:   tx abrt                        400b93 main+0x26 (/root/xabort) =>           400b87 main+0x1a (/root/xabort)
                xabort  1478 [007] 92161.431348637:   jcc                            400b8a main+0x1d (/root/xabort) =>           400b98 main+0x2b (/root/xabort)
                xabort  1478 [007] 92161.431348644:   tr end  call                   400ba9 main+0x3c (/root/xabort) =>           40f690 printf+0x0 (/root/xabort)
                xabort  1478 [007] 92161.431360859:   tr strt                             0 [unknown] ([unknown]) =>           400bae main+0x41 (/root/xabort)
                xabort  1478 [007] 92161.431360882:   tr end  return                 400bb4 main+0x47 (/root/xabort) =>           401139 __libc_start_main+0x309 (/root/xabort)
      
      Fixes: a472e65f ("perf intel-pt: Add decoder support for ptwrite and power event packets")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20210519074515.9262-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cb798783
    • Thomas Richter's avatar
      perf test: Fix libpfm4 support (63) test error for nested event groups · 316a76a5
      Thomas Richter authored
      Compiling perf with make LIBPFM4=1 includes libpfm support and
      enables test case 63 'Test libpfm4 support'. This test reports an error
      on all platforms for subtest 63.2 'test groups of --pfm-events'.
      The reported error message is 'nested event groups not supported'
      
       # ./perf test -F 63
       63: Test libpfm4 support                                            :
       63.1: test of individual --pfm-events                               :
       Error:
       failed to parse event stereolab : event not found
       Error:
       failed to parse event stereolab,instructions : event not found
       Error:
       failed to parse event instructions,stereolab : event not found
        Ok
       63.2: test groups of --pfm-events                                   :
       Error:
       nested event groups not supported    <------ Error message here
       Error:
       failed to parse event {stereolab} : event not found
       Error:
       failed to parse event {instructions,cycles},{instructions,stereolab} :\
      	 event not found
       Ok
       #
      
      This patch addresses the error message 'nested event groups not supported'.
      The root cause is function parse_libpfm_events_option() which parses the
      event string '{},{instructions}' and can not handle a leading empty
      group notation '{},...'.
      
      The code detects the first (empty) group indicator '{' but does not
      terminate group processing on the following group closing character '}'.
      So when the second group indicator '{' is detected, the code assumes
      a nested group and returns an error.
      
      With the error message fixed, also change the expected event number to
      one for the test case to succeed.
      
      While at it also fix a memory leak. In good case the function does not
      free the duplicated string given as first parameter.
      
      Output after:
       # ./perf test -F 63
       63: Test libpfm4 support                                            :
       63.1: test of individual --pfm-events                               :
       Error:
       failed to parse event stereolab : event not found
       Error:
       failed to parse event stereolab,instructions : event not found
       Error:
       failed to parse event instructions,stereolab : event not found
        Ok
       63.2: test groups of --pfm-events                                   :
       Error:
       failed to parse event {stereolab} : event not found
       Error:
       failed to parse event {instructions,cycles},{instructions,stereolab} : \
      	 event not found
        Ok
       #
      Error message 'nested event groups not supported' is gone.
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-By: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20210517140931.2559364-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      316a76a5
  2. 17 May, 2021 3 commits
    • Arnaldo Carvalho de Melo's avatar
      tools arch kvm: Sync kvm headers with the kernel sources · 3c91e8ef
      Arnaldo Carvalho de Melo authored
      To pick up the changes from:
      
        70f094f4 ("KVM: nVMX: Properly pad 'struct kvm_vmx_nested_state_hdr'")
      
      That don't entail changes in tooling.
      
      This silences these tools/perf build warnings:
      
        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: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3c91e8ef
    • Milian Wolff's avatar
      perf buildid-list: Initialize zstd_data · c67d7349
      Milian Wolff authored
      Fixes segmentation fault when trying to obtain buildid list (e.g. via
      perf-archive) from a zstd-compressed `perf.data` file:
      
      ```
          $ perf record -z ls
          ...
          [ perf record: Captured and wrote 0,010 MB perf.data, compressed (original 0,001 MB, ratio is 2,190) ]
          $ memcheck perf buildid-list
          ...
          ==57268== Invalid read of size 4
          ==57268==    at 0x5260D88: ZSTD_decompressStream (in /usr/lib/libzstd.so.1.4.9)
          ==57268==    by 0x4BB51B: zstd_decompress_stream (zstd.c:100)
          ==57268==    by 0x425C6C: perf_session__process_compressed_event (session.c:73)
          ==57268==    by 0x427450: perf_session__process_user_event (session.c:1631)
          ==57268==    by 0x42A609: reader__process_events (session.c:2207)
          ==57268==    by 0x42A609: __perf_session__process_events (session.c:2264)
          ==57268==    by 0x42A609: perf_session__process_events (session.c:2297)
          ==57268==    by 0x343A62: perf_session__list_build_ids (builtin-buildid-list.c:88)
          ==57268==    by 0x343A62: cmd_buildid_list (builtin-buildid-list.c:120)
          ==57268==    by 0x3C7732: run_builtin (perf.c:313)
          ==57268==    by 0x331157: handle_internal_command (perf.c:365)
          ==57268==    by 0x331157: run_argv (perf.c:409)
          ==57268==    by 0x331157: main (perf.c:539)
          ==57268==  Address 0x7470 is not stack'd, malloc'd or (recently) free'd
      ```
      Signed-off-by: default avatarMilian Wolff <milian.wolff@kdab.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Link: http://lore.kernel.org/lkml/20210429185759.59870-1-milian.wolff@kdab.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c67d7349
    • Linus Torvalds's avatar
      Merge tag 'for-5.13-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 8ac91e6c
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "A few more fixes:
      
         - fix fiemap to print extents that could get misreported due to
           internal extent splitting and logical merging for fiemap output
      
         - fix RCU stalls during delayed iputs
      
         - fix removed dentries still existing after log is synced"
      
      * tag 'for-5.13-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: fix removed dentries still existing after log is synced
        btrfs: return whole extents in fiemap
        btrfs: avoid RCU stalls while running delayed iputs
        btrfs: return 0 for dev_extent_hole_check_zoned hole_start in case of error
      8ac91e6c
  3. 16 May, 2021 7 commits
    • Linus Torvalds's avatar
      Linux 5.13-rc2 · d07f6ca9
      Linus Torvalds authored
      d07f6ca9
    • Linus Torvalds's avatar
      Merge tag 'driver-core-5.13-rc2' of... · 28183dbf
      Linus Torvalds authored
      Merge tag 'driver-core-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
      
      Pull driver core fixes from Greg KH:
       "Here are two driver fixes for driver core changes that happened in
        5.13-rc1.
      
        The clk driver fix resolves a many-reported issue with booting some
        devices, and the USB typec fix resolves the reported problem of USB
        systems on some embedded boards.
      
        Both of these have been in linux-next this week with no reported
        issues"
      
      * tag 'driver-core-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
        clk: Skip clk provider registration when np is NULL
        usb: typec: tcpm: Don't block probing of consumers of "connector" nodes
      28183dbf
    • Linus Torvalds's avatar
      Merge tag 'staging-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 6942d81a
      Linus Torvalds authored
      Pull staging and IIO driver fixes from Greg KH:
       "Here are some small IIO driver fixes and one Staging driver fix for
        5.13-rc2.
      
        Nothing major, just some resolutions for reported problems:
      
         - gcc-11 bogus warning fix for rtl8723bs
      
         - iio driver tiny fixes
      
        All of these have been in linux-next for many days with no reported
        issues"
      
      * tag 'staging-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
        iio: tsl2583: Fix division by a zero lux_val
        iio: core: return ENODEV if ioctl is unknown
        iio: core: fix ioctl handlers removal
        iio: gyro: mpu3050: Fix reported temperature value
        iio: hid-sensors: select IIO_TRIGGERED_BUFFER under HID_SENSOR_IIO_TRIGGER
        iio: proximity: pulsedlight: Fix rumtime PM imbalance on error
        iio: light: gp2ap002: Fix rumtime PM imbalance on error
        staging: rtl8723bs: avoid bogus gcc warning
      6942d81a
    • Linus Torvalds's avatar
      Merge tag 'usb-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 4a668429
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some small USB fixes for 5.13-rc2. They consist of a number
        of resolutions for reported issues:
      
         - typec fixes for found problems
      
         - xhci fixes and quirk additions
      
         - dwc3 driver fixes
      
         - minor fixes found by Coverity
      
         - cdc-wdm fixes for reported problems
      
        All of these have been in linux-next for a few days with no reported
        issues"
      
      * tag 'usb-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (28 commits)
        usb: core: hub: fix race condition about TRSMRCY of resume
        usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default
        xhci: Add reset resume quirk for AMD xhci controller.
        usb: xhci: Increase timeout for HC halt
        xhci: Do not use GFP_KERNEL in (potentially) atomic context
        xhci: Fix giving back cancelled URBs even if halted endpoint can't reset
        xhci-pci: Allow host runtime PM as default for Intel Alder Lake xHCI
        usb: musb: Fix an error message
        usb: typec: tcpm: Fix wrong handling for Not_Supported in VDM AMS
        usb: typec: tcpm: Send DISCOVER_IDENTITY from dedicated work
        usb: typec: ucsi: Retrieve all the PDOs instead of just the first 4
        usb: fotg210-hcd: Fix an error message
        docs: usb: function: Modify path name
        usb: dwc3: omap: improve extcon initialization
        usb: typec: ucsi: Put fwnode in any case during ->probe()
        usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP
        usb: dwc2: Remove obsolete MODULE_ constants from platform.c
        usb: dwc3: imx8mp: fix error return code in dwc3_imx8mp_probe()
        usb: dwc3: imx8mp: detect dwc3 core node via compatible string
        usb: dwc3: gadget: Return success always for kick transfer in ep queue
        ...
      4a668429
    • Linus Torvalds's avatar
      Merge tag 'timers-urgent-2021-05-16' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 8ce36481
      Linus Torvalds authored
      Pull timer fixes from Thomas Gleixner:
       "Two fixes for timers:
      
         - Use the ALARM feature check in the alarmtimer core code insted of
           the old method of checking for the set_alarm() callback.
      
           Drivers can have that callback set but the feature bit cleared. If
           such a RTC device is selected then alarms wont work.
      
         - Use a proper define to let the preprocessor check whether Hyper-V
           VDSO clocksource should be active.
      
           The code used a constant in an enum with #ifdef, which evaluates to
           always false and disabled the clocksource for VDSO"
      
      * tag 'timers-urgent-2021-05-16' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        clocksource/drivers/hyper-v: Re-enable VDSO_CLOCKMODE_HVCLOCK on X86
        alarmtimer: Check RTC features instead of ops
      8ce36481
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.13b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · f44e58bb
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
      
       - two patches for error path fixes
      
       - a small series for fixing a regression with swiotlb with Xen on Arm
      
      * tag 'for-linus-5.13b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        xen/swiotlb: check if the swiotlb has already been initialized
        arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required
        xen/arm: move xen_swiotlb_detect to arm/swiotlb-xen.h
        xen/unpopulated-alloc: fix error return code in fill_list()
        xen/gntdev: fix gntdev_mmap() error exit path
      f44e58bb
    • Linus Torvalds's avatar
      Merge tag 'x86_urgent_for_v5.13_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · ccb013c2
      Linus Torvalds authored
      Pull x86 fixes from Borislav Petkov:
       "The three SEV commits are not really urgent material. But we figured
        since getting them in now will avoid a huge amount of conflicts
        between future SEV changes touching tip, the kvm and probably other
        trees, sending them to you now would be best.
      
        The idea is that the tip, kvm etc branches for 5.14 will all base
        ontop of -rc2 and thus everything will be peachy. What is more, those
        changes are purely mechanical and defines movement so they should be
        fine to go now (famous last words).
      
        Summary:
      
         - Enable -Wundef for the compressed kernel build stage
      
         - Reorganize SEV code to streamline and simplify future development"
      
      * tag 'x86_urgent_for_v5.13_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/boot/compressed: Enable -Wundef
        x86/msr: Rename MSR_K8_SYSCFG to MSR_AMD64_SYSCFG
        x86/sev: Move GHCB MSR protocol and NAE definitions in a common header
        x86/sev-es: Rename sev-es.{ch} to sev.{ch}
      ccb013c2
  4. 15 May, 2021 25 commits