1. 29 Dec, 2023 3 commits
  2. 20 Dec, 2023 11 commits
  3. 13 Dec, 2023 17 commits
    • Yu Zhao's avatar
      mm/mglru: reclaim offlined memcgs harder · 4376807b
      Yu Zhao authored
      In the effort to reduce zombie memcgs [1], it was discovered that the
      memcg LRU doesn't apply enough pressure on offlined memcgs.  Specifically,
      instead of rotating them to the tail of the current generation
      (MEMCG_LRU_TAIL) for a second attempt, it moves them to the next
      generation (MEMCG_LRU_YOUNG) after the first attempt.
      
      Not applying enough pressure on offlined memcgs can cause them to build
      up, and this can be particularly harmful to memory-constrained systems.
      
      On Pixel 8 Pro, launching apps for 50 cycles:
                       Before  After  Change
        Zombie memcgs  45      35     -22%
      
      [1] https://lore.kernel.org/CABdmKX2M6koq4Q0Cmp_-=wbP0Qa190HdEGGaHfxNS05gAkUtPA@mail.gmail.com/
      
      Link: https://lkml.kernel.org/r/20231208061407.2125867-4-yuzhao@google.com
      Fixes: e4dde56c ("mm: multi-gen LRU: per-node lru_gen_folio lists")
      Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
      Reported-by: default avatarT.J. Mercier <tjmercier@google.com>
      Tested-by: default avatarT.J. Mercier <tjmercier@google.com>
      Cc: Charan Teja Kalla <quic_charante@quicinc.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
      Cc: Kairui Song <ryncsn@gmail.com>
      Cc: Kalesh Singh <kaleshsingh@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4376807b
    • Yu Zhao's avatar
      mm/mglru: respect min_ttl_ms with memcgs · 8aa42061
      Yu Zhao authored
      While investigating kswapd "consuming 100% CPU" [1] (also see "mm/mglru:
      try to stop at high watermarks"), it was discovered that the memcg LRU can
      breach the thrashing protection imposed by min_ttl_ms.
      
      Before the memcg LRU:
        kswapd()
          shrink_node_memcgs()
            mem_cgroup_iter()
              inc_max_seq()  // always hit a different memcg
          lru_gen_age_node()
            mem_cgroup_iter()
              check the timestamp of the oldest generation
      
      After the memcg LRU:
        kswapd()
          shrink_many()
            restart:
              iterate the memcg LRU:
                inc_max_seq()  // occasionally hit the same memcg
                if raced with lru_gen_rotate_memcg():
                  goto restart
          lru_gen_age_node()
            mem_cgroup_iter()
              check the timestamp of the oldest generation
      
      Specifically, when the restart happens in shrink_many(), it needs to stick
      with the (memcg LRU) generation it began with.  In other words, it should
      neither re-read memcg_lru->seq nor age an lruvec of a different
      generation.  Otherwise it can hit the same memcg multiple times without
      giving lru_gen_age_node() a chance to check the timestamp of that memcg's
      oldest generation (against min_ttl_ms).
      
      [1] https://lore.kernel.org/CAK8fFZ4DY+GtBA40Pm7Nn5xCHy+51w3sfxPqkqpqakSXYyX+Wg@mail.gmail.com/
      
      Link: https://lkml.kernel.org/r/20231208061407.2125867-3-yuzhao@google.com
      Fixes: e4dde56c ("mm: multi-gen LRU: per-node lru_gen_folio lists")
      Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
      Tested-by: default avatarT.J. Mercier <tjmercier@google.com>
      Cc: Charan Teja Kalla <quic_charante@quicinc.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
      Cc: Kairui Song <ryncsn@gmail.com>
      Cc: Kalesh Singh <kaleshsingh@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8aa42061
    • Yu Zhao's avatar
      mm/mglru: try to stop at high watermarks · 5095a2b2
      Yu Zhao authored
      The initial MGLRU patchset didn't include the memcg LRU support, and it
      relied on should_abort_scan(), added by commit f76c8337 ("mm:
      multi-gen LRU: optimize multiple memcgs"), to "backoff to avoid
      overshooting their aggregate reclaim target by too much".
      
      Later on when the memcg LRU was added, should_abort_scan() was deemed
      unnecessary, and the test results [1] showed no side effects after it was
      removed by commit a579086c ("mm: multi-gen LRU: remove eviction
      fairness safeguard").
      
      However, that test used memory.reclaim, which sets nr_to_reclaim to
      SWAP_CLUSTER_MAX.  So it can overshoot only by SWAP_CLUSTER_MAX-1 pages,
      i.e., from nr_reclaimed=nr_to_reclaim-1 to
      nr_reclaimed=nr_to_reclaim+SWAP_CLUSTER_MAX-1.  Compared with the batch
      size kswapd sets to nr_to_reclaim, SWAP_CLUSTER_MAX is tiny.  Therefore
      that test isn't able to reproduce the worst case scenario, i.e., kswapd
      overshooting GBs on large systems and "consuming 100% CPU" (see the Closes
      tag).
      
      Bring back a simplified version of should_abort_scan() on top of the memcg
      LRU, so that kswapd stops when all eligible zones are above their
      respective high watermarks plus a small delta to lower the chance of
      KSWAPD_HIGH_WMARK_HIT_QUICKLY.  Note that this only applies to order-0
      reclaim, meaning compaction-induced reclaim can still run wild (which is a
      different problem).
      
      On Android, launching 55 apps sequentially:
                 Before     After      Change
        pgpgin   838377172  802955040  -4%
        pgpgout  38037080   34336300   -10%
      
      [1] https://lore.kernel.org/20221222041905.2431096-1-yuzhao@google.com/
      
      Link: https://lkml.kernel.org/r/20231208061407.2125867-2-yuzhao@google.com
      Fixes: a579086c ("mm: multi-gen LRU: remove eviction fairness safeguard")
      Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
      Reported-by: default avatarCharan Teja Kalla <quic_charante@quicinc.com>
      Reported-by: default avatarJaroslav Pulchart <jaroslav.pulchart@gooddata.com>
      Closes: https://lore.kernel.org/CAK8fFZ4DY+GtBA40Pm7Nn5xCHy+51w3sfxPqkqpqakSXYyX+Wg@mail.gmail.com/Tested-by: default avatarJaroslav Pulchart <jaroslav.pulchart@gooddata.com>
      Tested-by: default avatarKalesh Singh <kaleshsingh@google.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Kairui Song <ryncsn@gmail.com>
      Cc: T.J. Mercier <tjmercier@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5095a2b2
    • Yu Zhao's avatar
      mm/mglru: fix underprotected page cache · 08148805
      Yu Zhao authored
      Unmapped folios accessed through file descriptors can be underprotected. 
      Those folios are added to the oldest generation based on:
      
      1. The fact that they are less costly to reclaim (no need to walk the
         rmap and flush the TLB) and have less impact on performance (don't
         cause major PFs and can be non-blocking if needed again).
      2. The observation that they are likely to be single-use. E.g., for
         client use cases like Android, its apps parse configuration files
         and store the data in heap (anon); for server use cases like MySQL,
         it reads from InnoDB files and holds the cached data for tables in
         buffer pools (anon).
      
      However, the oldest generation can be very short lived, and if so, it
      doesn't provide the PID controller with enough time to respond to a surge
      of refaults.  (Note that the PID controller uses weighted refaults and
      those from evicted generations only take a half of the whole weight.) In
      other words, for a short lived generation, the moving average smooths out
      the spike quickly.
      
      To fix the problem:
      1. For folios that are already on LRU, if they can be beyond the
         tracking range of tiers, i.e., five accesses through file
         descriptors, move them to the second oldest generation to give them
         more time to age. (Note that tiers are used by the PID controller
         to statistically determine whether folios accessed multiple times
         through file descriptors are worth protecting.)
      2. When adding unmapped folios to LRU, adjust the placement of them so
         that they are not too close to the tail. The effect of this is
         similar to the above.
      
      On Android, launching 55 apps sequentially:
                                 Before     After      Change
        workingset_refault_anon  25641024   25598972   0%
        workingset_refault_file  115016834  106178438  -8%
      
      Link: https://lkml.kernel.org/r/20231208061407.2125867-1-yuzhao@google.com
      Fixes: ac35a490 ("mm: multi-gen LRU: minimal implementation")
      Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
      Reported-by: default avatarCharan Teja Kalla <quic_charante@quicinc.com>
      Tested-by: default avatarKalesh Singh <kaleshsingh@google.com>
      Cc: T.J. Mercier <tjmercier@google.com>
      Cc: Kairui Song <ryncsn@gmail.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      08148805
    • David Stevens's avatar
      mm/shmem: fix race in shmem_undo_range w/THP · 55ac8bbe
      David Stevens authored
      Split folios during the second loop of shmem_undo_range.  It's not
      sufficient to only split folios when dealing with partial pages, since
      it's possible for a THP to be faulted in after that point.  Calling
      truncate_inode_folio in that situation can result in throwing away data
      outside of the range being targeted.
      
      [akpm@linux-foundation.org: tidy up comment layout]
      Link: https://lkml.kernel.org/r/20230418084031.3439795-1-stevensd@google.com
      Fixes: b9a8a419 ("truncate,shmem: Handle truncates that split large folios")
      Signed-off-by: default avatarDavid Stevens <stevensd@chromium.org>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Suleiman Souhlal <suleiman@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      55ac8bbe
    • John Hubbard's avatar
      Revert "selftests: error out if kernel header files are not yet built" · 43e8832f
      John Hubbard authored
      This reverts commit 9fc96c7c ("selftests: error out if kernel header
      files are not yet built").
      
      It turns out that requiring the kernel headers to be built as a
      prerequisite to building selftests, does not work in many cases. For
      example, Peter Zijlstra writes:
      
      "My biggest beef with the whole thing is that I simply do not want to use
      'make headers', it doesn't work for me.
      
      I have a ton of output directories and I don't care to build tools into
      the output dirs, in fact some of them flat out refuse to work that way
      (bpf comes to mind)." [1]
      
      Therefore, stop erroring out on the selftests build. Additional patches
      will be required in order to change over to not requiring the kernel
      headers.
      
      [1] https://lore.kernel.org/20231208221007.GO28727@noisy.programming.kicks-ass.net
      
      Link: https://lkml.kernel.org/r/20231209020144.244759-1-jhubbard@nvidia.com
      Fixes: 9fc96c7c ("selftests: error out if kernel header files are not yet built")
      Signed-off-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
      Cc: Anders Roxell <anders.roxell@linaro.org>
      Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Marcos Paulo de Souza <mpdesouza@suse.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      43e8832f
    • Yuntao Wang's avatar
      crash_core: fix the check for whether crashkernel is from high memory · 1dd11e97
      Yuntao Wang authored
      If crash_base is equal to CRASH_ADDR_LOW_MAX, it also indicates that
      the crashkernel memory is allocated from high memory. However, the
      current check only considers the case where crash_base is greater than
      CRASH_ADDR_LOW_MAX. Fix it.
      
      The runtime effects is that crashkernel high memory is successfully
      reserved, whereas the crashkernel low memory is bypassed in this case,
      then kdump kernel bootup will fail because of no low memory under 4G.
      
      This patch also includes some minor cleanups.
      
      Link: https://lkml.kernel.org/r/20231209141438.77233-1-ytcoode@gmail.com
      Fixes: 0ab97169 ("crash_core: add generic function to do reservation")
      Signed-off-by: default avatarYuntao Wang <ytcoode@gmail.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1dd11e97
    • Baoquan He's avatar
      x86, kexec: fix the wrong ifdeffery CONFIG_KEXEC · 69f8ca8d
      Baoquan He authored
      With the current ifdeffery CONFIG_KEXEC, get_cmdline_acpi_rsdp() is only
      available when kexec_load interface is taken, while kexec_file_load
      interface can't make use of it.
      
      Now change it to CONFIG_KEXEC_CORE.
      
      Link: https://lkml.kernel.org/r/20231208073036.7884-6-bhe@redhat.comSigned-off-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Eric DeVolder <eric_devolder@yahoo.com>
      Cc: Ignat Korchagin <ignat@cloudflare.com>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      69f8ca8d
    • Baoquan He's avatar
      sh, kexec: fix the incorrect ifdeffery and dependency of CONFIG_KEXEC · d70c27b7
      Baoquan He authored
      The select of KEXEC for CRASH_DUMP in kernel/Kconfig.kexec will be
      dropped, then compiling errors will be triggered if below config
      items are set:
      
      ===
      CONFIG_CRASH_CORE=y
      CONFIG_KEXEC_CORE=y
      CONFIG_CRASH_DUMP=y
      ===
      
      Here, change the dependency of building kexec_core related object files,
      and the ifdeffery on SuperH from CONFIG_KEXEC to CONFIG_KEXEC_CORE.
      
      Link: https://lkml.kernel.org/r/20231208073036.7884-5-bhe@redhat.comSigned-off-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Eric DeVolder <eric_devolder@yahoo.com>
      Cc: Ignat Korchagin <ignat@cloudflare.com>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d70c27b7
    • Baoquan He's avatar
      mips, kexec: fix the incorrect ifdeffery and dependency of CONFIG_KEXEC · 8cd2accb
      Baoquan He authored
      The select of KEXEC for CRASH_DUMP in kernel/Kconfig.kexec will be
      dropped, then compiling errors will be triggered if below config items are
      set:
      
      ===
      CONFIG_CRASH_CORE=y
      CONFIG_KEXEC_CORE=y
      CONFIG_CRASH_DUMP=y
      ===
      
      --------------------------------------------------------------------
      mipsel-linux-ld: kernel/kexec_core.o: in function `kimage_free':
      kernel/kexec_core.c:(.text+0x2200): undefined reference to `machine_kexec_cleanup'
      mipsel-linux-ld: kernel/kexec_core.o: in function `__crash_kexec':
      kernel/kexec_core.c:(.text+0x2480): undefined reference to `machine_crash_shutdown'
      mipsel-linux-ld: kernel/kexec_core.c:(.text+0x2488): undefined reference to `machine_kexec'
      mipsel-linux-ld: kernel/kexec_core.o: in function `kernel_kexec':
      kernel/kexec_core.c:(.text+0x29b8): undefined reference to `machine_shutdown'
      mipsel-linux-ld: kernel/kexec_core.c:(.text+0x29c0): undefined reference to `machine_kexec'
      --------------------------------------------------------------------
      
      Here, change the dependency of building kexec_core related object files,
      and the ifdeffery in mips from CONFIG_KEXEC to CONFIG_KEXEC_CORE.
      
      Link: https://lkml.kernel.org/r/20231208073036.7884-4-bhe@redhat.comSigned-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202311302042.sn8cDPIX-lkp@intel.com/
      Cc: Eric DeVolder <eric_devolder@yahoo.com>
      Cc: Ignat Korchagin <ignat@cloudflare.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8cd2accb
    • Baoquan He's avatar
      m68k, kexec: fix the incorrect ifdeffery and build dependency of CONFIG_KEXEC · 9bad6b75
      Baoquan He authored
      The select of KEXEC for CRASH_DUMP in kernel/Kconfig.kexec will be
      dropped, then compiling errors will be triggered if below config items are
      set:
      
      ===
      CONFIG_CRASH_CORE=y
      CONFIG_KEXEC_CORE=y
      CONFIG_CRASH_DUMP=y
      ===
      
      Here, change the dependency of buinding machine_kexec.o relocate_kernel.o
      and the ifdeffery in asm/kexe.h to CONFIG_KEXEC_CORE.
      
      Link: https://lkml.kernel.org/r/20231208073036.7884-3-bhe@redhat.comSigned-off-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Eric DeVolder <eric_devolder@yahoo.com>
      Cc: Ignat Korchagin <ignat@cloudflare.com>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9bad6b75
    • Baoquan He's avatar
      loongarch, kexec: change dependency of object files · 655fc6cd
      Baoquan He authored
      Patch series "kexec: fix the incorrect ifdeffery and dependency of
      CONFIG_KEXEC".
      
      The select of KEXEC for CRASH_DUMP in kernel/Kconfig.kexec will be
      dropped, then compiling errors will be triggered if below config items are
      set:
      
      ===
      CONFIG_CRASH_CORE=y
      CONFIG_KEXEC_CORE=y
      CONFIG_CRASH_DUMP=y
      ===
      
      E.g on mips, below link error are seen:
      --------------------------------------------------------------------
      mipsel-linux-ld: kernel/kexec_core.o: in function `kimage_free':
      kernel/kexec_core.c:(.text+0x2200): undefined reference to `machine_kexec_cleanup'
      mipsel-linux-ld: kernel/kexec_core.o: in function `__crash_kexec':
      kernel/kexec_core.c:(.text+0x2480): undefined reference to `machine_crash_shutdown'
      mipsel-linux-ld: kernel/kexec_core.c:(.text+0x2488): undefined reference to `machine_kexec'
      mipsel-linux-ld: kernel/kexec_core.o: in function `kernel_kexec':
      kernel/kexec_core.c:(.text+0x29b8): undefined reference to `machine_shutdown'
      mipsel-linux-ld: kernel/kexec_core.c:(.text+0x29c0): undefined reference to `machine_kexec'
      --------------------------------------------------------------------
      
      Here, change the incorrect dependency of building kexec_core related
      object files, and the ifdeffery on architectures from CONFIG_KEXEC to
      CONFIG_KEXEC_CORE.
      
      Testing:
      ========
      Passed on mips and loognarch with the LKP reproducer.
      
      
      This patch (of 5):
      
      Currently, in arch/loongarch/kernel/Makefile, building machine_kexec.o
      relocate_kernel.o depends on CONFIG_KEXEC.
      
      Whereas, since we will drop the select of KEXEC for CRASH_DUMP in
      kernel/Kconfig.kexec, compiling error will be triggered if below config
      items are set:
      
      ===
      CONFIG_CRASH_CORE=y
      CONFIG_KEXEC_CORE=y
      CONFIG_CRASH_DUMP=y
      ===
      
      ---------------------------------------------------------------
      loongarch64-linux-ld: kernel/kexec_core.o: in function `.L209':
      >> kexec_core.c:(.text+0x1660): undefined reference to `machine_kexec_cleanup'
         loongarch64-linux-ld: kernel/kexec_core.o: in function `.L287':
      >> kexec_core.c:(.text+0x1c5c): undefined reference to `machine_crash_shutdown'
      >> loongarch64-linux-ld: kexec_core.c:(.text+0x1c64): undefined reference to `machine_kexec'
         loongarch64-linux-ld: kernel/kexec_core.o: in function `.L2^B5':
      >> kexec_core.c:(.text+0x2090): undefined reference to `machine_shutdown'
         loongarch64-linux-ld: kexec_core.c:(.text+0x20a0): undefined reference to `machine_kexec'
      ---------------------------------------------------------------
      
      Here, change the dependency of machine_kexec.o relocate_kernel.o to
      CONFIG_KEXEC_CORE can fix above building error.
      
      Link: https://lkml.kernel.org/r/20231208073036.7884-1-bhe@redhat.com
      Link: https://lkml.kernel.org/r/20231208073036.7884-2-bhe@redhat.comSigned-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202311300946.kHE9Iu71-lkp@intel.com/
      Cc: Eric DeVolder <eric_devolder@yahoo.com>
      Cc: Ignat Korchagin <ignat@cloudflare.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      655fc6cd
    • SeongJae Park's avatar
      mm/damon/core: make damon_start() waits until kdamond_fn() starts · 6376a824
      SeongJae Park authored
      The cleanup tasks of kdamond threads including reset of corresponding
      DAMON context's ->kdamond field and decrease of global nr_running_ctxs
      counter is supposed to be executed by kdamond_fn().  However, commit
      0f91d133 ("mm/damon: simplify stop mechanism") made neither
      damon_start() nor damon_stop() ensure the corresponding kdamond has
      started the execution of kdamond_fn().
      
      As a result, the cleanup can be skipped if damon_stop() is called fast
      enough after the previous damon_start().  Especially the skipped reset
      of ->kdamond could cause a use-after-free.
      
      Fix it by waiting for start of kdamond_fn() execution from
      damon_start().
      
      Link: https://lkml.kernel.org/r/20231208175018.63880-1-sj@kernel.org
      Fixes: 0f91d133 ("mm/damon: simplify stop mechanism")
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Reported-by: default avatarJakub Acs <acsjakub@amazon.de>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Jakub Acs <acsjakub@amazon.de>
      Cc: <stable@vger.kernel.org> # 5.15.x
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6376a824
    • David Hildenbrand's avatar
      selftests/mm: cow: print ksft header before printing anything else · a6fcd57c
      David Hildenbrand authored
      Doing a ksft_print_msg() before the ksft_print_header() seems to confuse
      the ksft framework in a strange way: running the test on the cmdline
      results in the expected output.
      
      But piping the output somewhere else, results in some odd output,
      whereby we repeatedly get the same info printed:
      	# [INFO] detected THP size: 2048 KiB
      	# [INFO] detected hugetlb page size: 2048 KiB
      	# [INFO] detected hugetlb page size: 1048576 KiB
      	# [INFO] huge zeropage is enabled
      	TAP version 13
      	1..190
      	# [INFO] Anonymous memory tests in private mappings
      	# [RUN] Basic COW after fork() ... with base page
      	# [INFO] detected THP size: 2048 KiB
      	# [INFO] detected hugetlb page size: 2048 KiB
      	# [INFO] detected hugetlb page size: 1048576 KiB
      	# [INFO] huge zeropage is enabled
      	TAP version 13
      	1..190
      	# [INFO] Anonymous memory tests in private mappings
      	# [RUN] Basic COW after fork() ... with base page
      	ok 1 No leak from parent into child
      	# [RUN] Basic COW after fork() ... with swapped out base page
      	# [INFO] detected THP size: 2048 KiB
      	# [INFO] detected hugetlb page size: 2048 KiB
      	# [INFO] detected hugetlb page size: 1048576 KiB
      	# [INFO] huge zeropage is enabled
      
      Doing the ksft_print_header() first seems to resolve that and gives us
      the output we expect:
      	TAP version 13
      	# [INFO] detected THP size: 2048 KiB
      	# [INFO] detected hugetlb page size: 2048 KiB
      	# [INFO] detected hugetlb page size: 1048576 KiB
      	# [INFO] huge zeropage is enabled
      	1..190
      	# [INFO] Anonymous memory tests in private mappings
      	# [RUN] Basic COW after fork() ... with base page
      	ok 1 No leak from parent into child
      	# [RUN] Basic COW after fork() ... with swapped out base page
      	ok 2 No leak from parent into child
      	# [RUN] Basic COW after fork() ... with THP
      	ok 3 No leak from parent into child
      	# [RUN] Basic COW after fork() ... with swapped-out THP
      	ok 4 No leak from parent into child
      	# [RUN] Basic COW after fork() ... with PTE-mapped THP
      	ok 5 No leak from parent into child
      
      Link: https://lkml.kernel.org/r/20231206103558.38040-1-david@redhat.com
      Fixes: f4b5fd69 ("selftests/vm: anon_cow: THP tests")
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reported-by: default avatarNico Pache <npache@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a6fcd57c
    • Kefeng Wang's avatar
      mm: fix VMA heap bounds checking · d3bb89ea
      Kefeng Wang authored
      After converting selinux to VMA heap check helper, the gcl triggers an
      execheap SELinux denial, which is caused by a changed logic check.
      
      Previously selinux only checked that the VMA range was within the VMA heap
      range, and the implementation checks the intersection between the two
      ranges, but the corner case (vm_end=start_brk, brk=vm_start) isn't handled
      correctly.
      
      Since commit 11250fd1 ("mm: factor out VMA stack and heap checks") was
      only a function extraction, it seems that the issue was introduced by
      commit 0db0c01b ("procfs: fix /proc/<pid>/maps heap check").  Let's
      fix above corner cases, meanwhile, correct the wrong indentation of the
      stack and heap check helpers.
      
      Fixes: 11250fd1 ("mm: factor out VMA stack and heap checks")
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reported-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Closes: https://lore.kernel.org/selinux/CAFqZXNv0SVT0fkOK6neP9AXbj3nxJ61JAY4+zJzvxqJaeuhbFw@mail.gmail.com/Tested-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Link: https://lkml.kernel.org/r/20231207152525.2607420-1-wangkefeng.wang@huawei.com
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d3bb89ea
    • Baoquan He's avatar
      riscv: fix VMALLOC_START definition · ac88ff6b
      Baoquan He authored
      When below config items are set, compiler complained:
      
      --------------------
      CONFIG_CRASH_CORE=y
      CONFIG_KEXEC_CORE=y
      CONFIG_CRASH_DUMP=y
      ......
      -----------------------
      
      -------------------------------------------------------------------
      arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
      arch/riscv/kernel/crash_core.c:11:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]
      11 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
         |                                                        ~~^
         |                                                          |
         |                                                          long unsigned int
         |                                                        %x
      ----------------------------------------------------------------------
      
      This is because on riscv macro VMALLOC_START has different type when
      CONFIG_MMU is set or unset.
      
      arch/riscv/include/asm/pgtable.h:
      --------------------------------------------------
      
      Changing it to _AC(0, UL) in case CONFIG_MMU=n can fix the warning.
      
      Link: https://lkml.kernel.org/r/ZW7OsX4zQRA3mO4+@MiWiFi-R3L-srvSigned-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Tested-by: Randy Dunlap <rdunlap@infradead.org>	# build-tested
      Cc: Eric DeVolder <eric_devolder@yahoo.com>
      Cc: Ignat Korchagin <ignat@cloudflare.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      ac88ff6b
    • Ignat Korchagin's avatar
      kexec: drop dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP · c41bd251
      Ignat Korchagin authored
      In commit f8ff23429c62 ("kernel/Kconfig.kexec: drop select of KEXEC for
      CRASH_DUMP") we tried to fix a config regression, where CONFIG_CRASH_DUMP
      required CONFIG_KEXEC.
      
      However, it was not enough at least for arm64 platforms.  While further
      testing the patch with our arm64 config I noticed that CONFIG_CRASH_DUMP
      is unavailable in menuconfig.  This is because CONFIG_CRASH_DUMP still
      depends on the new CONFIG_ARCH_SUPPORTS_KEXEC introduced in commit
      91506f7e ("arm64/kexec: refactor for kernel/Kconfig.kexec") and on
      arm64 CONFIG_ARCH_SUPPORTS_KEXEC requires CONFIG_PM_SLEEP_SMP=y, which in
      turn requires either CONFIG_SUSPEND=y or CONFIG_HIBERNATION=y neither of
      which are set in our config.
      
      Given that we already established that CONFIG_KEXEC (which is a switch for
      kexec system call itself) is not required for CONFIG_CRASH_DUMP drop
      CONFIG_ARCH_SUPPORTS_KEXEC dependency as well.  The arm64 kernel builds
      just fine with CONFIG_CRASH_DUMP=y and with both CONFIG_KEXEC=n and
      CONFIG_KEXEC_FILE=n after f8ff23429c62 ("kernel/Kconfig.kexec: drop select
      of KEXEC for CRASH_DUMP") and this patch are applied given that the
      necessary shared bits are included via CONFIG_KEXEC_CORE dependency.
      
      [bhe@redhat.com: don't export some symbols when CONFIG_MMU=n]
        Link: https://lkml.kernel.org/r/ZW03ODUKGGhP1ZGU@MiWiFi-R3L-srv
      [bhe@redhat.com: riscv, kexec: fix dependency of two items]
        Link: https://lkml.kernel.org/r/ZW04G/SKnhbE5mnX@MiWiFi-R3L-srv
      Link: https://lkml.kernel.org/r/20231129220409.55006-1-ignat@cloudflare.com
      Fixes: 91506f7e ("arm64/kexec: refactor for kernel/Kconfig.kexec")
      Signed-off-by: default avatarIgnat Korchagin <ignat@cloudflare.com>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: <stable@vger.kernel.org> # 6.6+: f8ff234: kernel/Kconfig.kexec: drop select of KEXEC for CRASH_DUMP
      Cc: <stable@vger.kernel.org> # 6.6+
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      c41bd251
  4. 07 Dec, 2023 9 commits
    • Andrew Morton's avatar
      0c92218f
    • Jiexun Wang's avatar
      mm/madvise: add cond_resched() in madvise_cold_or_pageout_pte_range() · b2f557a2
      Jiexun Wang authored
      I conducted real-time testing and observed that
      madvise_cold_or_pageout_pte_range() causes significant latency under
      memory pressure, which can be effectively reduced by adding cond_resched()
      within the loop.
      
      I tested on the LicheePi 4A board using Cylictest for latency testing and
      Ftrace for latency tracing.  The board uses TH1520 processor and has a
      memory size of 8GB.  The kernel version is 6.5.0 with the PREEMPT_RT patch
      applied.
      
      The script I tested is as follows:
      
      echo wakeup_rt > /sys/kernel/tracing/current_tracer
      echo 1 > /sys/kernel/tracing/tracing_on
      echo 0 > /sys/kernel/tracing/tracing_max_latency
      stress-ng --vm 8 --vm-bytes 2G &
      cyclictest --mlockall --smp --priority=99 --distance=0 --duration=30m
      echo 0 > /sys/kernel/tracing/tracing_on
      cat /sys/kernel/tracing/trace 
      
      The tracing results before modification are as follows:
      
      # tracer: wakeup_rt
      #
      # wakeup_rt latency trace v1.1.5 on 6.5.0-rt6-r1208-00003-g999d221864bf
      # --------------------------------------------------------------------
      # latency: 2552 us, #6/6, CPU#3 | (M:preempt_rt VP:0, KP:0, SP:0 HP:0 #P:4)
      #    -----------------
      #    | task: cyclictest-196 (uid:0 nice:0 policy:1 rt_prio:99)
      #    -----------------
      #
      #                    _--------=> CPU#
      #                   / _-------=> irqs-off/BH-disabled
      #                  | / _------=> need-resched
      #                  || / _-----=> need-resched-lazy
      #                  ||| / _----=> hardirq/softirq
      #                  |||| / _---=> preempt-depth
      #                  ||||| / _--=> preempt-lazy-depth
      #                  |||||| / _-=> migrate-disable
      #                  ||||||| /     delay
      #  cmd     pid     |||||||| time  |   caller
      #     \   /        ||||||||  \    |    /
      stress-n-206       3dn.h512    2us :      206:120:R   + [003]     196:  0:R cyclictest
      stress-n-206       3dn.h512    7us : <stack trace>
       => __ftrace_trace_stack
       => __trace_stack
       => probe_wakeup
       => ttwu_do_activate
       => try_to_wake_up
       => wake_up_process
       => hrtimer_wakeup
       => __hrtimer_run_queues
       => hrtimer_interrupt
       => riscv_timer_interrupt
       => handle_percpu_devid_irq
       => generic_handle_domain_irq
       => riscv_intc_irq
       => handle_riscv_irq
       => do_irq
      stress-n-206       3dn.h512    9us#: 0
      stress-n-206       3d...3.. 2544us : __schedule
      stress-n-206       3d...3.. 2545us :      206:120:R ==> [003]     196:  0:R cyclictest
      stress-n-206       3d...3.. 2551us : <stack trace>
       => __ftrace_trace_stack
       => __trace_stack
       => probe_wakeup_sched_switch
       => __schedule
       => preempt_schedule
       => migrate_enable
       => rt_spin_unlock
       => madvise_cold_or_pageout_pte_range
       => walk_pgd_range
       => __walk_page_range
       => walk_page_range
       => madvise_pageout
       => madvise_vma_behavior
       => do_madvise
       => sys_madvise
       => do_trap_ecall_u
       => ret_from_exception
      
      The tracing results after modification are as follows:
      
      # tracer: wakeup_rt
      #
      # wakeup_rt latency trace v1.1.5 on 6.5.0-rt6-r1208-00004-gca3876fc69a6-dirty
      # --------------------------------------------------------------------
      # latency: 1689 us, #6/6, CPU#0 | (M:preempt_rt VP:0, KP:0, SP:0 HP:0 #P:4)
      #    -----------------
      #    | task: cyclictest-217 (uid:0 nice:0 policy:1 rt_prio:99)
      #    -----------------
      #
      #                    _--------=> CPU#
      #                   / _-------=> irqs-off/BH-disabled
      #                  | / _------=> need-resched
      #                  || / _-----=> need-resched-lazy
      #                  ||| / _----=> hardirq/softirq
      #                  |||| / _---=> preempt-depth
      #                  ||||| / _--=> preempt-lazy-depth
      #                  |||||| / _-=> migrate-disable
      #                  ||||||| /     delay
      #  cmd     pid     |||||||| time  |   caller
      #     \   /        ||||||||  \    |    /
      stress-n-232       0dn.h413    1us+:      232:120:R   + [000]     217:  0:R cyclictest
      stress-n-232       0dn.h413   12us : <stack trace>
       => __ftrace_trace_stack
       => __trace_stack
       => probe_wakeup
       => ttwu_do_activate
       => try_to_wake_up
       => wake_up_process
       => hrtimer_wakeup
       => __hrtimer_run_queues
       => hrtimer_interrupt
       => riscv_timer_interrupt
       => handle_percpu_devid_irq
       => generic_handle_domain_irq
       => riscv_intc_irq
       => handle_riscv_irq
       => do_irq
      stress-n-232       0dn.h413   19us#: 0
      stress-n-232       0d...3.. 1671us : __schedule
      stress-n-232       0d...3.. 1676us+:      232:120:R ==> [000]     217:  0:R cyclictest
      stress-n-232       0d...3.. 1687us : <stack trace>
       => __ftrace_trace_stack
       => __trace_stack
       => probe_wakeup_sched_switch
       => __schedule
       => preempt_schedule
       => migrate_enable
       => free_unref_page_list
       => release_pages
       => free_pages_and_swap_cache
       => tlb_batch_pages_flush
       => tlb_flush_mmu
       => unmap_page_range
       => unmap_vmas
       => unmap_region
       => do_vmi_align_munmap.constprop.0
       => do_vmi_munmap
       => __vm_munmap
       => sys_munmap
       => do_trap_ecall_u
       => ret_from_exception
      
      After the modification, the cause of maximum latency is no longer
      madvise_cold_or_pageout_pte_range(), so this modification can reduce the
      latency caused by madvise_cold_or_pageout_pte_range().
      
      
      Currently the madvise_cold_or_pageout_pte_range() function exhibits
      significant latency under memory pressure, which can be effectively
      reduced by adding cond_resched() within the loop.
      
      When the batch_count reaches SWAP_CLUSTER_MAX, we reschedule
      the task to ensure fairness and avoid long lock holding times.
      
      Link: https://lkml.kernel.org/r/85363861af65fac66c7a98c251906afc0d9c8098.1695291046.git.wangjiexun@tinylab.orgSigned-off-by: default avatarJiexun Wang <wangjiexun@tinylab.org>
      Cc: Zhangjin Wu <falcon@tinylab.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      b2f557a2
    • Ryusuke Konishi's avatar
      nilfs2: prevent WARNING in nilfs_sufile_set_segment_usage() · 675abf8d
      Ryusuke Konishi authored
      If nilfs2 reads a disk image with corrupted segment usage metadata, and
      its segment usage information is marked as an error for the segment at the
      write location, nilfs_sufile_set_segment_usage() can trigger WARN_ONs
      during log writing.
      
      Segments newly allocated for writing with nilfs_sufile_alloc() will not
      have this error flag set, but this unexpected situation will occur if the
      segment indexed by either nilfs->ns_segnum or nilfs->ns_nextnum (active
      segment) was marked in error.
      
      Fix this issue by inserting a sanity check to treat it as a file system
      corruption.
      
      Since error returns are not allowed during the execution phase where
      nilfs_sufile_set_segment_usage() is used, this inserts the sanity check
      into nilfs_sufile_mark_dirty() which pre-reads the buffer containing the
      segment usage record to be updated and sets it up in a dirty state for
      writing.
      
      In addition, nilfs_sufile_set_segment_usage() is also called when
      canceling log writing and undoing segment usage update, so in order to
      avoid issuing the same kernel warning in that case, in case of
      cancellation, avoid checking the error flag in
      nilfs_sufile_set_segment_usage().
      
      Link: https://lkml.kernel.org/r/20231205085947.4431-1-konishi.ryusuke@gmail.comSigned-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: syzbot+14e9f834f6ddecece094@syzkaller.appspotmail.com
      Closes: https://syzkaller.appspot.com/bug?extid=14e9f834f6ddecece094Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      675abf8d
    • Sidhartha Kumar's avatar
      mm/hugetlb: have CONFIG_HUGETLB_PAGE select CONFIG_XARRAY_MULTI · 4a3ef6be
      Sidhartha Kumar authored
      After commit a08c7193 "mm/filemap: remove hugetlb special casing in
      filemap.c", hugetlb pages are stored in the page cache in base page sized
      indexes.  This leads to multi index stores in the xarray which is only
      supporting through CONFIG_XARRAY_MULTI.  The other page cache user of
      multi index stores ,THP, selects XARRAY_MULTI.  Have CONFIG_HUGETLB_PAGE
      follow this behavior as well to avoid the BUG() with a CONFIG_HUGETLB_PAGE
      && !CONFIG_XARRAY_MULTI config.
      
      Link: https://lkml.kernel.org/r/20231204183234.348697-1-sidhartha.kumar@oracle.com
      Fixes: a08c7193 ("mm/filemap: remove hugetlb special casing in filemap.c")
      Signed-off-by: default avatarSidhartha Kumar <sidhartha.kumar@oracle.com>
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Muchun Song <muchun.song@linux.dev>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4a3ef6be
    • Florian Fainelli's avatar
      scripts/gdb: fix lx-device-list-bus and lx-device-list-class · 801a2b1b
      Florian Fainelli authored
      After the conversion to bus_to_subsys() and class_to_subsys(), the gdb
      scripts listing the system buses and classes respectively was broken, fix
      those by returning the subsys_priv pointer and have the various caller
      de-reference either the 'bus' or 'class' structure members accordingly.
      
      Link: https://lkml.kernel.org/r/20231130043317.174188-1-florian.fainelli@broadcom.com
      Fixes: 7b884b7f ("driver core: class.c: convert to only use class_to_subsys")
      Signed-off-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Tested-by: default avatarKuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      801a2b1b
    • Bagas Sanjaya's avatar
      MAINTAINERS: drop Antti Palosaari · bc220fe7
      Bagas Sanjaya authored
      He is currently inactive (last message from him is two years ago [1]). 
      His media tree [2] is also dormant (latest activity is 6 years ago), yet
      his site is still online [3].
      
      Drop him from MAINTAINERS and add CREDITS entry for him. We thank him
      for maintaining various DVB drivers.
      
      [1]: https://lore.kernel.org/all/660772b3-0597-02db-ed94-c6a9be04e8e8@iki.fi/
      [2]: https://git.linuxtv.org/anttip/media_tree.git/
      [3]: https://palosaari.fi/linux/
      
      Link: https://lkml.kernel.org/r/20231130083848.5396-1-bagasdotme@gmail.comSigned-off-by: default avatarBagas Sanjaya <bagasdotme@gmail.com>
      Acked-by: default avatarAntti Palosaari <crope@iki.fi>
      Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
      Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      bc220fe7
    • Su Hui's avatar
      highmem: fix a memory copy problem in memcpy_from_folio · 73424d00
      Su Hui authored
      Clang static checker complains that value stored to 'from' is never read. 
      And memcpy_from_folio() only copy the last chunk memory from folio to
      destination.  Use 'to += chunk' to replace 'from += chunk' to fix this
      typo problem.
      
      Link: https://lkml.kernel.org/r/20231130034017.1210429-1-suhui@nfschina.com
      Fixes: b23d03ef ("highmem: add memcpy_to_folio() and memcpy_from_folio()")
      Signed-off-by: default avatarSu Hui <suhui@nfschina.com>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jiaqi Yan <jiaqiyan@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Collingbourne <pcc@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      73424d00
    • Ryusuke Konishi's avatar
      nilfs2: fix missing error check for sb_set_blocksize call · d61d0ab5
      Ryusuke Konishi authored
      When mounting a filesystem image with a block size larger than the page
      size, nilfs2 repeatedly outputs long error messages with stack traces to
      the kernel log, such as the following:
      
       getblk(): invalid block size 8192 requested
       logical block size: 512
       ...
       Call Trace:
        dump_stack_lvl+0x92/0xd4
        dump_stack+0xd/0x10
        bdev_getblk+0x33a/0x354
        __breadahead+0x11/0x80
        nilfs_search_super_root+0xe2/0x704 [nilfs2]
        load_nilfs+0x72/0x504 [nilfs2]
        nilfs_mount+0x30f/0x518 [nilfs2]
        legacy_get_tree+0x1b/0x40
        vfs_get_tree+0x18/0xc4
        path_mount+0x786/0xa88
        __ia32_sys_mount+0x147/0x1a8
        __do_fast_syscall_32+0x56/0xc8
        do_fast_syscall_32+0x29/0x58
        do_SYSENTER_32+0x15/0x18
        entry_SYSENTER_32+0x98/0xf1
       ...
      
      This overloads the system logger.  And to make matters worse, it sometimes
      crashes the kernel with a memory access violation.
      
      This is because the return value of the sb_set_blocksize() call, which
      should be checked for errors, is not checked.
      
      The latter issue is due to out-of-buffer memory being accessed based on a
      large block size that caused sb_set_blocksize() to fail for buffers read
      with the initial minimum block size that remained unupdated in the
      super_block structure.
      
      Since nilfs2 mkfs tool does not accept block sizes larger than the system
      page size, this has been overlooked.  However, it is possible to create
      this situation by intentionally modifying the tool or by passing a
      filesystem image created on a system with a large page size to a system
      with a smaller page size and mounting it.
      
      Fix this issue by inserting the expected error handling for the call to
      sb_set_blocksize().
      
      Link: https://lkml.kernel.org/r/20231129141547.4726-1-konishi.ryusuke@gmail.comSigned-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d61d0ab5
    • Baoquan He's avatar
      kernel/Kconfig.kexec: drop select of KEXEC for CRASH_DUMP · dccf78d3
      Baoquan He authored
      Ignat Korchagin complained that a potential config regression was
      introduced by commit 89cde455 ("kexec: consolidate kexec and crash
      options into kernel/Kconfig.kexec").  Before the commit, CONFIG_CRASH_DUMP
      has no dependency on CONFIG_KEXEC.  After the commit, CRASH_DUMP selects
      KEXEC.  That enforces system to have CONFIG_KEXEC=y as long as
      CONFIG_CRASH_DUMP=Y which people may not want.
      
      In Ignat's case, he sets CONFIG_CRASH_DUMP=y, CONFIG_KEXEC_FILE=y and
      CONFIG_KEXEC=n because kexec_load interface could have security issue if
      kernel/initrd has no chance to be signed and verified.
      
      CRASH_DUMP has select of KEXEC because Eric, author of above commit, met a
      LKP report of build failure when posting patch of earlier version.  Please
      see below link to get detail of the LKP report:
      
          https://lore.kernel.org/all/3e8eecd1-a277-2cfb-690e-5de2eb7b988e@oracle.com/T/#u
      
      In fact, that LKP report is triggered because arm's <asm/kexec.h> is
      wrapped in CONFIG_KEXEC ifdeffery scope.  That is wrong.  CONFIG_KEXEC
      controls the enabling/disabling of kexec_load interface, but not kexec
      feature.  Removing the wrongly added CONFIG_KEXEC ifdeffery scope in
      <asm/kexec.h> of arm allows us to drop the select KEXEC for CRASH_DUMP. 
      Meanwhile, change arch/arm/kernel/Makefile to let machine_kexec.o
      relocate_kernel.o depend on KEXEC_CORE.
      
      Link: https://lkml.kernel.org/r/20231128054457.659452-1-bhe@redhat.com
      Fixes: 89cde455 ("kexec: consolidate kexec and crash options into kernel/Kconfig.kexec")
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reported-by: default avatarIgnat Korchagin <ignat@cloudflare.com>
      Tested-by: Ignat Korchagin <ignat@cloudflare.com>	[compile-time only]
      Tested-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Reviewed-by: default avatarEric DeVolder <eric_devolder@yahoo.com>
      Tested-by: default avatarEric DeVolder <eric_devolder@yahoo.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      dccf78d3