1. 12 Jul, 2023 1 commit
    • Ian Rogers's avatar
      perf parse-events: Avoid SEGV if PMU lookup fails for legacy cache terms · 5b10c18d
      Ian Rogers authored
      libfuzzer found the following command could SEGV:
      
        $ perf stat -e cpu/L2,L2/ true
      
      This is because the L2 term rewrites the perf_event_attr type to
      PERF_TYPE_HW_CACHE which then fails the PMU lookup for the second
      legacy cache term.
      
      The new failure is consistent with repeated hardware terms:
      
        $ perf stat -e cpu/L2,L2/ true
        event syntax error: 'cpu/L2,L2/'
                                    \___ Failed to find PMU for type 3
      
        Initial error:
        event syntax error: 'cpu/L2,L2/'
                                    \___ Failed to find PMU for type 3
        Run 'perf list' for a list of valid events
      
         Usage: perf stat [<options>] [<command>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
        $ perf stat -e cpu/cycles,cycles/ true
        event syntax error: 'cpu/cycles,cycles/'
                                        \___ Failed to find PMU for type 0
      
        Initial error:
        event syntax error: 'cpu/cycles,cycles/'
                                        \___ Failed to find PMU for type 0
        Run 'perf list' for a list of valid events
      
         Usage: perf stat [<options>] [<command>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
      
      Committer testing:
      
      Before:
      
        $ perf stat -e cpu/L2,L2/ true
        Segmentation fault (core dumped)
        $
      
      After:
      
        $ perf stat -e cpu/L2,L2/ true
        event syntax error: 'cpu/L2,L2/'
                                    \___ Failed to find PMU for type 3
      
        Initial error:
        event syntax error: 'cpu/L2,L2/'
                                    \___ Failed to find PMU for type 3
        Run 'perf list' for a list of valid events
      
         Usage: perf stat [<options>] [<command>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
        $
      
      Fixes: 6fd1e519 ("perf parse-events: Support PMUs for legacy cache events")
      Signed-off-by: default avatarIan Rogers <irogers@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: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.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/20230712065250.1450306-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5b10c18d
  2. 11 Jul, 2023 12 commits
    • Ian Rogers's avatar
      libsubcmd: Avoid SEGV/use-after-free when commands aren't excluded · 4b966791
      Ian Rogers authored
      The array shortening may perform unnecessary array copies.
      
      Before commit 657a3efe ("lib subcmd: Avoid memory leak in
      exclude_cmds") this was benign, but afterwards this could lead to a
      SEGV.
      
      Fixes: 657a3efe ("lib subcmd: Avoid memory leak in exclude_cmds")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Chenyuan Mi <cymi20@fudan.edu.cn>
      Cc: Ian Rogers <irogers@google.com>
      Link: https://lore.kernel.org/r/20230707230926.841086-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4b966791
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/prctl.h with the kernel sources · ad07149f
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        1fd96a3e ("riscv: Add prctl controls for userspace vector management")
      
      That adds some RISC-V specific prctl options:
      
        $ tools/perf/trace/beauty/prctl_option.sh > before
        $ cp include/uapi/linux/prctl.h tools/include/uapi/linux/prctl.h
        $ tools/perf/trace/beauty/prctl_option.sh > after
        $ diff -u before after
        --- before	2023-07-11 13:22:01.928705942 -0300
        +++ after	2023-07-11 13:22:36.342645970 -0300
        @@ -63,6 +63,8 @@
         	[66] = "GET_MDWE",
         	[67] = "SET_MEMORY_MERGE",
         	[68] = "GET_MEMORY_MERGE",
        +	[69] = "RISCV_V_SET_CONTROL",
        +	[70] = "RISCV_V_GET_CONTROL",
         };
         static const char *prctl_set_mm_options[] = {
         	[1] = "START_CODE",
        $
      
      That now will be used to decode the syscall option and also to compose
      filters, for instance:
      
        [root@five ~]# perf trace -e syscalls:sys_enter_prctl --filter option==SET_NAME
             0.000 Isolated Servi/3474327 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7f23f13b7aee)
             0.032 DOM Worker/3474327 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7f23deb25670)
             7.920 :3474328/3474328 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7f23e24fbb10)
             7.935 StreamT~s #374/3474328 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7f23e24fb970)
             8.400 Isolated Servi/3474329 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7f23e24bab10)
             8.418 StreamT~s #374/3474329 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7f23e24ba970)
        ^C[root@five ~]#
      
      This addresses this perf build warning:
      
        Warning: Kernel ABI header differences:
          diff -u tools/include/uapi/linux/prctl.h include/uapi/linux/prctl.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andy Chiu <andy.chiu@sifive.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Link: https://lore.kernel.org/lkml/ZK2DhOB6JJKu2A7M@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ad07149f
    • Thomas Richter's avatar
      perf build: Fix broken feature check for libtracefs due to external lib changes · a87834d1
      Thomas Richter authored
      The perf build process auto-detects features and packages already
      installed for its build. This is done in directory tools/build/feature.
      This directory contains small sample programs. When they successfully
      compile the necessary prereqs in form of libraries and header files are
      present.
      
      Such a check is also done for libtracefs. And this check fails:
      
      Output before:
       # rm -f test-libtracefs.bin; make test-libtracefs.bin
       gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
      	 > test-libtracefs.make.output 2>&1 -ltracefs
       make: *** [Makefile:211: test-libtracefs.bin] Error 1
       # cat test-libtracefs.make.output
       In file included from test-libtracefs.c:2:
       /usr/include/tracefs/tracefs.h:11:10: fatal error: \
      	 event-parse.h: No such file or directory
         11 | #include <event-parse.h>
            |          ^~~~~~~~~~~~~~~
       compilation terminated.
       #
      
      The root cause of this compile error is commit 880885d9c22e
      ("libtracefs: Remove "traceevent/" from referencing libtraceevent
      headers") in the libtracefs project hosted here:
      https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
      
      That mentioned patch removes the traceevent/ directory name from
      the include statement, causing the file not to be included even
      when the libtraceevent-devel package is installed. This package contains
      the file referred to in tracefs/tracefs.h:
      
       # rpm -ql libtraceevent-devel
       /usr/include/traceevent
       /usr/include/traceevent/event-parse.h  <----- here
       /usr/include/traceevent/event-utils.h
       /usr/include/traceevent/kbuffer.h
       /usr/include/traceevent/trace-seq.h
       /usr/lib64/libtraceevent.so
       /usr/lib64/pkgconfig/libtraceevent.pc
       #
      
      With this patch the compile succeeds.
      
      Output after:
       # rm -f test-libtracefs.bin; make test-libtracefs.bin
       gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
      	 > test-libtracefs.make.output 2>&1 -I/usr/include/traceevent -ltracefs
       #
      
      Committer testing:
      
        $ make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools -C tools/perf install-bin
      
      Before:
      
        $ cat /tmp/build/perf-tools/feature/test-libtracefs.make.output
        In file included from test-libtracefs.c:2:
        /usr/include/tracefs/tracefs.h:11:10: fatal error: event-parse.h: No such file or directory
           11 | #include <event-parse.h>
              |          ^~~~~~~~~~~~~~~
        compilation terminated.
        $
        $ grep -i tracefs /tmp/build/perf-tools/FEATURE-DUMP
        feature-libtracefs=0
        $
      
      After:
      
        $ cat /tmp/build/perf-tools/feature/test-libtracefs.make.output
        $
        $ grep -i tracefs /tmp/build/perf-tools/FEATURE-DUMP
        feature-libtracefs=1
        $
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230711135338.397473-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a87834d1
    • Arnaldo Carvalho de Melo's avatar
      tools include UAPI: Sync linux/mount.h copy with the kernel sources · 920b91d9
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        6ac39281 ("fs: allow to mount beneath top mount")
      
      That, after a fix to the move_mount_flags.sh script, harvests the new
      MOVE_MOUNT_BENEATH move_mount flag:
      
        $ tools/perf/trace/beauty/move_mount_flags.sh > before
        $ cp include/uapi/linux/mount.h tools/include/uapi/linux/mount.h
        $ tools/perf/trace/beauty/move_mount_flags.sh > after
        $
        $ diff -u before after
        --- before	2023-07-11 12:38:49.244886707 -0300
        +++ after	2023-07-11 12:51:15.125255940 -0300
        @@ -6,4 +6,5 @@
         	[ilog2(0x00000020) + 1] = "T_AUTOMOUNTS",
         	[ilog2(0x00000040) + 1] = "T_EMPTY_PATH",
         	[ilog2(0x00000100) + 1] = "SET_GROUP",
        +	[ilog2(0x00000200) + 1] = "BENEATH",
         };
        $
      
      That will then be properly decoded when used in tools like:
      
        # perf trace -e move_mount
      
      This addresses this perf build warning:
      
        Warning: Kernel ABI header differences:
          diff -u tools/include/uapi/linux/mount.h include/uapi/linux/mount.h
      
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZK17kifP%2FiYl+Hcc@kernel.org/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      920b91d9
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/kvm.h with the kernel sources · 225bbf44
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        89d01306 ("RISC-V: KVM: Implement device interface for AIA irqchip")
        22725266 ("KVM: Fix comment for KVM_ENABLE_CAP")
        2f440b72 ("KVM: arm64: Add KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE")
      
      That just rebuilds perf, as these patches don't add any new KVM ioctl to
      be harvested for the the 'perf trace' ioctl syscall argument
      beautifiers.
      
      This addresses this perf build warning:
      
        Warning: Kernel ABI header differences:
          diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Anup Patel <apatel@ventanamicro.com>
      Cc: Binbin Wu <binbin.wu@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Ricardo Koller <ricarkol@google.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/lkml/ZK12+virXMIXMysy@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      225bbf44
    • Arnaldo Carvalho de Melo's avatar
      tools headers uapi: Sync linux/fcntl.h with the kernel sources · 48fa42c9
      Arnaldo Carvalho de Melo authored
      To get the changes in:
      
        96b2b072 ("exportfs: allow exporting non-decodeable file handles to userspace")
      
      That don't add anything that is handled by existing hard coded tables or
      table generation scripts.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header differences:
          diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZK11P5AwRBUxxutI@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      48fa42c9
    • Sandipan Das's avatar
      perf vendor events amd: Fix large metrics · 8d40f74e
      Sandipan Das authored
      There are cases where a metric requires more events than the number of
      available counters. E.g. AMD Zen, Zen 2 and Zen 3 processors have four
      data fabric counters but the "nps1_die_to_dram" metric has eight events.
      
      By default, the constituent events are placed in a group and since the
      events cannot be scheduled at the same time, the metric is not computed.
      The "all metrics" test also fails because of this.
      
      Use the NO_GROUP_EVENTS constraint for such metrics which anyway expect
      the user to run perf with "--metric-no-group".
      
      E.g.
      
        $ sudo perf test -v 101
      
      Before:
      
        101: perf all metrics test                                           :
        --- start ---
        test child forked, pid 37131
        Testing branch_misprediction_ratio
        Testing all_remote_links_outbound
        Testing nps1_die_to_dram
        Metric 'nps1_die_to_dram' not printed in:
        Error:
        Invalid event (dram_channel_data_controller_4) in per-thread mode, enable system wide with '-a'.
        Testing macro_ops_dispatched
        Testing all_l2_cache_accesses
        Testing all_l2_cache_hits
        Testing all_l2_cache_misses
        Testing ic_fetch_miss_ratio
        Testing l2_cache_accesses_from_l2_hwpf
        Testing l2_cache_misses_from_l2_hwpf
        Testing op_cache_fetch_miss_ratio
        Testing l3_read_miss_latency
        Testing l1_itlb_misses
        test child finished with -1
        ---- end ----
        perf all metrics test: FAILED!
      
      After:
      
        101: perf all metrics test                                           :
        --- start ---
        test child forked, pid 43766
        Testing branch_misprediction_ratio
        Testing all_remote_links_outbound
        Testing nps1_die_to_dram
        Testing macro_ops_dispatched
        Testing all_l2_cache_accesses
        Testing all_l2_cache_hits
        Testing all_l2_cache_misses
        Testing ic_fetch_miss_ratio
        Testing l2_cache_accesses_from_l2_hwpf
        Testing l2_cache_misses_from_l2_hwpf
        Testing op_cache_fetch_miss_ratio
        Testing l3_read_miss_latency
        Testing l1_itlb_misses
        test child finished with 0
        ---- end ----
        perf all metrics test: Ok
      Reported-by: default avatarAyush Jain <ayush.jain3@amd.com>
      Suggested-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarSandipan Das <sandipan.das@amd.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ananth Narayan <ananth.narayan@amd.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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Santosh Shukla <santosh.shukla@amd.com>
      Link: https://lore.kernel.org/r/20230706063440.54189-1-sandipan.das@amd.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8d40f74e
    • James Clark's avatar
      perf build: Fix library not found error when using CSLIBS · 1feece27
      James Clark authored
      -L only specifies the search path for libraries directly provided in the
      link line with -l. Because -lopencsd isn't specified, it's only linked
      because it's a dependency of -lopencsd_c_api. Dependencies like this are
      resolved using the default system search paths or -rpath-link=... rather
      than -L. This means that compilation only works if OpenCSD is installed
      to the system rather than provided with the CSLIBS (-L) option.
      
      This could be fixed by adding -Wl,-rpath-link=$(CSLIBS) but that is less
      conventional than just adding -lopencsd to the link line so that it uses
      -L. -lopencsd seems to have been removed in commit ed17b191
      ("perf tools: Drop requirement for libstdc++.so for libopencsd check")
      because it was thought that there was a chance compilation would work
      even if it didn't exist, but I think that only applies to libstdc++ so
      there is no harm to add it back. libopencsd.so and libopencsd_c_api.so
      would always exist together.
      
      Testing
      =======
      
      The following scenarios now all work:
      
       * Cross build with OpenCSD installed
       * Cross build using CSLIBS=...
       * Native build with OpenCSD installed
       * Native build using CSLIBS=...
       * Static cross build with OpenCSD installed
       * Static cross build with CSLIBS=...
      
      Committer testing:
      
        ⬢[acme@toolbox perf-tools]$ alias m
        alias m='make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools -C tools/perf install-bin && git status && perf test python ;  perf record -o /dev/null sleep 0.01 ; perf stat --null sleep 0.01'
        ⬢[acme@toolbox perf-tools]$ ldd ~/bin/perf | grep csd
        	libopencsd_c_api.so.1 => /lib64/libopencsd_c_api.so.1 (0x00007fd49c44e000)
        	libopencsd.so.1 => /lib64/libopencsd.so.1 (0x00007fd49bd56000)
        ⬢[acme@toolbox perf-tools]$ cat /etc/redhat-release
        Fedora release 36 (Thirty Six)
        ⬢[acme@toolbox perf-tools]$
      
      Fixes: ed17b191 ("perf tools: Drop requirement for libstdc++.so for libopencsd check")
      Reported-by: default avatarRadhey Shyam Pandey <radhey.shyam.pandey@amd.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarRadhey Shyam Pandey <radhey.shyam.pandey@amd.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Uwe Kleine-König <uwe@kleine-koenig.org>
      Cc: coresight@lists.linaro.org
      Closes: https://lore.kernel.org/linux-arm-kernel/56905d7a-a91e-883a-b707-9d5f686ba5f1@arm.com/
      Link: https://lore.kernel.org/all/36cc4dc6-bf4b-1093-1c0a-876e368af183@kleine-koenig.org/
      Link: https://lore.kernel.org/r/20230707154546.456720-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1feece27
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync files changed by new cachestat syscall with the kernel sources · 9350a917
      Arnaldo Carvalho de Melo authored
      To pick the changes in these csets:
      
        cf264e13 ("cachestat: implement cachestat syscall")
      
      That add support for this new syscall in tools such as 'perf trace'.
      
      For instance, this is now possible:
      
        # perf trace -e cachestat
        ^C[root@five ~]#
        # perf trace -v -e cachestat
        Using CPUID AuthenticAMD-25-21-0
        event qualifier tracepoint filter: (common_pid != 3163687 && common_pid != 3147) && (id == 451)
        mmap size 528384B
        ^C[root@five ~]
      
        # perf trace -v -e *stat* --max-events=10
        Using CPUID AuthenticAMD-25-21-0
        event qualifier tracepoint filter: (common_pid != 3163713 && common_pid != 3147) && (id == 4 || id == 5 || id == 6 || id == 136 || id == 137 || id == 138 || id == 262 || id == 332 || id == 451)
        mmap size 528384B
             0.000 ( 0.009 ms): Cache2 I/O/4544 statfs(pathname: 0x45635288, buf: 0x7f8745725b60)                     = 0
             0.012 ( 0.003 ms): Cache2 I/O/4544 newfstatat(dfd: CWD, filename: 0x45635288, statbuf: 0x7f874569d250)   = 0
             0.036 ( 0.002 ms): Cache2 I/O/4544 newfstatat(dfd: 138, filename: 0x541b7093, statbuf: 0x7f87457256f0, flag: 4096) = 0
             0.372 ( 0.006 ms): Cache2 I/O/4544 statfs(pathname: 0x45635288, buf: 0x7f8745725b10)                     = 0
             0.379 ( 0.003 ms): Cache2 I/O/4544 newfstatat(dfd: CWD, filename: 0x45635288, statbuf: 0x7f874569d250)   = 0
             0.390 ( 0.002 ms): Cache2 I/O/4544 newfstatat(dfd: 138, filename: 0x541b7093, statbuf: 0x7f87457256a0, flag: 4096) = 0
             0.609 ( 0.005 ms): Cache2 I/O/4544 statfs(pathname: 0x45635288, buf: 0x7f8745725b60)                     = 0
             0.615 ( 0.003 ms): Cache2 I/O/4544 newfstatat(dfd: CWD, filename: 0x45635288, statbuf: 0x7f874569d250)   = 0
             0.625 ( 0.002 ms): Cache2 I/O/4544 newfstatat(dfd: 138, filename: 0x541b7093, statbuf: 0x7f87457256f0, flag: 4096) = 0
             0.826 ( 0.005 ms): Cache2 I/O/4544 statfs(pathname: 0x45635288, buf: 0x7f8745725b10)                     = 0
        #
      
      That is the filter expression attached to the raw_syscalls:sys_{enter,exit}
      tracepoints.
      
        $ find tools/perf/arch/ -name "syscall*tbl" | xargs grep -w sys_cachestat
        tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl:451	n64	cachestat			sys_cachestat
        tools/perf/arch/powerpc/entry/syscalls/syscall.tbl:451	common	cachestat			sys_cachestat
        tools/perf/arch/s390/entry/syscalls/syscall.tbl:451  common	cachestat		sys_cachestat			sys_cachestat
        tools/perf/arch/x86/entry/syscalls/syscall_64.tbl:451	common	cachestat		sys_cachestat
        $
      
        $ grep -w cachestat /tmp/build/perf-tools/arch/x86/include/generated/asm/syscalls_64.c
        	[451] = "cachestat",
        $
      
      This addresses these perf build warnings:
      
      Warning: Kernel ABI header differences:
        diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
        diff -u tools/include/uapi/linux/mman.h include/uapi/linux/mman.h
        diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
        diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
        diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
        diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nhat Pham <nphamcs@gmail.com>
      Link: https://lore.kernel.org/lkml/ZK1pVBJpbjujJNJW@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9350a917
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync drm/i915_drm.h with the kernel sources · 142256d2
      Arnaldo Carvalho de Melo authored
        81b1b599 ("drm/i915: Allow user to set cache at BO creation")
        98d2722a ("drm/i915/huc: differentiate the 2 steps of the MTL HuC auth flow")
        bc4be0a3 ("drm/i915/pmu: Prepare for multi-tile non-engine counters")
        d1da138f ("drm/i915/uapi/pxp: Add a GET_PARAM for PXP")
      
      That adds some ioctls but use the __I915_PMU_OTHER() macro, not
      supported yet in the tools/perf/trace/beauty/drm_ioctl.sh conversion
      script.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header differences:
          diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
      Cc: Andi Shyti <andi.shyti@linux.intel.com>
      Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Cc: Fei Yang <fei.yang@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
      Link: https://lore.kernel.org/lkml/ZK1R%2FIyWcUKYQbQV@kernel.org/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      142256d2
    • Georg Müller's avatar
      perf probe: Read DWARF files from the correct CU · c66e1c68
      Georg Müller authored
      After switching from dwarf_decl_file() to die_get_decl_file(), it is not
      possible to add probes for certain functions:
      
        $ perf probe -x /usr/lib/systemd/systemd-logind match_unit_removed
        A function DIE doesn't have decl_line. Maybe broken DWARF?
        A function DIE doesn't have decl_line. Maybe broken DWARF?
        Probe point 'match_unit_removed' not found.
           Error: Failed to add events.
      
      The problem is that die_get_decl_file() uses the wrong CU to search for
      the file. elfutils commit e1db5cdc9f has some good explanation for this:
      
          dwarf_decl_file uses dwarf_attr_integrate to get the DW_AT_decl_file
          attribute. This means the attribute might come from a different DIE
          in a different CU. If so, we need to use the CU associated with the
          attribute, not the original DIE, to resolve the file name.
      
      This patch uses the same source of information as elfutils: use attribute
      DW_AT_decl_file and use this CU to search for the file.
      
      Fixes: dc9a5d2c ("perf probe: Fix to get declared file name from clang DWARF5")
      Signed-off-by: default avatarGeorg Müller <georgmueller@gmx.net>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: regressions@lists.linux.dev
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230628084551.1860532-6-georgmueller@gmx.netSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c66e1c68
    • Georg Müller's avatar
      perf probe: Add test for regression introduced by switch to die_get_decl_file() · 56cbeacf
      Georg Müller authored
      This patch adds a test to validate that 'perf probe' works for binaries
      where DWARF info is split into multiple CUs
      Signed-off-by: default avatarGeorg Müller <georgmueller@gmx.net>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: regressions@lists.linux.dev
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230628084551.1860532-5-georgmueller@gmx.netSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56cbeacf
  3. 10 Jul, 2023 2 commits
  4. 09 Jul, 2023 10 commits
  5. 08 Jul, 2023 15 commits
    • Hugh Dickins's avatar
      mm: lock newly mapped VMA with corrected ordering · 1c7873e3
      Hugh Dickins authored
      Lockdep is certainly right to complain about
      
        (&vma->vm_lock->lock){++++}-{3:3}, at: vma_start_write+0x2d/0x3f
                       but task is already holding lock:
        (&mapping->i_mmap_rwsem){+.+.}-{3:3}, at: mmap_region+0x4dc/0x6db
      
      Invert those to the usual ordering.
      
      Fixes: 33313a74 ("mm: lock newly mapped VMA which can be modified after it becomes visible")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Tested-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1c7873e3
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2023-07-08-10-43' of... · 946c6b59
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2023-07-08-10-43' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull hotfixes from Andrew Morton:
       "16 hotfixes. Six are cc:stable and the remainder address post-6.4
        issues"
      
      The merge undoes the disabling of the CONFIG_PER_VMA_LOCK feature, since
      it was all hopefully fixed in mainline.
      
      * tag 'mm-hotfixes-stable-2023-07-08-10-43' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        lib: dhry: fix sleeping allocations inside non-preemptable section
        kasan, slub: fix HW_TAGS zeroing with slub_debug
        kasan: fix type cast in memory_is_poisoned_n
        mailmap: add entries for Heiko Stuebner
        mailmap: update manpage link
        bootmem: remove the vmemmap pages from kmemleak in free_bootmem_page
        MAINTAINERS: add linux-next info
        mailmap: add Markus Schneider-Pargmann
        writeback: account the number of pages written back
        mm: call arch_swap_restore() from do_swap_page()
        squashfs: fix cache race with migration
        mm/hugetlb.c: fix a bug within a BUG(): inconsistent pte comparison
        docs: update ocfs2-devel mailing list address
        MAINTAINERS: update ocfs2-devel mailing list address
        mm: disable CONFIG_PER_VMA_LOCK until its fixed
        fork: lock VMAs of the parent process when forking
      946c6b59
    • Suren Baghdasaryan's avatar
      fork: lock VMAs of the parent process when forking · fb49c455
      Suren Baghdasaryan authored
      When forking a child process, the parent write-protects anonymous pages
      and COW-shares them with the child being forked using copy_present_pte().
      
      We must not take any concurrent page faults on the source vma's as they
      are being processed, as we expect both the vma and the pte's behind it
      to be stable.  For example, the anon_vma_fork() expects the parents
      vma->anon_vma to not change during the vma copy.
      
      A concurrent page fault on a page newly marked read-only by the page
      copy might trigger wp_page_copy() and a anon_vma_prepare(vma) on the
      source vma, defeating the anon_vma_clone() that wasn't done because the
      parent vma originally didn't have an anon_vma, but we now might end up
      copying a pte entry for a page that has one.
      
      Before the per-vma lock based changes, the mmap_lock guaranteed
      exclusion with concurrent page faults.  But now we need to do a
      vma_start_write() to make sure no concurrent faults happen on this vma
      while it is being processed.
      
      This fix can potentially regress some fork-heavy workloads.  Kernel
      build time did not show noticeable regression on a 56-core machine while
      a stress test mapping 10000 VMAs and forking 5000 times in a tight loop
      shows ~5% regression.  If such fork time regression is unacceptable,
      disabling CONFIG_PER_VMA_LOCK should restore its performance.  Further
      optimizations are possible if this regression proves to be problematic.
      Suggested-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reported-by: default avatarJiri Slaby <jirislaby@kernel.org>
      Closes: https://lore.kernel.org/all/dbdef34c-3a07-5951-e1ae-e9c6e3cdf51b@kernel.org/Reported-by: default avatarHolger Hoffstätte <holger@applied-asynchrony.com>
      Closes: https://lore.kernel.org/all/b198d649-f4bf-b971-31d0-e8433ec2a34c@applied-asynchrony.com/Reported-by: default avatarJacob Young <jacobly.alt@gmail.com>
      Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217624
      Fixes: 0bff0aae ("x86/mm: try VMA lock-based page fault handling first")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fb49c455
    • Suren Baghdasaryan's avatar
      mm: lock newly mapped VMA which can be modified after it becomes visible · 33313a74
      Suren Baghdasaryan authored
      mmap_region adds a newly created VMA into VMA tree and might modify it
      afterwards before dropping the mmap_lock.  This poses a problem for page
      faults handled under per-VMA locks because they don't take the mmap_lock
      and can stumble on this VMA while it's still being modified.  Currently
      this does not pose a problem since post-addition modifications are done
      only for file-backed VMAs, which are not handled under per-VMA lock.
      However, once support for handling file-backed page faults with per-VMA
      locks is added, this will become a race.
      
      Fix this by write-locking the VMA before inserting it into the VMA tree.
      Other places where a new VMA is added into VMA tree do not modify it
      after the insertion, so do not need the same locking.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      33313a74
    • Suren Baghdasaryan's avatar
      mm: lock a vma before stack expansion · c137381f
      Suren Baghdasaryan authored
      With recent changes necessitating mmap_lock to be held for write while
      expanding a stack, per-VMA locks should follow the same rules and be
      write-locked to prevent page faults into the VMA being expanded. Add
      the necessary locking.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c137381f
    • Linus Torvalds's avatar
      Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 7fcd473a
      Linus Torvalds authored
      Pull more SCSI updates from James Bottomley:
       "A few late arriving patches that missed the initial pull request. It's
        mostly bug fixes (the dt-bindings is a fix for the initial pull)"
      
      * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: ufs: core: Remove unused function declaration
        scsi: target: docs: Remove tcm_mod_builder.py
        scsi: target: iblock: Quiet bool conversion warning with pr_preempt use
        scsi: dt-bindings: ufs: qcom: Fix ICE phandle
        scsi: core: Simplify scsi_cdl_check_cmd()
        scsi: isci: Fix comment typo
        scsi: smartpqi: Replace one-element arrays with flexible-array members
        scsi: target: tcmu: Replace strlcpy() with strscpy()
        scsi: ncr53c8xx: Replace strlcpy() with strscpy()
        scsi: lpfc: Fix lpfc_name struct packing
      7fcd473a
    • Linus Torvalds's avatar
      Merge tag 'i2c-for-6.5-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · 84dc5aa3
      Linus Torvalds authored
      Pull more i2c updates from Wolfram Sang:
      
       - xiic patch should have been in the original pull but slipped through
      
       - mpc patch fixes a build regression
      
       - nomadik cleanup
      
      * tag 'i2c-for-6.5-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: mpc: Drop unused variable
        i2c: nomadik: Remove a useless call in the remove function
        i2c: xiic: Don't try to handle more interrupt events after error
      84dc5aa3
    • Linus Torvalds's avatar
      Merge tag 'hardening-v6.5-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · 8fc3b8f0
      Linus Torvalds authored
      Pull hardening fixes from Kees Cook:
      
       - Check for NULL bdev in LoadPin (Matthias Kaehlcke)
      
       - Revert unwanted KUnit FORTIFY build default
      
       - Fix 1-element array causing boot warnings with xhci-hub
      
      * tag 'hardening-v6.5-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        usb: ch9: Replace bmSublinkSpeedAttr 1-element array with flexible array
        Revert "fortify: Allow KUnit test to build without FORTIFY"
        dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter
      8fc3b8f0
    • Anup Sharma's avatar
      ntb: hw: amd: Fix debugfs_create_dir error checking · bff6efc5
      Anup Sharma authored
      The debugfs_create_dir function returns ERR_PTR in case of error, and the
      only correct way to check if an error occurred is 'IS_ERR' inline function.
      This patch will replace the null-comparison with IS_ERR.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Suggested-by: default avatarIvan Orlov <ivan.orlov0322@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      bff6efc5
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-for-v6.5-2-2023-07-06' of... · c206353d
      Linus Torvalds authored
      Merge tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next
      
      Pull more perf tools updates from Namhyung Kim:
       "These are remaining changes and fixes for this cycle.
      
        Build:
      
         - Allow generating vmlinux.h from BTF using `make GEN_VMLINUX_H=1`
           and skip if the vmlinux has no BTF.
      
         - Replace deprecated clang -target xxx option by --target=xxx.
      
        perf record:
      
         - Print event attributes with well known type and config symbols in
           the debug output like below:
      
             # perf record -e cycles,cpu-clock -C0 -vv true
             <SNIP>
             ------------------------------------------------------------
             perf_event_attr:
               type                             0 (PERF_TYPE_HARDWARE)
               size                             136
               config                           0 (PERF_COUNT_HW_CPU_CYCLES)
               { sample_period, sample_freq }   4000
               sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
               read_format                      ID
               disabled                         1
               inherit                          1
               freq                             1
               sample_id_all                    1
               exclude_guest                    1
             ------------------------------------------------------------
             sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 5
             ------------------------------------------------------------
             perf_event_attr:
               type                             1 (PERF_TYPE_SOFTWARE)
               size                             136
               config                           0 (PERF_COUNT_SW_CPU_CLOCK)
               { sample_period, sample_freq }   4000
               sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
               read_format                      ID
               disabled                         1
               inherit                          1
               freq                             1
               sample_id_all                    1
               exclude_guest                    1
      
         - Update AMD IBS event error message since it now support per-process
           profiling but no priviledge filters.
      
             $ sudo perf record -e ibs_op//k -C 0
             Error:
             AMD IBS doesn't support privilege filtering. Try again without
             the privilege modifiers (like 'k') at the end.
      
        perf lock contention:
      
         - Support CSV style output using -x option
      
             $ sudo perf lock con -ab -x, sleep 1
             # output: contended, total wait, max wait, avg wait, type, caller
             19, 194232, 21415, 10222, spinlock, process_one_work+0x1f0
             15, 162748, 23843, 10849, rwsem:R, do_user_addr_fault+0x40e
             4, 86740, 23415, 21685, rwlock:R, ep_poll_callback+0x2d
             1, 84281, 84281, 84281, mutex, iwl_mvm_async_handlers_wk+0x135
             8, 67608, 27404, 8451, spinlock, __queue_work+0x174
             3, 58616, 31125, 19538, rwsem:W, do_mprotect_pkey+0xff
             3, 52953, 21172, 17651, rwlock:W, do_epoll_wait+0x248
             2, 30324, 19704, 15162, rwsem:R, do_madvise+0x3ad
             1, 24619, 24619, 24619, spinlock, rcu_core+0xd4
      
         - Add --output option to save the data to a file not to be interfered
           by other debug messages.
      
        Test:
      
         - Fix event parsing test on ARM where there's no raw PMU nor supports
           PERF_PMU_CAP_EXTENDED_HW_TYPE.
      
         - Update the lock contention test case for CSV output.
      
         - Fix a segfault in the daemon command test.
      
        Vendor events (JSON):
      
         - Add has_event() to check if the given event is available on system
           at runtime. On Intel machines, some transaction events may not be
           present when TSC extensions are disabled.
      
         - Update Intel event metrics.
      
        Misc:
      
         - Sort symbols by name using an external array of pointers instead of
           a rbtree node in the symbol. This will save 16-bytes or 24-bytes
           per symbol whether the sorting is actually requested or not.
      
         - Fix unwinding DWARF callstacks using libdw when --symfs option is
           used"
      
      * tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next: (38 commits)
        perf test: Fix event parsing test when PERF_PMU_CAP_EXTENDED_HW_TYPE isn't supported.
        perf test: Fix event parsing test on Arm
        perf evsel amd: Fix IBS error message
        perf: unwind: Fix symfs with libdw
        perf symbol: Fix uninitialized return value in symbols__find_by_name()
        perf test: Test perf lock contention CSV output
        perf lock contention: Add --output option
        perf lock contention: Add -x option for CSV style output
        perf lock: Remove stale comments
        perf vendor events intel: Update tigerlake to 1.13
        perf vendor events intel: Update skylakex to 1.31
        perf vendor events intel: Update skylake to 57
        perf vendor events intel: Update sapphirerapids to 1.14
        perf vendor events intel: Update icelakex to 1.21
        perf vendor events intel: Update icelake to 1.19
        perf vendor events intel: Update cascadelakex to 1.19
        perf vendor events intel: Update meteorlake to 1.03
        perf vendor events intel: Add rocketlake events/metrics
        perf vendor metrics intel: Make transaction metrics conditional
        perf jevents: Support for has_event function
        ...
      c206353d
    • Linus Torvalds's avatar
      Merge tag 'bitmap-6.5-rc1' of https://github.com/norov/linux · ad8258e8
      Linus Torvalds authored
      Pull bitmap updates from Yury Norov:
       "Fixes for different bitmap pieces:
      
         - lib/test_bitmap: increment failure counter properly
      
           The tests that don't use expect_eq() macro to determine that a test
           is failured must increment failed_tests explicitly.
      
         - lib/bitmap: drop optimization of bitmap_{from,to}_arr64
      
           bitmap_{from,to}_arr64() optimization is overly optimistic
           on 32-bit LE architectures when it's wired to
           bitmap_copy_clear_tail().
      
         - nodemask: Drop duplicate check in for_each_node_mask()
      
           As the return value type of first_node() became unsigned, the node
           >= 0 became unnecessary.
      
         - cpumask: fix function description kernel-doc notation
      
         - MAINTAINERS: Add bits.h and bitfield.h to the BITMAP API record
      
           Add linux/bits.h and linux/bitfield.h for visibility"
      
      * tag 'bitmap-6.5-rc1' of https://github.com/norov/linux:
        MAINTAINERS: Add bitfield.h to the BITMAP API record
        MAINTAINERS: Add bits.h to the BITMAP API record
        cpumask: fix function description kernel-doc notation
        nodemask: Drop duplicate check in for_each_node_mask()
        lib/bitmap: drop optimization of bitmap_{from,to}_arr64
        lib/test_bitmap: increment failure counter properly
      ad8258e8
    • Geert Uytterhoeven's avatar
      lib: dhry: fix sleeping allocations inside non-preemptable section · 8ba388c0
      Geert Uytterhoeven authored
      The Smatch static checker reports the following warnings:
      
          lib/dhry_run.c:38 dhry_benchmark() warn: sleeping in atomic context
          lib/dhry_run.c:43 dhry_benchmark() warn: sleeping in atomic context
      
      Indeed, dhry() does sleeping allocations inside the non-preemptable
      section delimited by get_cpu()/put_cpu().
      
      Fix this by using atomic allocations instead.
      Add error handling, as atomic these allocations may fail.
      
      Link: https://lkml.kernel.org/r/bac6d517818a7cd8efe217c1ad649fffab9cc371.1688568764.git.geert+renesas@glider.be
      Fixes: 13684e96 ("lib: dhry: fix unstable smp_processor_id(_) usage")
      Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Closes: https://lore.kernel.org/r/0469eb3a-02eb-4b41-b189-de20b931fa56@moroto.mountainSigned-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8ba388c0
    • Andrey Konovalov's avatar
      kasan, slub: fix HW_TAGS zeroing with slub_debug · fdb54d96
      Andrey Konovalov authored
      Commit 946fa0db ("mm/slub: extend redzone check to extra allocated
      kmalloc space than requested") added precise kmalloc redzone poisoning to
      the slub_debug functionality.
      
      However, this commit didn't account for HW_TAGS KASAN fully initializing
      the object via its built-in memory initialization feature.  Even though
      HW_TAGS KASAN memory initialization contains special memory initialization
      handling for when slub_debug is enabled, it does not account for in-object
      slub_debug redzones.  As a result, HW_TAGS KASAN can overwrite these
      redzones and cause false-positive slub_debug reports.
      
      To fix the issue, avoid HW_TAGS KASAN memory initialization when
      slub_debug is enabled altogether.  Implement this by moving the
      __slub_debug_enabled check to slab_post_alloc_hook.  Common slab code
      seems like a more appropriate place for a slub_debug check anyway.
      
      Link: https://lkml.kernel.org/r/678ac92ab790dba9198f9ca14f405651b97c8502.1688561016.git.andreyknvl@google.com
      Fixes: 946fa0db ("mm/slub: extend redzone check to extra allocated kmalloc space than requested")
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Reported-by: default avatarWill Deacon <will@kernel.org>
      Acked-by: default avatarMarco Elver <elver@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: kasan-dev@googlegroups.com
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Collingbourne <pcc@google.com>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      fdb54d96
    • Andrey Konovalov's avatar
      kasan: fix type cast in memory_is_poisoned_n · 05c56e7b
      Andrey Konovalov authored
      Commit bb6e04a1 ("kasan: use internal prototypes matching gcc-13
      builtins") introduced a bug into the memory_is_poisoned_n implementation:
      it effectively removed the cast to a signed integer type after applying
      KASAN_GRANULE_MASK.
      
      As a result, KASAN started failing to properly check memset, memcpy, and
      other similar functions.
      
      Fix the bug by adding the cast back (through an additional signed integer
      variable to make the code more readable).
      
      Link: https://lkml.kernel.org/r/8c9e0251c2b8b81016255709d4ec42942dcaf018.1688431866.git.andreyknvl@google.com
      Fixes: bb6e04a1 ("kasan: use internal prototypes matching gcc-13 builtins")
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Marco Elver <elver@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      05c56e7b
    • Heiko Stuebner's avatar
      mailmap: add entries for Heiko Stuebner · d3a808ec
      Heiko Stuebner authored
      I am going to lose my vrull.eu address at the end of july, and while
      adding it to mailmap I also realised that there are more old addresses
      from me dangling, so update .mailmap for all of them.
      
      Link: https://lkml.kernel.org/r/20230704163919.1136784-3-heiko@sntech.deSigned-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarHeiko Stuebner <heiko.stuebner@vrull.eu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d3a808ec