1. 14 Dec, 2022 2 commits
    • Anshuman Khandual's avatar
      perf record: Add remaining branch filters: "no_cycles", "no_flags" & "hw_index" · 955f6def
      Anshuman Khandual authored
      This adds all remaining branch filters i.e "no_cycles", "no_flags" and
      "hw_index". While here, also updates the documentation.
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20221205064443.533587-1-anshuman.khandual@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      955f6def
    • Ian Rogers's avatar
      perf stat: Check existence of os->prefix, fixing a segfault · 3c97d25c
      Ian Rogers authored
      We need to check if we have a OS prefix, otherwise we stumble on a
      metric segv that I'm now seeing in Arnaldo's tree:
      
        $ gdb --args perf stat -M Backend true
        ...
        Performance counter stats for 'true':
      
                4,712,355      TOPDOWN.SLOTS                    #     17.3 % tma_core_bound
      
        Program received signal SIGSEGV, Segmentation fault.
        __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex.S:77
        77      ../sysdeps/x86_64/multiarch/strlen-evex.S: No such file or directory.
        (gdb) bt
        #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex.S:77
        #1  0x00007ffff74749a5 in __GI__IO_fputs (str=0x0, fp=0x7ffff75f5680 <_IO_2_1_stderr_>)
        #2  0x0000555555779f28 in do_new_line_std (config=0x555555e077c0 <stat_config>, os=0x7fffffffbf10) at util/stat-display.c:356
        #3  0x000055555577a081 in print_metric_std (config=0x555555e077c0 <stat_config>, ctx=0x7fffffffbf10, color=0x0, fmt=0x5555558b77b5 "%8.1f", unit=0x7fffffffbb10 "%  tma_memory_bound", val=13.165355724442199) at util/stat-display.c:380
        #4  0x00005555557768b6 in generic_metric (config=0x555555e077c0 <stat_config>, metric_expr=0x55555593d5b7 "((CYCLE_ACTIVITY.STALLS_MEM_ANY + EXE_ACTIVITY.BOUND_ON_STORES) / (CYCLE_ACTIVITY.STALLS_TOTAL + (EXE_ACTIVITY.1_PORTS_UTIL + tma_retiring * EXE_ACTIVITY.2_PORTS_UTIL) + EXE_ACTIVITY.BOUND_ON_STORES))"..., metric_events=0x555555f334e0, metric_refs=0x555555ec81d0, name=0x555555f32e80 "TOPDOWN.SLOTS", metric_name=0x555555f26c80 "tma_memory_bound", metric_unit=0x55555593d5b1 "100%", runtime=0, map_idx=0, out=0x7fffffffbd90, st=0x555555e9e620 <rt_stat>) at util/stat-shadow.c:934
        #5  0x0000555555778cac in perf_stat__print_shadow_stats (config=0x555555e077c0 <stat_config>, evsel=0x555555f289d0, avg=4712355, map_idx=0, out=0x7fffffffbd90, metric_events=0x555555e078e8 <stat_config+296>, st=0x555555e9e620 <rt_stat>) at util/stat-shadow.c:1329
        #6  0x000055555577b6a0 in printout (config=0x555555e077c0 <stat_config>, os=0x7fffffffbf10, uval=4712355, run=325322, ena=325322, noise=4712355, map_idx=0) at util/stat-display.c:741
        #7  0x000055555577bc74 in print_counter_aggrdata (config=0x555555e077c0 <stat_config>, counter=0x555555f289d0, s=0, os=0x7fffffffbf10) at util/stat-display.c:838
        #8  0x000055555577c1d8 in print_counter (config=0x555555e077c0 <stat_config>, counter=0x555555f289d0, os=0x7fffffffbf10) at util/stat-display.c:957
        #9  0x000055555577dba0 in evlist__print_counters (evlist=0x555555ec3610, config=0x555555e077c0 <stat_config>, _target=0x555555e01c80 <target>, ts=0x0, argc=1, argv=0x7fffffffe450) at util/stat-display.c:1413
        #10 0x00005555555fc821 in print_counters (ts=0x0, argc=1, argv=0x7fffffffe450) at builtin-stat.c:1040
        #11 0x000055555560091a in cmd_stat (argc=1, argv=0x7fffffffe450) at builtin-stat.c:2665
        #12 0x00005555556b1eea in run_builtin (p=0x555555e11f70 <commands+336>, argc=4, argv=0x7fffffffe450) at perf.c:322
        #13 0x00005555556b2181 in handle_internal_command (argc=4, argv=0x7fffffffe450) at perf.c:376
        #14 0x00005555556b22d7 in run_argv (argcp=0x7fffffffe27c, argv=0x7fffffffe270) at perf.c:420
        #15 0x00005555556b26ef in main (argc=4, argv=0x7fffffffe450) at perf.c:550
        (gdb)
      
      Fixes: f123b2d8 ("perf stat: Remove prefix argument in print_metric_headers()")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: http://lore.kernel.org/lkml/CAP-5=fUOjSM5HajU9TCD6prY39LbX4OQbkEbtKPPGRBPBN=_VQ@mail.gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3c97d25c
  2. 05 Dec, 2022 4 commits
  3. 24 Nov, 2022 24 commits
  4. 23 Nov, 2022 10 commits
    • Linus Torvalds's avatar
      Merge tag 'pci-v6.1-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · c3eb11fb
      Linus Torvalds authored
      Pull pci fixes from Bjorn Helgaas:
      
       - Update MAINTAINERS to add Manivannan Sadhasivam as Qcom PCIe RC
         maintainer (replacing Stanimir Varbanov) and include DT PCI bindings
         in the "PCI native host bridge and endpoint drivers" entry.
      
      * tag 'pci-v6.1-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        MAINTAINERS: Include PCI bindings in host bridge entry
        MAINTAINERS: Add Manivannan Sadhasivam as Qcom PCIe RC maintainer
      c3eb11fb
    • Linus Torvalds's avatar
      Merge tag 'spi-fix-v6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 4312098b
      Linus Torvalds authored
      Pull spi fixes from Mark Brown:
       "A few fixes, all device specific.
      
        The most important ones are for the i.MX driver which had a couple of
        nasty data corruption inducing errors appear after the change to
        support PIO mode in the last merge window (one introduced by the
        change and one latent one which the PIO changes exposed).
      
        Thanks to Frieder, Fabio, Marc and Marek for jumping on that and
        resolving the issues quickly once they were found"
      
      * tag 'spi-fix-v6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: spi-imx: spi_imx_transfer_one(): check for DMA transfer first
        spi: tegra210-quad: Fix duplicate resource error
        spi: dw-dma: decrease reference count in dw_spi_dma_init_mfld()
        spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock
        spi: mediatek: Fix DEVAPC Violation at KO Remove
      4312098b
    • Linus Torvalds's avatar
      Merge tag '9p-for-6.1-rc7' of https://github.com/martinetd/linux · fd64898d
      Linus Torvalds authored
      Pull 9p fixes from Dominique Martinet:
      
       - 9p now uses a variable size for its recv buffer, but every place
         hadn't been updated properly to use it and some buffer overflows have
         been found and needed fixing.
      
         There's still one place where msize is incorrectly used in a safety
         check (p9_check_errors), but all paths leading to it should already
         be avoiding overflows and that patch took a bit more time to get
         right for zero-copy requests so I'll send it for 6.2
      
       - yet another race condition in p9_conn_cancel introduced by a fix for
         a syzbot report in the same place. Maybe at some point we'll get it
         right without burning it all down...
      
      * tag '9p-for-6.1-rc7' of https://github.com/martinetd/linux:
        9p/xen: check logical size for buffer size
        9p/fd: Use P9_HDRSZ for header size
        9p/fd: Fix write overflow in p9_read_work
        9p/fd: fix issue of list_del corruption in p9_fd_cancel()
      fd64898d
    • David Howells's avatar
      fscache: fix OOB Read in __fscache_acquire_volume · 9f0933ac
      David Howells authored
      The type of a->key[0] is char in fscache_volume_same().  If the length
      of cache volume key is greater than 127, the value of a->key[0] is less
      than 0.  In this case, klen becomes much larger than 255 after type
      conversion, because the type of klen is size_t.  As a result, memcmp()
      is read out of bounds.
      
      This causes a slab-out-of-bounds Read in __fscache_acquire_volume(), as
      reported by Syzbot.
      
      Fix this by changing the type of the stored key to "u8 *" rather than
      "char *" (it isn't a simple string anyway).  Also put in a check that
      the volume name doesn't exceed NAME_MAX.
      
        BUG: KASAN: slab-out-of-bounds in memcmp+0x16f/0x1c0 lib/string.c:757
        Read of size 8 at addr ffff888016f3aa90 by task syz-executor344/3613
        Call Trace:
         memcmp+0x16f/0x1c0 lib/string.c:757
         memcmp include/linux/fortify-string.h:420 [inline]
         fscache_volume_same fs/fscache/volume.c:133 [inline]
         fscache_hash_volume fs/fscache/volume.c:171 [inline]
         __fscache_acquire_volume+0x76c/0x1080 fs/fscache/volume.c:328
         fscache_acquire_volume include/linux/fscache.h:204 [inline]
         v9fs_cache_session_get_cookie+0x143/0x240 fs/9p/cache.c:34
         v9fs_session_init+0x1166/0x1810 fs/9p/v9fs.c:473
         v9fs_mount+0xba/0xc90 fs/9p/vfs_super.c:126
         legacy_get_tree+0x105/0x220 fs/fs_context.c:610
         vfs_get_tree+0x89/0x2f0 fs/super.c:1530
         do_new_mount fs/namespace.c:3040 [inline]
         path_mount+0x1326/0x1e20 fs/namespace.c:3370
         do_mount fs/namespace.c:3383 [inline]
         __do_sys_mount fs/namespace.c:3591 [inline]
         __se_sys_mount fs/namespace.c:3568 [inline]
         __x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
      
      Fixes: 62ab6335 ("fscache: Implement volume registration")
      Reported-by: syzbot+a76f6a6e524cf2080aa3@syzkaller.appspotmail.com
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarZhang Peng <zhangpeng362@huawei.com>
      Reviewed-by: default avatarJingbo Xu <jefflexu@linux.alibaba.com>
      cc: Dominique Martinet <asmadeus@codewreck.org>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: v9fs-developer@lists.sourceforge.net
      cc: linux-cachefs@redhat.com
      Link: https://lore.kernel.org/r/Y3OH+Dmi0QIOK18n@codewreck.org/ # Zhang Peng's v1 fix
      Link: https://lore.kernel.org/r/20221115140447.2971680-1-zhangpeng362@huawei.com/ # Zhang Peng's v2 fix
      Link: https://lore.kernel.org/r/166869954095.3793579.8500020902371015443.stgit@warthog.procyon.org.uk/ # v1
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f0933ac
    • Namhyung Kim's avatar
      perf lock contention: Do not use BPF task local storage · c66a36af
      Namhyung Kim authored
      It caused some troubles when a lock inside kmalloc is contended
      because task local storage would allocate memory using kmalloc.
      It'd create a recusion and even crash in my system.
      
      There could be a couple of workarounds but I think the simplest
      one is to use a pre-allocated hash map.  We could fix the task
      local storage to use the safe BPF allocator, but it takes time
      so let's change this until it happens actually.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Chris Li <chriscli@google.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20221118190109.1512674-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c66a36af
    • John Garry's avatar
    • Michael Petlan's avatar
      perf test: Fix record test on KVM guests · 2e9f5bda
      Michael Petlan authored
      Using precise flag with br_inst_retired.near_call causes the test fail
      on KVM guests, even when the guests have PMU forwarding enabled and the
      event itself is supported.
      
      Remove the precise flag in order to make the test work on KVM guests.
      Signed-off-by: default avatarMichael Petlan <mpetlan@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Link: https://lore.kernel.org/r/20221122083121.6012-1-mpetlan@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2e9f5bda
    • Namhyung Kim's avatar
      perf inject: Set PERF_RECORD_MISC_BUILD_ID_SIZE · 19030564
      Namhyung Kim authored
      With perf inject -b, it synthesizes build-id event for DSOs.  But it
      missed to set the size and resulted in having trailing zeros.
      
      As perf record sets the size in write_build_id(), let's set the size
      here as well.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20221119002750.1568027-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      19030564
    • Naveen N. Rao's avatar
      perf test: Skip watchpoint tests if no watchpoints available · 7d54a4ac
      Naveen N. Rao authored
      On IBM Power9, perf watchpoint tests fail since no hardware breakpoints
      are available. Detect this by checking the error returned by
      perf_event_open() and skip the tests in that case.
      Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Reviewed-by: Kajol Jain<kjain@linux.ibm.com>
      Tested-by: Kajol Jain<kjain@linux.ibm.com>
      Link: https://lore.kernel.org/r/20221121102747.208289-1-naveen.n.rao@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      7d54a4ac
    • Leo Yan's avatar
      perf trace: Remove unused bpf map 'syscalls' · 8daf87f5
      Leo Yan authored
      augmented_raw_syscalls.c defines the bpf map 'syscalls' which is
      initialized by perf tool in user space to indicate which system calls
      are enabled for tracing, on the other flip eBPF program relies on the
      map to filter out the trace events which are not enabled.
      
      The map also includes a field 'string_args_len[6]' which presents the
      string length if the corresponding argument is a string type.
      
      Now the map 'syscalls' is not used, bpf program doesn't use it as filter
      anymore, this is replaced by using the function bpf_tail_call() and
      PROG_ARRAY syscalls map.  And we don't need to explicitly set the string
      length anymore, bpf_probe_read_str() is smart to copy the string and
      return string length.
      
      Therefore, it's safe to remove the bpf map 'syscalls'.
      
      To consolidate the code, this patch removes the definition of map
      'syscalls' from augmented_raw_syscalls.c and drops code for using
      the map in the perf trace.
      
      Note, since function trace__set_ev_qualifier_bpf_filter() is removed,
      calling trace__init_syscall_bpf_progs() from it is also removed.  We
      don't need to worry it because trace__init_syscall_bpf_progs() is
      still invoked from trace__init_syscalls_bpf_prog_array_maps() for
      initialization the system call's bpf program callback.
      
      After:
      
        # perf trace -e examples/bpf/augmented_raw_syscalls.c,open* --max-events 10 perf stat --quiet sleep 0.001
        openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libelf.so.1", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libdw.so.1", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libunwind.so.8", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libunwind-aarch64.so.8", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libcrypto.so.3", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libslang.so.2", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libperl.so.5.34", O_RDONLY|O_CLOEXEC) = 3
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
      
        # perf trace -e examples/bpf/augmented_raw_syscalls.c --max-events 10 perf stat --quiet sleep 0.001
        ... [continued]: execve())             = 0
        brk(NULL)                               = 0xaaaab1d28000
        faccessat(-100, "/etc/ld.so.preload", 4) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
        close(3</usr/lib/aarch64-linux-gnu/libcrypto.so.3>) = 0
        openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
        read(3</usr/lib/aarch64-linux-gnu/libcrypto.so.3>, 0xfffff33f70d0, 832) = 832
        munmap(0xffffb5519000, 28672)           = 0
        munmap(0xffffb55b7000, 32880)           = 0
        mprotect(0xffffb55a6000, 61440, PROT_NONE) = 0
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20221121075237.127706-6-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8daf87f5