1. 09 Apr, 2022 24 commits
    • James Clark's avatar
      perf unwind: Don't show unwind error messages when augmenting frame pointer stack · fa7095c5
      James Clark authored
      Commit Fixes: b9f6fbb3 ("perf arm64: Inject missing frames when
      using 'perf record --call-graph=fp'") intended to add a 'best effort'
      DWARF unwind that improved the frame pointer stack in most scenarios.
      
      It's expected that the unwind will fail sometimes, but this shouldn't be
      reported as an error. It only works when the return address can be
      determined from the contents of the link register alone.
      
      Fix the error shown when the unwinder requires extra registers by adding
      a new flag that suppresses error messages. This flag is not set in the
      normal --call-graph=dwarf unwind mode so that behavior is not changed.
      
      Fixes: b9f6fbb3 ("perf arm64: Inject missing frames when using 'perf record --call-graph=fp'")
      Reported-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Tested-by: default avatarJohn Garry <john.garry@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Truong <alexandre.truong@arm.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20220406145651.1392529-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fa7095c5
    • Arnaldo Carvalho de Melo's avatar
      tools headers arm64: Sync arm64's cputype.h with the kernel sources · 278aaba2
      Arnaldo Carvalho de Melo authored
      To get the changes in:
      
        83bea32a ("arm64: Add part number for Arm Cortex-A78AE")
      
      That addresses this perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/arm64/include/asm/cputype.h' differs from latest version at 'arch/arm64/include/asm/cputype.h'
        diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
      
      Cc: Ali Saidi <alisaidi@amazon.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Chanho Park <chanho61.park@samsung.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      278aaba2
    • Chengdong Li's avatar
      perf test tsc: Fix error message when not supported · 290fa68b
      Chengdong Li authored
      By default `perf test tsc` does not return the error message when the
      child process detected kernel does not support it. Instead, the child
      process prints an error message to stderr, unfortunately stderr is
      redirected to /dev/null when verbose <= 0.
      
      This patch does:
      
      - return TEST_SKIP to the parent process instead of TEST_OK when
        perf_read_tsc_conversion() is not supported.
      
      - Add a new subtest of testing if TSC is supported on current
        architecture by moving exist code to a separate function.
        It avoids two places in test__perf_time_to_tsc() that return
        TEST_SKIP by doing this.
      
      - Extend the test suite definition to contain above two subtests.
        Current test_suite and test_case structs do not support printing skip
        reason when the number of subtest less than 1. To print skip reason, it
        is necessary to extend current test suite definition.
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarChengdong Li <chengdongli@tencent.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@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: likexu@tencent.com
      Link: https://lore.kernel.org/r/20220408084748.43707-1-chengdongli@tencent.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      290fa68b
    • Arnaldo Carvalho de Melo's avatar
      perf build: Don't use -ffat-lto-objects in the python feature test when building with clang-13 · 3a8a0475
      Arnaldo Carvalho de Melo authored
      Using -ffat-lto-objects in the python feature test when building with
      clang-13 results in:
      
        clang-13: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]
        error: command '/usr/sbin/clang' failed with exit code 1
        cp: cannot stat '/tmp/build/perf/python_ext_build/lib/perf*.so': No such file or directory
        make[2]: *** [Makefile.perf:639: /tmp/build/perf/python/perf.so] Error 1
      
      Noticed when building on a docker.io/library/archlinux:base container.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Keeping <john@metanate.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Sedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3a8a0475
    • Arnaldo Carvalho de Melo's avatar
      perf python: Fix probing for some clang command line options · dd6e1fe9
      Arnaldo Carvalho de Melo authored
      The clang compiler complains about some options even without a source
      file being available, while others require one, so use the simple
      tools/build/feature/test-hello.c file.
      
      Then check for the "is not supported" string in its output, in addition
      to the "unknown argument" already being looked for.
      
      This was noticed when building with clang-13 where -ffat-lto-objects
      isn't supported and since we were looking just for "unknown argument"
      and not providing a source code to clang, was mistakenly assumed as
      being available and not being filtered to set of command line options
      provided to clang, leading to a build failure.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Keeping <john@metanate.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Sedat Dilek <sedat.dilek@gmail.com>
      Link: http://lore.kernel.org/lkml/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dd6e1fe9
    • Arnaldo Carvalho de Melo's avatar
      tools build: Filter out options and warnings not supported by clang · 41caff45
      Arnaldo Carvalho de Melo authored
      These make the feature check fail when using clang, so remove them just
      like is done in tools/perf/Makefile.config to build perf itself.
      
      Adding -Wno-compound-token-split-by-macro to tools/perf/Makefile.config
      when building with clang is also necessary to avoid these warnings
      turned into errors (-Werror):
      
          CC      /tmp/build/perf/util/scripting-engines/trace-event-perl.o
        In file included from util/scripting-engines/trace-event-perl.c:35:
        In file included from /usr/lib64/perl5/CORE/perl.h:4085:
        In file included from /usr/lib64/perl5/CORE/hv.h:659:
        In file included from /usr/lib64/perl5/CORE/hv_func.h:34:
        In file included from /usr/lib64/perl5/CORE/sbox32_hash.h:4:
        /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
            ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /usr/lib64/perl5/CORE/zaphod32_hash.h:80:38: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
        #define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START {  \
                                             ^~~~~~~~~~
        /usr/lib64/perl5/CORE/perl.h:737:29: note: expanded from macro 'STMT_START'
        #   define STMT_START   (void)( /* gcc supports "({ STATEMENTS; })" */
                                      ^
        /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: '{' token is here
            ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /usr/lib64/perl5/CORE/zaphod32_hash.h:80:49: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
        #define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START {  \
                                                        ^
        /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
            ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /usr/lib64/perl5/CORE/zaphod32_hash.h:87:41: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
            v ^= (v>>23);                       \
                                                ^
        /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: ')' token is here
            ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /usr/lib64/perl5/CORE/zaphod32_hash.h:88:3: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
        } STMT_END
          ^~~~~~~~
        /usr/lib64/perl5/CORE/perl.h:738:21: note: expanded from macro 'STMT_END'
        #   define STMT_END     )
                                ^
      
      Please refer to the discussion on the Link: tag below, where Nathan
      clarifies the situation:
      
      <quote>
      acme> And then get to the problems at the end of this message, which seem
      acme> similar to the problem described here:
      acme>
      acme> From  Nathan Chancellor <>
      acme> Subject	[PATCH] mwifiex: Remove unnecessary braces from HostCmd_SET_SEQ_NO_BSS_INFO
      acme>
      acme> https://lkml.org/lkml/2020/9/1/135
      acme>
      acme> So perhaps in this case its better to disable that
      acme> -Werror,-Wcompound-token-split-by-macro when building with clang?
      
      Yes, I think that is probably the best solution. As far as I can tell,
      at least in this file and context, the warning appears harmless, as the
      "create a GNU C statement expression from two different macros" is very
      much intentional, based on the presence of PERL_USE_GCC_BRACE_GROUPS.
      The warning is fixed in upstream Perl by just avoiding creating GNU C
      statement expressions using STMT_START and STMT_END:
      
        https://github.com/Perl/perl5/issues/18780
        https://github.com/Perl/perl5/pull/18984
      
      If I am reading the source code correctly, an alternative to disabling
      the warning would be specifying -DPERL_GCC_BRACE_GROUPS_FORBIDDEN but it
      seems like that might end up impacting more than just this site,
      according to the issue discussion above.
      </quote>
      Based-on-a-patch-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # Debian/Selfmade LLVM-14 (x86-64)
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Keeping <john@metanate.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Link: http://lore.kernel.org/lkml/YkxWcYzph5pC1EK8@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      41caff45
    • Arnaldo Carvalho de Melo's avatar
      tools build: Use $(shell ) instead of `` to get embedded libperl's ccopts · 541f695c
      Arnaldo Carvalho de Melo authored
      Just like its done for ldopts and for both in tools/perf/Makefile.config.
      
      Using `` to initialize PERL_EMBED_CCOPTS somehow precludes using:
      
        $(filter-out SOMETHING_TO_FILTER,$(PERL_EMBED_CCOPTS))
      
      And we need to do it to allow for building with versions of clang where
      some gcc options selected by distros are not available.
      
      Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # Debian/Selfmade LLVM-14 (x86-64)
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Keeping <john@metanate.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Link: http://lore.kernel.org/lkml/YktYX2OnLtyobRYD@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      541f695c
    • Arnaldo Carvalho de Melo's avatar
      tools include UAPI: Sync linux/vhost.h with the kernel sources · 940442de
      Arnaldo Carvalho de Melo authored
      To get the changes in:
      
        b04d910a ("vdpa: support exposing the count of vqs to userspace")
        a61280dd ("vdpa: support exposing the config size to userspace")
      
      Silencing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/vhost.h' differs from latest version at 'include/uapi/linux/vhost.h'
        diff -u tools/include/uapi/linux/vhost.h include/uapi/linux/vhost.h
      
        $ diff -u tools/include/uapi/linux/vhost.h include/uapi/linux/vhost.h
        --- tools/include/uapi/linux/vhost.h	2021-07-15 16:17:01.840818309 -0300
        +++ include/uapi/linux/vhost.h	2022-04-02 18:55:05.702522387 -0300
        @@ -150,4 +150,11 @@
         /* Get the valid iova range */
         #define VHOST_VDPA_GET_IOVA_RANGE	_IOR(VHOST_VIRTIO, 0x78, \
         					     struct vhost_vdpa_iova_range)
        +
        +/* Get the config size */
        +#define VHOST_VDPA_GET_CONFIG_SIZE	_IOR(VHOST_VIRTIO, 0x79, __u32)
        +
        +/* Get the count of all virtqueues */
        +#define VHOST_VDPA_GET_VQS_COUNT	_IOR(VHOST_VIRTIO, 0x80, __u32)
        +
         #endif
        $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
        $ cp include/uapi/linux/vhost.h tools/include/uapi/linux/vhost.h
        $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
        $ diff -u before after
        --- before	2022-04-04 14:52:25.036375145 -0300
        +++ after	2022-04-04 14:52:31.906549976 -0300
        @@ -38,4 +38,6 @@
         	[0x73] = "VDPA_GET_CONFIG",
         	[0x76] = "VDPA_GET_VRING_NUM",
         	[0x78] = "VDPA_GET_IOVA_RANGE",
        +	[0x79] = "VDPA_GET_CONFIG_SIZE",
        +	[0x80] = "VDPA_GET_VQS_COUNT",
         };
        $
      
      Cc: Longpeng <longpeng2@huawei.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Link: https://lore.kernel.org/lkml/YksxoFcOARk%2Fldev@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      940442de
    • Linus Torvalds's avatar
      Merge tag 'block-5.18-2022-04-08' of git://git.kernel.dk/linux-block · f1b45d8c
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
       "Nothing major in here, just a few small fixes:
      
         - Small series of neglected drbd patches (Christoph, Lv, Xiaomeng)
      
         - Remove dead variable in cdrom (Enze)"
      
      * tag 'block-5.18-2022-04-08' of git://git.kernel.dk/linux-block:
        drbd: set QUEUE_FLAG_STABLE_WRITES
        drbd: fix an invalid memory access caused by incorrect use of list iterator
        drbd: Fix five use after free bugs in get_initial_state
        cdrom: remove unused variable
      f1b45d8c
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.18-2022-04-08' of git://git.kernel.dk/linux-block · 4d6f9f24
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
       "A bit bigger than usual post merge window, largely due to a revert and
        a fix of at what point files are assigned for requests.
      
        The latter fixing a linked request use case where a dependent link can
        rely on what file is assigned consistently.
      
        Summary:
      
         - 32-bit compat fix for IORING_REGISTER_IOWQ_AFF (Eugene)
      
         - File assignment fixes (me)
      
         - Revert of the NAPI poll addition from this merge window. The author
           isn't available right now to engage on this, so let's revert it and
           we can retry for the 5.19 release (me, Jakub)
      
         - Fix a timeout removal race (me)
      
         - File update and SCM fixes (Pavel)"
      
      * tag 'io_uring-5.18-2022-04-08' of git://git.kernel.dk/linux-block:
        io_uring: fix race between timeout flush and removal
        io_uring: use nospec annotation for more indexes
        io_uring: zero tag on rsrc removal
        io_uring: don't touch scm_fp_list after queueing skb
        io_uring: nospec index for tags on files update
        io_uring: implement compat handling for IORING_REGISTER_IOWQ_AFF
        Revert "io_uring: Add support for napi_busy_poll"
        io_uring: drop the old style inflight file tracking
        io_uring: defer file assignment
        io_uring: propagate issue_flags state down to file assignment
        io_uring: move read/write file prep state into actual opcode handler
        io_uring: defer splice/tee file validity check until command issue
        io_uring: don't check req->file in io_fsync_prep()
      4d6f9f24
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · f335af10
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "Several bug fixes for old bugs:
      
         - Welcome Leon as co-maintainer for RDMA so we are back to having two
           people
      
         - Some corner cases are fixed in mlx5's MR code
      
         - Long standing CM bug where a DREQ at the wrong time can result in a
           long timeout
      
         - Missing locking and refcounting in hf1"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/hfi1: Fix use-after-free bug for mm struct
        IB/rdmavt: add lock to call to rvt_error_qp to prevent a race condition
        IB/cm: Cancel mad on the DREQ event when the state is MRA_REP_RCVD
        RDMA/mlx5: Add a missing update of cache->last_add
        RDMA/mlx5: Don't remove cache MRs when a delay is needed
        MAINTAINERS: Update qib and hfi1 related drivers
        MAINTAINERS: Add Leon Romanovsky to RDMA maintainers
      f335af10
    • Linus Torvalds's avatar
      Merge tag 'acpi-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · d017a316
      Linus Torvalds authored
      Pull ACPI updates from Rafael Wysocki:
       "These revert a problematic commit from the 5.17 development cycle and
        finalize the elimination of acpi_bus_get_device() that mostly took
        place during the recent merge window.
      
        Specifics:
      
         - Revert an ACPI processor driver change related to cache
           invalidation in acpi_idle_play_dead() that clearly was a mistake
           and introduced user-visible regressions (Akihiko Odaki).
      
         - Replace the last instance of acpi_bus_get_device() added during the
           recent merge window and drop the function to prevent more users of
           it from being added (Rafael Wysocki)"
      
      * tag 'acpi-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        ACPI: bus: Eliminate acpi_bus_get_device()
        Revert "ACPI: processor: idle: Only flush cache on entering C3"
      d017a316
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-kunit-fixes-5.18-rc2' of... · 6c7376da
      Linus Torvalds authored
      Merge tag 'linux-kselftest-kunit-fixes-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull KUnit fix from Shuah Khan:
       "A single documentation fix to incorrect and outdated usage
        information"
      
      * tag 'linux-kselftest-kunit-fixes-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        Documentation: kunit: fix path to .kunitconfig in start.rst
      6c7376da
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-fixes-5.18-rc2' of... · 9abb16ba
      Linus Torvalds authored
      Merge tag 'linux-kselftest-fixes-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull Kselftest fixes from Shuah Khan:
       "Build and run-times fixes to tests:
      
         - header dependencies
      
         - missing tear-downs to release allocated resources in assert paths
      
         - missing error messages when build fails
      
         - coccicheck and unused variable warnings"
      
      * tag 'linux-kselftest-fixes-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        selftests/harness: Pass variant to teardown
        selftests/harness: Run TEARDOWN for ASSERT failures
        selftests: fix an unused variable warning in pidfd selftest
        selftests: fix header dependency for pid_namespace selftests
        selftests: x86: add 32bit build warnings for SUSE
        selftests/proc: fix array_size.cocci warning
        selftests/vDSO: fix array_size.cocci warning
      9abb16ba
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · 911b2b95
      Linus Torvalds authored
      Merge fixes from Andrew Morton:
       "9 patches.
      
        Subsystems affected by this patch series: mm (migration, highmem,
        sparsemem, mremap, mempolicy, and memcg), lz4, mailmap, and
        MAINTAINERS"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        MAINTAINERS: add Tom as clang reviewer
        mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()"
        mailmap: update Vasily Averin's email address
        mm/mempolicy: fix mpol_new leak in shared_policy_replace
        mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
        mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
        lz4: fix LZ4_decompress_safe_partial read out of bound
        highmem: fix checks in __kmap_local_sched_{in,out}
        mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.
      911b2b95
    • Tom Rix's avatar
      MAINTAINERS: add Tom as clang reviewer · 4071a1b9
      Tom Rix authored
      I have been helping with build breaks and other clang things and would
      like to help with the reviews.
      
      Link: https://lkml.kernel.org/r/20220407175715.3378998-1-trix@redhat.comSigned-off-by: default avatarTom Rix <trix@redhat.com>
      Acked-by: default avatarNathan Chancellor <nathan@kernel.org>
      Acked-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4071a1b9
    • Andrew Morton's avatar
      mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()" · b33e1044
      Andrew Morton authored
      Commit 405cc51f ("mm/list_lru: optimize memcg_reparent_list_lru_node()")
      has subtle races which are proving ugly to fix.  Revert the original
      optimization.  If quantitative testing indicates that we have a
      significant problem here then other implementations can be looked at.
      
      Fixes: 405cc51f ("mm/list_lru: optimize memcg_reparent_list_lru_node()")
      Acked-by: default avatarShakeel Butt <shakeelb@google.com>
      Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b33e1044
    • Vasily Averin's avatar
      0347b2b9
    • Miaohe Lin's avatar
      mm/mempolicy: fix mpol_new leak in shared_policy_replace · 4ad09955
      Miaohe Lin authored
      If mpol_new is allocated but not used in restart loop, mpol_new will be
      freed via mpol_put before returning to the caller.  But refcnt is not
      initialized yet, so mpol_put could not do the right things and might
      leak the unused mpol_new.  This would happen if mempolicy was updated on
      the shared shmem file while the sp->lock has been dropped during the
      memory allocation.
      
      This issue could be triggered easily with the below code snippet if
      there are many processes doing the below work at the same time:
      
        shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT);
        shm = shmat(shmid, 0, 0);
        loop many times {
          mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0);
          mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask,
                maxnode, 0);
        }
      
      Link: https://lkml.kernel.org/r/20220329111416.27954-1-linmiaohe@huawei.com
      Fixes: 42288fe3 ("mm: mempolicy: Convert shared_policy mutex to spinlock")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: <stable@vger.kernel.org>	[3.8]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4ad09955
    • Paolo Bonzini's avatar
      mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) · 01e67e04
      Paolo Bonzini authored
      If an mremap() syscall with old_size=0 ends up in move_page_tables(), it
      will call invalidate_range_start()/invalidate_range_end() unnecessarily,
      i.e.  with an empty range.
      
      This causes a WARN in KVM's mmu_notifier.  In the past, empty ranges
      have been diagnosed to be off-by-one bugs, hence the WARNing.  Given the
      low (so far) number of unique reports, the benefits of detecting more
      buggy callers seem to outweigh the cost of having to fix cases such as
      this one, where userspace is doing something silly.  In this particular
      case, an early return from move_page_tables() is enough to fix the
      issue.
      
      Link: https://lkml.kernel.org/r/20220329173155.172439-1-pbonzini@redhat.com
      Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      01e67e04
    • Waiman Long's avatar
      mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning · a431dbbc
      Waiman Long authored
      The gcc 12 compiler reports a "'mem_section' will never be NULL" warning
      on the following code:
      
          static inline struct mem_section *__nr_to_section(unsigned long nr)
          {
          #ifdef CONFIG_SPARSEMEM_EXTREME
              if (!mem_section)
                      return NULL;
          #endif
              if (!mem_section[SECTION_NR_TO_ROOT(nr)])
                      return NULL;
             :
      
      It happens with CONFIG_SPARSEMEM_EXTREME off.  The mem_section definition
      is
      
          #ifdef CONFIG_SPARSEMEM_EXTREME
          extern struct mem_section **mem_section;
          #else
          extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
          #endif
      
      In the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static
      2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]"
      doesn't make sense.
      
      Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]"
      check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an
      explicit NR_SECTION_ROOTS check to make sure that there is no
      out-of-bound array access.
      
      Link: https://lkml.kernel.org/r/20220331180246.2746210-1-longman@redhat.com
      Fixes: 3e347261 ("sparsemem extreme implementation")
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Reported-by: default avatarJustin Forbes <jforbes@redhat.com>
      Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Rafael Aquini <aquini@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a431dbbc
    • Guo Xuenan's avatar
      lz4: fix LZ4_decompress_safe_partial read out of bound · eafc0a02
      Guo Xuenan authored
      When partialDecoding, it is EOF if we've either filled the output buffer
      or can't proceed with reading an offset for following match.
      
      In some extreme corner cases when compressed data is suitably corrupted,
      UAF will occur.  As reported by KASAN [1], LZ4_decompress_safe_partial
      may lead to read out of bound problem during decoding.  lz4 upstream has
      fixed it [2] and this issue has been disscussed here [3] before.
      
      current decompression routine was ported from lz4 v1.8.3, bumping
      lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd
      better fix it first.
      
      [1] https://lore.kernel.org/all/000000000000830d1205cf7f0477@google.com/
      [2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad244ad#
      [3] https://lore.kernel.org/all/CC666AE8-4CA4-4951-B6FB-A2EFDE3AC03B@fb.com/
      
      Link: https://lkml.kernel.org/r/20211111105048.2006070-1-guoxuenan@huawei.com
      Reported-by: syzbot+63d688f1d899c588fb71@syzkaller.appspotmail.com
      Signed-off-by: default avatarGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: default avatarNick Terrell <terrelln@fb.com>
      Acked-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
      Cc: Yann Collet <cyan@fb.com>
      Cc: Chengyang Fan <cy.fan@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      eafc0a02
    • Max Filippov's avatar
      highmem: fix checks in __kmap_local_sched_{in,out} · 66f133ce
      Max Filippov authored
      When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check
      that even slots in the tsk->kmap_ctrl.pteval are unmapped.  The slots are
      initialized with 0 value, but the check is done with pte_none.  0 pte
      however does not necessarily mean that pte_none will return true.  e.g.
      on xtensa it returns false, resulting in the following runtime warnings:
      
       WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0x108
       CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13
       Call Trace:
         dump_stack+0xc/0x40
         __warn+0x8f/0x174
         warn_slowpath_fmt+0x48/0xac
         __kmap_local_sched_out+0x51/0x108
         __schedule+0x71a/0x9c4
         preempt_schedule_irq+0xa0/0xe0
         common_exception_return+0x5c/0x93
         do_wp_page+0x30e/0x330
         handle_mm_fault+0xa70/0xc3c
         do_page_fault+0x1d8/0x3c4
         common_exception+0x7f/0x7f
      
       WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0xe0
       CPU: 0 PID: 101 Comm: touch Tainted: G        W         5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13
       Call Trace:
         dump_stack+0xc/0x40
         __warn+0x8f/0x174
         warn_slowpath_fmt+0x48/0xac
         __kmap_local_sched_in+0x50/0xe0
         finish_task_switch$isra$0+0x1ce/0x2f8
         __schedule+0x86e/0x9c4
         preempt_schedule_irq+0xa0/0xe0
         common_exception_return+0x5c/0x93
         do_wp_page+0x30e/0x330
         handle_mm_fault+0xa70/0xc3c
         do_page_fault+0x1d8/0x3c4
         common_exception+0x7f/0x7f
      
      Fix it by replacing !pte_none(pteval) with pte_val(pteval) != 0.
      
      Link: https://lkml.kernel.org/r/20220403235159.3498065-1-jcmvbkbc@gmail.com
      Fixes: 5fbda3ec ("sched: highmem: Store local kmaps in task struct")
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      66f133ce
    • Zi Yan's avatar
      mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation. · a04cd160
      Zi Yan authored
      Fix a VM_BUG_ON_FOLIO(folio_nr_pages(old) != nr_pages) crash.
      
      With folios support, it is possible to have other than HPAGE_PMD_ORDER
      THPs, in the form of folios, in the system.  Use thp_order() to correctly
      determine the source page order during migration.
      
      Link: https://lkml.kernel.org/r/20220404165325.1883267-1-zi.yan@sent.com
      Link: https://lore.kernel.org/linux-mm/20220404132908.GA785673@u2004/
      Fixes: d68eccad ("mm/filemap: Allow large folios to be added to the page cache")
      Reported-by: default avatarNaoya Horiguchi <naoya.horiguchi@linux.dev>
      Signed-off-by: default avatarZi Yan <ziy@nvidia.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Hocko <mhocko@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a04cd160
  2. 08 Apr, 2022 16 commits