1. 14 Dec, 2022 8 commits
    • Namhyung Kim's avatar
      perf stat: Fix multi-line metric output in JSON · 117195d9
      Namhyung Kim authored
      When a metric produces more than one values, it missed to print the opening
      bracket.
      
      Fixes: ab6baaae ("perf stat: Fix JSON output in metric-only mode")
      Reported-by: default avatarWeilin Wang <weilin.wang@intel.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarWeilin Wang <weilin.wang@intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.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: https://lore.kernel.org/r/20221202190447.1588680-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      117195d9
    • Ian Rogers's avatar
      tools lib symbol: Add dependency test to install_headers · 113bb396
      Ian Rogers authored
      Compute the headers to be installed from their source headers and make
      each have its own build target to install it. Using dependencies
      avoids headers being reinstalled and getting a new timestamp which
      then causes files that depend on the header to be rebuilt.
      Signed-off-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: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20221202045743.2639466-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      113bb396
    • Ian Rogers's avatar
      tools lib subcmd: Add dependency test to install_headers · 5d890591
      Ian Rogers authored
      Compute the headers to be installed from their source headers and make
      each have its own build target to install it. Using dependencies
      avoids headers being reinstalled and getting a new timestamp which
      then causes files that depend on the header to be rebuilt.
      Signed-off-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: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20221202045743.2639466-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5d890591
    • Ian Rogers's avatar
      tools lib perf: Add dependency test to install_headers · 47e02b94
      Ian Rogers authored
      Compute the headers to be installed from their source headers and make
      each have its own build target to install it. Using dependencies
      avoids headers being reinstalled and getting a new timestamp which
      then causes files that depend on the header to be rebuilt.
      Signed-off-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: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20221202045743.2639466-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47e02b94
    • Ian Rogers's avatar
      tools lib api: Add dependency test to install_headers · 1849f9f0
      Ian Rogers authored
      Compute the headers to be installed from their source headers and make
      each have its own build target to install it. Using dependencies
      avoids headers being reinstalled and getting a new timestamp which
      then causes files that depend on the header to be rebuilt.
      Signed-off-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: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20221202045743.2639466-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1849f9f0
    • Athira Rajeev's avatar
      perf stat: Fix printing field separator in CSV metrics output · 8f4b1e3c
      Athira Rajeev authored
      In 'perf stat' with CSV output option, number of fields in metrics
      output is not matching with number of fields in other event output
      lines.
      
      Sample output below after applying patch to fix printing os->prefix.
      
      	# ./perf stat -x, --per-socket -a -C 1 ls
      	S0,1,82.11,msec,cpu-clock,82111626,100.00,1.000,CPUs utilized
      	S0,1,2,,context-switches,82109314,100.00,24.358,/sec
      	------
      ====>	S0,1,,,,,,,1.71,stalled cycles per insn
      
      The above command line uses field separator as "," via "-x," option and
      per-socket option displays socket value as first field. But here the
      last line for "stalled cycles per insn" has more separators.  Each csv
      output line is expected to have 8 field separators (for the 9 fields),
      where as last line has 9 "," in the result. Patch fixes this issue.
      
      The counter stats are displayed by function
      "perf_stat__print_shadow_stats" in code "util/stat-shadow.c". While
      printing the stats info for "stalled cycles per insn", function
      "new_line_csv" is used as new_line callback.
      
      The fields printed in each line contains: "Socket_id,aggr
      nr,Avg,unit,event_name,run,enable_percent,ratio,unit"
      
      The metric output prints Socket_id, aggr nr, ratio and unit. It has to
      skip through remaining five fields ie,
      Avg,unit,event_name,run,enable_percent. The csv line callback uses
      "os->nfields" to know the number of fields to skip to match with other
      lines.
      
      Currently it is set as:
      
      	os.nfields = 3 + aggr_fields[config->aggr_mode] + (counter->cgrp ? 1 : 0);
      
      But in case of aggregation modes, csv_sep already gets printed along
      with each field (Function "aggr_printout" in util/stat-display.c). So
      aggr_fields can be removed from nfields. And fixed number of fields to
      skip has to be "4". This is to skip fields for: "avg, unit, event name,
      run, enable_percent"
      
      This needs 4 csv separators. Patch removes aggr_fields
      and uses 4 as fixed number of os->nfields to skip.
      
      After the patch:
      
      	# ./perf stat -x, --per-socket -a -C 1 ls
      	S0,1,79.08,msec,cpu-clock,79085956,100.00,1.000,CPUs utilized
      	S0,1,7,,context-switches,79084176,100.00,88.514,/sec
      	------
      ====>	S0,1,,,,,,0.81,stalled cycles per insn
      
      Fixes: 92a61f64 ("perf stat: Implement CSV metrics output")
      Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Signed-off-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20221205042852.83382-1-atrajeev@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8f4b1e3c
    • 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 4 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