History

Merge tag 'mm-hotfixes-stable-2025-02-01-03-56' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull misc fixes from Andrew Morton: "21 hotfixes. 8 are cc:stable and the remainder address post-6.13 issues. 13 are for MM and 8 are for non-MM. All are singletons, please see the changelogs for details" * tag 'mm-hotfixes-stable-2025-02-01-03-56' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (21 commits) MAINTAINERS: include linux-mm for xarray maintenance revert "xarray: port tests to kunit" MAINTAINERS: add lib/test_xarray.c mailmap, MAINTAINERS, docs: update Carlos's email address mm/hugetlb: fix hugepage allocation for interleaved memory nodes mm: gup: fix infinite loop within __get_longterm_locked mm, swap: fix reclaim offset calculation error during allocation .mailmap: update email address for Christopher Obbard kfence: skip __GFP_THISNODE allocations on NUMA systems nilfs2: fix possible int overflows in nilfs_fiemap() mm: compaction: use the proper flag to determine watermarks kernel: be more careful about dup_mmap() failures and uprobe registering mm/fake-numa: handle cases with no SRAT info mm: kmemleak: fix upper boundary check for physical address objects mailmap: add an entry for Hamza Mahfooz MAINTAINERS: mailmap: update Yosry Ahmed's email address scripts/gdb: fix aarch64 userspace detection in get_current_task mm/vmscan: accumulate nr_demoted for accurate demotion statistics ocfs2: fix incorrect CPU endianness conversion causing mount failure mm/zsmalloc: add __maybe_unused attribute for is_first_zpdesc() ...

Linus Torvalds committed 1 year ago

Commit 03cc3572 parents c6fe03a e5b2a3534 files · +386 −448Browse files

Unified · Split

34 files
  1. .mailmap +6 −1
  2. Documentation/translations/sp_SP/index.rst +1 −1
  3. MAINTAINERS +7 −5
  4. arch/m68k/configs/amiga_defconfig +1 −0
  5. arch/m68k/configs/apollo_defconfig +1 −0
  6. arch/m68k/configs/atari_defconfig +1 −0
  7. arch/m68k/configs/bvme6000_defconfig +1 −0
  8. arch/m68k/configs/hp300_defconfig +1 −0
  9. arch/m68k/configs/mac_defconfig +1 −0
  10. arch/m68k/configs/multi_defconfig +1 −0
  11. arch/m68k/configs/mvme147_defconfig +1 −0
  12. arch/m68k/configs/mvme16x_defconfig +1 −0
  13. arch/m68k/configs/q40_defconfig +1 −0
  14. arch/m68k/configs/sun3_defconfig +1 −0
  15. arch/m68k/configs/sun3x_defconfig +1 −0
  16. arch/powerpc/configs/ppc64_defconfig +1 −0
  17. drivers/acpi/numa/srat.c +10 −1
  18. fs/nilfs2/inode.c +3 −3
  19. fs/ocfs2/super.c +1 −1
  20. include/linux/swap.h +1 −0
  21. kernel/events/uprobes.c +4 −0
  22. kernel/fork.c +14 −3
  23. lib/Kconfig.debug +2 −16
  24. lib/Makefile +1 −1
  25. lib/test_xarray.c +278 −393
  26. mm/compaction.c +25 −4
  27. mm/gup.c +4 −10
  28. mm/hugetlb.c +1 −1
  29. mm/kfence/core.c +2 −0
  30. mm/kmemleak.c +1 −1
  31. mm/swapfile.c +1 −1
  32. mm/vmscan.c +9 −4
  33. mm/zsmalloc.c +1 −1
  34. scripts/gdb/linux/cpus.py +1 −1
.mailmap+6−1
@@ -150,7 +150,9 @@ Bryan Tan <bryan-bt.tan@broadcom.com> <bryantan@vmware.com> · 149 unmodified lines
150150 Cai Huoqing <cai.huoqing@linux.dev> <caihuoqing@baidu.com>
151151 Can Guo <quic_cang@quicinc.com> <cang@codeaurora.org>
152152 Carl Huang <quic_cjhuang@quicinc.com> <cjhuang@codeaurora.org>
153−Carlos Bilbao <carlos.bilbao.osdev@gmail.com> <carlos.bilbao@amd.com>
153+Carlos Bilbao <carlos.bilbao@kernel.org> <carlos.bilbao@amd.com>
154+Carlos Bilbao <carlos.bilbao@kernel.org> <carlos.bilbao.osdev@gmail.com>
155+Carlos Bilbao <carlos.bilbao@kernel.org> <bilbao@vt.edu>
154156 Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com>
155157 Changbin Du <changbin.du@intel.com> <changbin.du@intel.com>
156158 Chao Yu <chao@kernel.org> <chao2.yu@samsung.com>
@@ -167,6 +169,7 @@ Christian Brauner <brauner@kernel.org> <christian.brauner@canonical.com> · 10 unmodified lines
167169 Christian Brauner <brauner@kernel.org> <christian.brauner@ubuntu.com>
168170 Christian Marangi <ansuelsmth@gmail.com>
169171 Christophe Ricard <christophe.ricard@gmail.com>
172+Christopher Obbard <christopher.obbard@linaro.org> <chris.obbard@collabora.com>
170173 Christoph Hellwig <hch@lst.de>
171174 Chuck Lever <chuck.lever@oracle.com> <cel@kernel.org>
172175 Chuck Lever <chuck.lever@oracle.com> <cel@netapp.com>
@@ -263,6 +266,7 @@ Guo Ren <guoren@kernel.org> <ren_guo@c-sky.com> · 90 unmodified lines
263266 Guru Das Srinagesh <quic_gurus@quicinc.com> <gurus@codeaurora.org>
264267 Gustavo Padovan <gustavo@las.ic.unicamp.br>
265268 Gustavo Padovan <padovan@profusion.mobi>
269+Hamza Mahfooz <hamzamahfooz@linux.microsoft.com> <hamza.mahfooz@amd.com>
266270 Hanjun Guo <guohanjun@huawei.com> <hanjun.guo@linaro.org>
267271 Hans Verkuil <hverkuil@xs4all.nl> <hansverk@cisco.com>
268272 Hans Verkuil <hverkuil@xs4all.nl> <hverkuil-cisco@xs4all.nl>
@@ -763,6 +767,7 @@ Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de> · 494 unmodified lines
763767 Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>
764768 Yanteng Si <si.yanteng@linux.dev> <siyanteng@loongson.cn>
765769 Ying Huang <huang.ying.caritas@gmail.com> <ying.huang@intel.com>
770+Yosry Ahmed <yosry.ahmed@linux.dev> <yosryahmed@google.com>
766771 Yusuke Goda <goda.yusuke@renesas.com>
767772 Zack Rusin <zack.rusin@broadcom.com> <zackr@vmware.com>
768773 Zhu Yanjun <zyjzyj2000@gmail.com> <yanjunz@nvidia.com>
Documentation/translations/sp_SP/index.rst+1−1
@@ -7,7 +7,7 @@ Traducción al español · 6 unmodified lines
77
88 \kerneldocCJKoff
99
10−:maintainer: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
10+:maintainer: Carlos Bilbao <carlos.bilbao@kernel.org>
1111
1212 .. _sp_disclaimer:
1313
MAINTAINERS+7−5
@@ -1090,7 +1090,7 @@ F: drivers/video/fbdev/geode/ · 1089 unmodified lines
10901090
10911091 AMD HSMP DRIVER
10921092 M: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
1093−R: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
1093+R: Carlos Bilbao <carlos.bilbao@kernel.org>
10941094 L: platform-driver-x86@vger.kernel.org
10951095 S: Maintained
10961096 F: Documentation/arch/x86/amd_hsmp.rst
@@ -5857,7 +5857,7 @@ F: drivers/usb/atm/cxacru.c · 4760 unmodified lines
58575857
58585858 CONFIDENTIAL COMPUTING THREAT MODEL FOR X86 VIRTUALIZATION (SNP/TDX)
58595859 M: Elena Reshetova <elena.reshetova@intel.com>
5860−M: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
5860+M: Carlos Bilbao <carlos.bilbao@kernel.org>
58615861 S: Maintained
58625862 F: Documentation/security/snp-tdx-threat-model.rst
58635863
@@ -11331,7 +11331,7 @@ S: Orphan · 5467 unmodified lines
1133111331 F: drivers/video/fbdev/imsttfb.c
1133211332
1133311333 INDEX OF FURTHER KERNEL DOCUMENTATION
11334−M: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
11334+M: Carlos Bilbao <carlos.bilbao@kernel.org>
1133511335 S: Maintained
1133611336 F: Documentation/process/kernel-docs.rst
1133711337
@@ -22215,7 +22215,7 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/ · 10877 unmodified lines
2221522215 F: drivers/media/dvb-frontends/sp2*
2221622216
2221722217 SPANISH DOCUMENTATION
22218−M: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
22218+M: Carlos Bilbao <carlos.bilbao@kernel.org>
2221922219 R: Avadhut Naik <avadhut.naik@amd.com>
2222022220 S: Maintained
2222122221 F: Documentation/translations/sp_SP/
@@ -25739,11 +25739,13 @@ F: arch/x86/entry/vdso/ · 3517 unmodified lines
2573925739 XARRAY
2574025740 M: Matthew Wilcox <willy@infradead.org>
2574125741 L: linux-fsdevel@vger.kernel.org
25742+L: linux-mm@kvack.org
2574225743 S: Supported
2574325744 F: Documentation/core-api/xarray.rst
2574425745 F: include/linux/idr.h
2574525746 F: include/linux/xarray.h
2574625747 F: lib/idr.c
25748+F: lib/test_xarray.c
2574725749 F: lib/xarray.c
2574825750 F: tools/testing/radix-tree
2574925751
@@ -26223,7 +26225,7 @@ K: zstd · 473 unmodified lines
2622326225
2622426226 ZSWAP COMPRESSED SWAP CACHING
2622526227 M: Johannes Weiner <hannes@cmpxchg.org>
26226−M: Yosry Ahmed <yosryahmed@google.com>
26228+M: Yosry Ahmed <yosry.ahmed@linux.dev>
2622726229 M: Nhat Pham <nphamcs@gmail.com>
2622826230 R: Chengming Zhou <chengming.zhou@linux.dev>
2622926231 L: linux-mm@kvack.org
arch/m68k/configs/amiga_defconfig+1−0
@@ -626,6 +626,7 @@ CONFIG_TEST_PRINTF=m · 625 unmodified lines
626626 CONFIG_TEST_SCANF=m
627627 CONFIG_TEST_BITMAP=m
628628 CONFIG_TEST_UUID=m
629+CONFIG_TEST_XARRAY=m
629630 CONFIG_TEST_MAPLE_TREE=m
630631 CONFIG_TEST_RHASHTABLE=m
631632 CONFIG_TEST_IDA=m
arch/m68k/configs/apollo_defconfig+1−0
@@ -583,6 +583,7 @@ CONFIG_TEST_PRINTF=m · 582 unmodified lines
583583 CONFIG_TEST_SCANF=m
584584 CONFIG_TEST_BITMAP=m
585585 CONFIG_TEST_UUID=m
586+CONFIG_TEST_XARRAY=m
586587 CONFIG_TEST_MAPLE_TREE=m
587588 CONFIG_TEST_RHASHTABLE=m
588589 CONFIG_TEST_IDA=m
arch/m68k/configs/atari_defconfig+1−0
@@ -603,6 +603,7 @@ CONFIG_TEST_PRINTF=m · 602 unmodified lines
603603 CONFIG_TEST_SCANF=m
604604 CONFIG_TEST_BITMAP=m
605605 CONFIG_TEST_UUID=m
606+CONFIG_TEST_XARRAY=m
606607 CONFIG_TEST_MAPLE_TREE=m
607608 CONFIG_TEST_RHASHTABLE=m
608609 CONFIG_TEST_IDA=m
arch/m68k/configs/bvme6000_defconfig+1−0
@@ -575,6 +575,7 @@ CONFIG_TEST_PRINTF=m · 574 unmodified lines
575575 CONFIG_TEST_SCANF=m
576576 CONFIG_TEST_BITMAP=m
577577 CONFIG_TEST_UUID=m
578+CONFIG_TEST_XARRAY=m
578579 CONFIG_TEST_MAPLE_TREE=m
579580 CONFIG_TEST_RHASHTABLE=m
580581 CONFIG_TEST_IDA=m
arch/m68k/configs/hp300_defconfig+1−0
@@ -585,6 +585,7 @@ CONFIG_TEST_PRINTF=m · 584 unmodified lines
585585 CONFIG_TEST_SCANF=m
586586 CONFIG_TEST_BITMAP=m
587587 CONFIG_TEST_UUID=m
588+CONFIG_TEST_XARRAY=m
588589 CONFIG_TEST_MAPLE_TREE=m
589590 CONFIG_TEST_RHASHTABLE=m
590591 CONFIG_TEST_IDA=m
arch/m68k/configs/mac_defconfig+1−0
@@ -602,6 +602,7 @@ CONFIG_TEST_PRINTF=m · 601 unmodified lines
602602 CONFIG_TEST_SCANF=m
603603 CONFIG_TEST_BITMAP=m
604604 CONFIG_TEST_UUID=m
605+CONFIG_TEST_XARRAY=m
605606 CONFIG_TEST_MAPLE_TREE=m
606607 CONFIG_TEST_RHASHTABLE=m
607608 CONFIG_TEST_IDA=m
arch/m68k/configs/multi_defconfig+1−0
@@ -689,6 +689,7 @@ CONFIG_TEST_PRINTF=m · 688 unmodified lines
689689 CONFIG_TEST_SCANF=m
690690 CONFIG_TEST_BITMAP=m
691691 CONFIG_TEST_UUID=m
692+CONFIG_TEST_XARRAY=m
692693 CONFIG_TEST_MAPLE_TREE=m
693694 CONFIG_TEST_RHASHTABLE=m
694695 CONFIG_TEST_IDA=m
arch/m68k/configs/mvme147_defconfig+1−0
@@ -575,6 +575,7 @@ CONFIG_TEST_PRINTF=m · 574 unmodified lines
575575 CONFIG_TEST_SCANF=m
576576 CONFIG_TEST_BITMAP=m
577577 CONFIG_TEST_UUID=m
578+CONFIG_TEST_XARRAY=m
578579 CONFIG_TEST_MAPLE_TREE=m
579580 CONFIG_TEST_RHASHTABLE=m
580581 CONFIG_TEST_IDA=m
arch/m68k/configs/mvme16x_defconfig+1−0
@@ -576,6 +576,7 @@ CONFIG_TEST_PRINTF=m · 575 unmodified lines
576576 CONFIG_TEST_SCANF=m
577577 CONFIG_TEST_BITMAP=m
578578 CONFIG_TEST_UUID=m
579+CONFIG_TEST_XARRAY=m
579580 CONFIG_TEST_MAPLE_TREE=m
580581 CONFIG_TEST_RHASHTABLE=m
581582 CONFIG_TEST_IDA=m
arch/m68k/configs/q40_defconfig+1−0
@@ -592,6 +592,7 @@ CONFIG_TEST_PRINTF=m · 591 unmodified lines
592592 CONFIG_TEST_SCANF=m
593593 CONFIG_TEST_BITMAP=m
594594 CONFIG_TEST_UUID=m
595+CONFIG_TEST_XARRAY=m
595596 CONFIG_TEST_MAPLE_TREE=m
596597 CONFIG_TEST_RHASHTABLE=m
597598 CONFIG_TEST_IDA=m
arch/m68k/configs/sun3_defconfig+1−0
@@ -572,6 +572,7 @@ CONFIG_TEST_PRINTF=m · 571 unmodified lines
572572 CONFIG_TEST_SCANF=m
573573 CONFIG_TEST_BITMAP=m
574574 CONFIG_TEST_UUID=m
575+CONFIG_TEST_XARRAY=m
575576 CONFIG_TEST_MAPLE_TREE=m
576577 CONFIG_TEST_RHASHTABLE=m
577578 CONFIG_TEST_IDA=m
arch/m68k/configs/sun3x_defconfig+1−0
@@ -573,6 +573,7 @@ CONFIG_TEST_PRINTF=m · 572 unmodified lines
573573 CONFIG_TEST_SCANF=m
574574 CONFIG_TEST_BITMAP=m
575575 CONFIG_TEST_UUID=m
576+CONFIG_TEST_XARRAY=m
576577 CONFIG_TEST_MAPLE_TREE=m
577578 CONFIG_TEST_RHASHTABLE=m
578579 CONFIG_TEST_IDA=m
arch/powerpc/configs/ppc64_defconfig+1−0
@@ -448,6 +448,7 @@ CONFIG_TEST_PRINTF=m · 447 unmodified lines
448448 CONFIG_TEST_SCANF=m
449449 CONFIG_TEST_BITMAP=m
450450 CONFIG_TEST_UUID=m
451+CONFIG_TEST_XARRAY=m
451452 CONFIG_TEST_MAPLE_TREE=m
452453 CONFIG_TEST_RHASHTABLE=m
453454 CONFIG_TEST_IDA=m
drivers/acpi/numa/srat.c+10−1
@@ -95,9 +95,13 @@ int __init fix_pxm_node_maps(int max_nid) · 94 unmodified lines
9595 int i, j, index = -1, count = 0;
9696 nodemask_t nodes_to_enable;
9797
98− if (numa_off || srat_disabled())
98+ if (numa_off)
9999 return -1;
100100
101+ /* no or incomplete node/PXM mapping set, nothing to do */
102+ if (srat_disabled())
103+ return 0;
104+
101105 /* find fake nodes PXM mapping */
102106 for (i = 0; i < MAX_NUMNODES; i++) {
103107 if (node_to_pxm_map[i] != PXM_INVAL) {
@@ -117,6 +121,11 @@ int __init fix_pxm_node_maps(int max_nid) · 13 unmodified lines
117121 }
118122 }
119123 }
124+ if (index == -1) {
125+ pr_debug("No node/PXM mapping has been set\n");
126+ /* nothing more to be done */
127+ return 0;
128+ }
120129 if (WARN(index != max_nid, "%d max nid when expected %d\n",
121130 index, max_nid))
122131 return -1;
fs/nilfs2/inode.c+3−3
@@ -1186,7 +1186,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · 1185 unmodified lines
11861186 if (size) {
11871187 if (phys && blkphy << blkbits == phys + size) {
11881188 /* The current extent goes on */
1189− size += n << blkbits;
1189+ size += (u64)n << blkbits;
11901190 } else {
11911191 /* Terminate the current extent */
11921192 ret = fiemap_fill_next_extent(
@@ -1199,14 +1199,14 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · 6 unmodified lines
11991199 flags = FIEMAP_EXTENT_MERGED;
12001200 logical = blkoff << blkbits;
12011201 phys = blkphy << blkbits;
1202− size = n << blkbits;
1202+ size = (u64)n << blkbits;
12031203 }
12041204 } else {
12051205 /* Start a new extent */
12061206 flags = FIEMAP_EXTENT_MERGED;
12071207 logical = blkoff << blkbits;
12081208 phys = blkphy << blkbits;
1209− size = n << blkbits;
1209+ size = (u64)n << blkbits;
12101210 }
12111211 blkoff += n;
12121212 }
fs/ocfs2/super.c+1−1
@@ -2285,7 +2285,7 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di, · 2284 unmodified lines
22852285 mlog(ML_ERROR, "found superblock with incorrect block "
22862286 "size bits: found %u, should be 9, 10, 11, or 12\n",
22872287 blksz_bits);
2288− } else if ((1 << le32_to_cpu(blksz_bits)) != blksz) {
2288+ } else if ((1 << blksz_bits) != blksz) {
22892289 mlog(ML_ERROR, "found superblock with incorrect block "
22902290 "size: found %u, should be %u\n", 1 << blksz_bits, blksz);
22912291 } else if (le16_to_cpu(di->id2.i_super.s_major_rev_level) !=
include/linux/swap.h+1−0
@@ -222,6 +222,7 @@ enum { · 221 unmodified lines
222222 };
223223
224224 #define SWAP_CLUSTER_MAX 32UL
225+#define SWAP_CLUSTER_MAX_SKIPPED (SWAP_CLUSTER_MAX << 10)
225226 #define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
226227
227228 /* Bit flag in swap_map */
kernel/events/uprobes.c+4−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/rcupdate_trace.h>
2929 #include <linux/workqueue.h>
3030 #include <linux/srcu.h>
31+#include <linux/oom.h> /* check_stable_address_space */
3132
3233 #include <linux/uprobes.h>
3334
@@ -1260,6 +1261,9 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new) · 1226 unmodified lines
12601261 * returns NULL in find_active_uprobe_rcu().
12611262 */
12621263 mmap_write_lock(mm);
1264+ if (check_stable_address_space(mm))
1265+ goto unlock;
1266+
12631267 vma = find_vma(mm, info->vaddr);
12641268 if (!vma || !valid_vma(vma, is_register) ||
12651269 file_inode(vma->vm_file) != uprobe->inode)
kernel/fork.c+14−3
@@ -760,7 +760,8 @@ loop_out: · 759 unmodified lines
760760 mt_set_in_rcu(vmi.mas.tree);
761761 ksm_fork(mm, oldmm);
762762 khugepaged_fork(mm, oldmm);
763− } else if (mpnt) {
763+ } else {
764+
764765 /*
765766 * The entire maple tree has already been duplicated. If the
766767 * mmap duplication fails, mark the failure point with
@@ -768,8 +769,18 @@ loop_out: · 1 unmodified line
768769 * stop releasing VMAs that have not been duplicated after this
769770 * point.
770771 */
771− mas_set_range(&vmi.mas, mpnt->vm_start, mpnt->vm_end - 1);
772− mas_store(&vmi.mas, XA_ZERO_ENTRY);
772+ if (mpnt) {
773+ mas_set_range(&vmi.mas, mpnt->vm_start, mpnt->vm_end - 1);
774+ mas_store(&vmi.mas, XA_ZERO_ENTRY);
775+ /* Avoid OOM iterating a broken tree */
776+ set_bit(MMF_OOM_SKIP, &mm->flags);
777+ }
778+ /*
779+ * The mm_struct is going to exit, but the locks will be dropped
780+ * first. Set the mm_struct as unstable is advisable as it is
781+ * not fully initialised.
782+ */
783+ set_bit(MMF_UNSTABLE, &mm->flags);
773784 }
774785 out:
775786 mmap_write_unlock(mm);
lib/Kconfig.debug+2−16
@@ -2456,22 +2456,8 @@ config TEST_BITMAP · 2455 unmodified lines
24562456 config TEST_UUID
24572457 tristate "Test functions located in the uuid module at runtime"
24582458
2459−config XARRAY_KUNIT
2460− tristate "KUnit test XArray code at runtime" if !KUNIT_ALL_TESTS
2461− depends on KUNIT
2462− default KUNIT_ALL_TESTS
2463− help
2464− Enable this option to test the Xarray code at boot.
2465−
2466− KUnit tests run during boot and output the results to the debug log
2467− in TAP format (http://testanything.org/). Only useful for kernel devs
2468− running the KUnit test harness, and not intended for inclusion into a
2469− production build.
2470−
2471− For more information on KUnit and unit tests in general please refer
2472− to the KUnit documentation in Documentation/dev-tools/kunit/.
2473−
2474− If unsure, say N.
2459+config TEST_XARRAY
2460+ tristate "Test the XArray code at runtime"
24752461
24762462 config TEST_MAPLE_TREE
24772463 tristate "Test the Maple Tree code at runtime or module load"
lib/Makefile+1−1
@@ -94,6 +94,7 @@ GCOV_PROFILE_test_bitmap.o := n · 93 unmodified lines
9494 endif
9595
9696 obj-$(CONFIG_TEST_UUID) += test_uuid.o
97+obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
9798 obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o
9899 obj-$(CONFIG_TEST_PARMAN) += test_parman.o
99100 obj-$(CONFIG_TEST_KMOD) += test_kmod.o
@@ -372,7 +373,6 @@ CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN) · 272 unmodified lines
372373 obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
373374 obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o
374375 obj-$(CONFIG_UTIL_MACROS_KUNIT) += util_macros_kunit.o
375−obj-$(CONFIG_XARRAY_KUNIT) += test_xarray.o
376376 obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
377377 obj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o
378378 obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
lib/test_xarray.c+278−393
@@ -6,10 +6,11 @@ · 5 unmodified lines
66 * Author: Matthew Wilcox <willy@infradead.org>
77 */
88
9−#include <kunit/test.h>
10−
11−#include <linux/module.h>
129 #include <linux/xarray.h>
10+#include <linux/module.h>
11+
12+static unsigned int tests_run;
13+static unsigned int tests_passed;
1314
1415 static const unsigned int order_limit =
1516 IS_ENABLED(CONFIG_XARRAY_MULTI) ? BITS_PER_LONG : 1;
@@ -19,12 +20,15 @@ static const unsigned int order_limit = · 3 unmodified lines
1920 void xa_dump(const struct xarray *xa) { }
2021 # endif
2122 #undef XA_BUG_ON
22−#define XA_BUG_ON(xa, x) do { \
23− if (x) { \
24− KUNIT_FAIL(test, #x); \
25− xa_dump(xa); \
26− dump_stack(); \
27− } \
23+#define XA_BUG_ON(xa, x) do { \
24+ tests_run++; \
25+ if (x) { \
26+ printk("BUG at %s:%d\n", __func__, __LINE__); \
27+ xa_dump(xa); \
28+ dump_stack(); \
29+ } else { \
30+ tests_passed++; \
31+ } \
2832 } while (0)
2933 #endif
3034
@@ -38,13 +42,13 @@ static void *xa_store_index(struct xarray *xa, unsigned long index, gfp_t gfp) · 7 unmodified lines
3842 return xa_store(xa, index, xa_mk_index(index), gfp);
3943 }
4044
41−static void xa_insert_index(struct kunit *test, struct xarray *xa, unsigned long index)
45+static void xa_insert_index(struct xarray *xa, unsigned long index)
4246 {
4347 XA_BUG_ON(xa, xa_insert(xa, index, xa_mk_index(index),
4448 GFP_KERNEL) != 0);
4549 }
4650
47−static void xa_alloc_index(struct kunit *test, struct xarray *xa, unsigned long index, gfp_t gfp)
51+static void xa_alloc_index(struct xarray *xa, unsigned long index, gfp_t gfp)
4852 {
4953 u32 id;
5054
@@ -53,7 +57,7 @@ static void xa_alloc_index(struct kunit *test, struct xarray *xa, unsigned long · 2 unmodified lines
5357 XA_BUG_ON(xa, id != index);
5458 }
5559
56−static void xa_erase_index(struct kunit *test, struct xarray *xa, unsigned long index)
60+static void xa_erase_index(struct xarray *xa, unsigned long index)
5761 {
5862 XA_BUG_ON(xa, xa_erase(xa, index) != xa_mk_index(index));
5963 XA_BUG_ON(xa, xa_load(xa, index) != NULL);
@@ -79,15 +83,8 @@ static void *xa_store_order(struct xarray *xa, unsigned long index, · 19 unmodified lines
7983 return curr;
8084 }
8185
82−static inline struct xarray *xa_param(struct kunit *test)
86+static noinline void check_xa_err(struct xarray *xa)
8387 {
84− return *(struct xarray **)test->param_value;
85−}
86−
87−static noinline void check_xa_err(struct kunit *test)
88−{
89− struct xarray *xa = xa_param(test);
90−
9188 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 0, GFP_NOWAIT)) != 0);
9289 XA_BUG_ON(xa, xa_err(xa_erase(xa, 0)) != 0);
9390 #ifndef __KERNEL__
@@ -102,10 +99,8 @@ static noinline void check_xa_err(struct kunit *test) · 8 unmodified lines
10299 // XA_BUG_ON(xa, xa_err(xa_store(xa, 0, xa_mk_internal(0), 0)) != -EINVAL);
103100 }
104101
105−static noinline void check_xas_retry(struct kunit *test)
102+static noinline void check_xas_retry(struct xarray *xa)
106103 {
107− struct xarray *xa = xa_param(test);
108−
109104 XA_STATE(xas, xa, 0);
110105 void *entry;
111106
@@ -114,7 +109,7 @@ static noinline void check_xas_retry(struct kunit *test) · 2 unmodified lines
114109
115110 rcu_read_lock();
116111 XA_BUG_ON(xa, xas_find(&xas, ULONG_MAX) != xa_mk_value(0));
117− xa_erase_index(test, xa, 1);
112+ xa_erase_index(xa, 1);
118113 XA_BUG_ON(xa, !xa_is_retry(xas_reload(&xas)));
119114 XA_BUG_ON(xa, xas_retry(&xas, NULL));
120115 XA_BUG_ON(xa, xas_retry(&xas, xa_mk_value(0)));
@@ -145,14 +140,12 @@ static noinline void check_xas_retry(struct kunit *test) · 24 unmodified lines
145140 }
146141 xas_unlock(&xas);
147142
148− xa_erase_index(test, xa, 0);
149− xa_erase_index(test, xa, 1);
143+ xa_erase_index(xa, 0);
144+ xa_erase_index(xa, 1);
150145 }
151146
152−static noinline void check_xa_load(struct kunit *test)
147+static noinline void check_xa_load(struct xarray *xa)
153148 {
154− struct xarray *xa = xa_param(test);
155−
156149 unsigned long i, j;
157150
158151 for (i = 0; i < 1024; i++) {
@@ -174,15 +167,13 @@ static noinline void check_xa_load(struct kunit *test) · 15 unmodified lines
174167 else
175168 XA_BUG_ON(xa, entry);
176169 }
177− xa_erase_index(test, xa, i);
170+ xa_erase_index(xa, i);
178171 }
179172 XA_BUG_ON(xa, !xa_empty(xa));
180173 }
181174
182−static noinline void check_xa_mark_1(struct kunit *test, unsigned long index)
175+static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index)
183176 {
184− struct xarray *xa = xa_param(test);
185−
186177 unsigned int order;
187178 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 8 : 1;
188179
@@ -202,7 +193,7 @@ static noinline void check_xa_mark_1(struct kunit *test, unsigned long index) · 13 unmodified lines
202193 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_1));
203194
204195 /* Storing NULL clears marks, and they can't be set again */
205− xa_erase_index(test, xa, index);
196+ xa_erase_index(xa, index);
206197 XA_BUG_ON(xa, !xa_empty(xa));
207198 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0));
208199 xa_set_mark(xa, index, XA_MARK_0);
@@ -253,17 +244,15 @@ static noinline void check_xa_mark_1(struct kunit *test, unsigned long index) · 44 unmodified lines
253244 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_0));
254245 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_1));
255246 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_2));
256− xa_erase_index(test, xa, index);
257− xa_erase_index(test, xa, next);
247+ xa_erase_index(xa, index);
248+ xa_erase_index(xa, next);
258249 XA_BUG_ON(xa, !xa_empty(xa));
259250 }
260251 XA_BUG_ON(xa, !xa_empty(xa));
261252 }
262253
263−static noinline void check_xa_mark_2(struct kunit *test)
254+static noinline void check_xa_mark_2(struct xarray *xa)
264255 {
265− struct xarray *xa = xa_param(test);
266−
267256 XA_STATE(xas, xa, 0);
268257 unsigned long index;
269258 unsigned int count = 0;
@@ -300,11 +289,9 @@ static noinline void check_xa_mark_2(struct kunit *test) · 30 unmodified lines
300289 xa_destroy(xa);
301290 }
302291
303−static noinline void check_xa_mark_3(struct kunit *test)
292+static noinline void check_xa_mark_3(struct xarray *xa)
304293 {
305294 #ifdef CONFIG_XARRAY_MULTI
306− struct xarray *xa = xa_param(test);
307−
308295 XA_STATE(xas, xa, 0x41);
309296 void *entry;
310297 int count = 0;
@@ -323,21 +310,19 @@ static noinline void check_xa_mark_3(struct kunit *test) · 12 unmodified lines
323310 #endif
324311 }
325312
326−static noinline void check_xa_mark(struct kunit *test)
313+static noinline void check_xa_mark(struct xarray *xa)
327314 {
328315 unsigned long index;
329316
330317 for (index = 0; index < 16384; index += 4)
331− check_xa_mark_1(test, index);
318+ check_xa_mark_1(xa, index);
332319
333− check_xa_mark_2(test);
334− check_xa_mark_3(test);
320+ check_xa_mark_2(xa);
321+ check_xa_mark_3(xa);
335322 }
336323
337−static noinline void check_xa_shrink(struct kunit *test)
324+static noinline void check_xa_shrink(struct xarray *xa)
338325 {
339− struct xarray *xa = xa_param(test);
340−
341326 XA_STATE(xas, xa, 1);
342327 struct xa_node *node;
343328 unsigned int order;
@@ -362,7 +347,7 @@ static noinline void check_xa_shrink(struct kunit *test) · 18 unmodified lines
362347 XA_BUG_ON(xa, xas_load(&xas) != NULL);
363348 xas_unlock(&xas);
364349 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0));
365− xa_erase_index(test, xa, 0);
350+ xa_erase_index(xa, 0);
366351 XA_BUG_ON(xa, !xa_empty(xa));
367352
368353 for (order = 0; order < max_order; order++) {
@@ -379,49 +364,45 @@ static noinline void check_xa_shrink(struct kunit *test) · 10 unmodified lines
379364 XA_BUG_ON(xa, xa_head(xa) == node);
380365 rcu_read_unlock();
381366 XA_BUG_ON(xa, xa_load(xa, max + 1) != NULL);
382− xa_erase_index(test, xa, ULONG_MAX);
367+ xa_erase_index(xa, ULONG_MAX);
383368 XA_BUG_ON(xa, xa->xa_head != node);
384− xa_erase_index(test, xa, 0);
369+ xa_erase_index(xa, 0);
385370 }
386371 }
387372
388−static noinline void check_insert(struct kunit *test)
373+static noinline void check_insert(struct xarray *xa)
389374 {
390− struct xarray *xa = xa_param(test);
391−
392375 unsigned long i;
393376
394377 for (i = 0; i < 1024; i++) {
395− xa_insert_index(test, xa, i);
378+ xa_insert_index(xa, i);
396379 XA_BUG_ON(xa, xa_load(xa, i - 1) != NULL);
397380 XA_BUG_ON(xa, xa_load(xa, i + 1) != NULL);
398− xa_erase_index(test, xa, i);
381+ xa_erase_index(xa, i);
399382 }
400383
401384 for (i = 10; i < BITS_PER_LONG; i++) {
402− xa_insert_index(test, xa, 1UL << i);
385+ xa_insert_index(xa, 1UL << i);
403386 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 1) != NULL);
404387 XA_BUG_ON(xa, xa_load(xa, (1UL << i) + 1) != NULL);
405− xa_erase_index(test, xa, 1UL << i);
388+ xa_erase_index(xa, 1UL << i);
406389
407− xa_insert_index(test, xa, (1UL << i) - 1);
390+ xa_insert_index(xa, (1UL << i) - 1);
408391 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 2) != NULL);
409392 XA_BUG_ON(xa, xa_load(xa, 1UL << i) != NULL);
410− xa_erase_index(test, xa, (1UL << i) - 1);
393+ xa_erase_index(xa, (1UL << i) - 1);
411394 }
412395
413− xa_insert_index(test, xa, ~0UL);
396+ xa_insert_index(xa, ~0UL);
414397 XA_BUG_ON(xa, xa_load(xa, 0UL) != NULL);
415398 XA_BUG_ON(xa, xa_load(xa, ~1UL) != NULL);
416− xa_erase_index(test, xa, ~0UL);
399+ xa_erase_index(xa, ~0UL);
417400
418401 XA_BUG_ON(xa, !xa_empty(xa));
419402 }
420403
421−static noinline void check_cmpxchg(struct kunit *test)
404+static noinline void check_cmpxchg(struct xarray *xa)
422405 {
423− struct xarray *xa = xa_param(test);
424−
425406 void *FIVE = xa_mk_value(5);
426407 void *SIX = xa_mk_value(6);
427408 void *LOTS = xa_mk_value(12345678);
@@ -437,16 +418,14 @@ static noinline void check_cmpxchg(struct kunit *test) · 9 unmodified lines
437418 XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) != -EBUSY);
438419 XA_BUG_ON(xa, xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL) != FIVE);
439420 XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) == -EBUSY);
440− xa_erase_index(test, xa, 12345678);
441− xa_erase_index(test, xa, 5);
421+ xa_erase_index(xa, 12345678);
422+ xa_erase_index(xa, 5);
442423 XA_BUG_ON(xa, !xa_empty(xa));
443424 }
444425
445−static noinline void check_cmpxchg_order(struct kunit *test)
426+static noinline void check_cmpxchg_order(struct xarray *xa)
446427 {
447428 #ifdef CONFIG_XARRAY_MULTI
448− struct xarray *xa = xa_param(test);
449−
450429 void *FIVE = xa_mk_value(5);
451430 unsigned int i, order = 3;
452431
@@ -497,10 +476,8 @@ static noinline void check_cmpxchg_order(struct kunit *test) · 44 unmodified lines
497476 #endif
498477 }
499478
500−static noinline void check_reserve(struct kunit *test)
479+static noinline void check_reserve(struct xarray *xa)
501480 {
502− struct xarray *xa = xa_param(test);
503−
504481 void *entry;
505482 unsigned long index;
506483 int count;
@@ -517,7 +494,7 @@ static noinline void check_reserve(struct kunit *test) · 10 unmodified lines
517494 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0);
518495 XA_BUG_ON(xa, xa_store_index(xa, 12345678, GFP_NOWAIT) != NULL);
519496 xa_release(xa, 12345678);
520− xa_erase_index(test, xa, 12345678);
497+ xa_erase_index(xa, 12345678);
521498 XA_BUG_ON(xa, !xa_empty(xa));
522499
523500 /* cmpxchg sees a reserved entry as ZERO */
@@ -525,7 +502,7 @@ static noinline void check_reserve(struct kunit *test) · 1 unmodified line
525502 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, XA_ZERO_ENTRY,
526503 xa_mk_value(12345678), GFP_NOWAIT) != NULL);
527504 xa_release(xa, 12345678);
528− xa_erase_index(test, xa, 12345678);
505+ xa_erase_index(xa, 12345678);
529506 XA_BUG_ON(xa, !xa_empty(xa));
530507
531508 /* xa_insert treats it as busy */
@@ -565,10 +542,8 @@ static noinline void check_reserve(struct kunit *test) · 33 unmodified lines
565542 xa_destroy(xa);
566543 }
567544
568−static noinline void check_xas_erase(struct kunit *test)
545+static noinline void check_xas_erase(struct xarray *xa)
569546 {
570− struct xarray *xa = xa_param(test);
571−
572547 XA_STATE(xas, xa, 0);
573548 void *entry;
574549 unsigned long i, j;
@@ -606,11 +581,9 @@ static noinline void check_xas_erase(struct kunit *test) · 31 unmodified lines
606581 }
607582
608583 #ifdef CONFIG_XARRAY_MULTI
609−static noinline void check_multi_store_1(struct kunit *test, unsigned long index,
584+static noinline void check_multi_store_1(struct xarray *xa, unsigned long index,
610585 unsigned int order)
611586 {
612− struct xarray *xa = xa_param(test);
613−
614587 XA_STATE(xas, xa, index);
615588 unsigned long min = index & ~((1UL << order) - 1);
616589 unsigned long max = min + (1UL << order);
@@ -629,15 +602,13 @@ static noinline void check_multi_store_1(struct kunit *test, unsigned long index · 12 unmodified lines
629602 XA_BUG_ON(xa, xa_load(xa, max) != NULL);
630603 XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL);
631604
632− xa_erase_index(test, xa, min);
605+ xa_erase_index(xa, min);
633606 XA_BUG_ON(xa, !xa_empty(xa));
634607 }
635608
636−static noinline void check_multi_store_2(struct kunit *test, unsigned long index,
609+static noinline void check_multi_store_2(struct xarray *xa, unsigned long index,
637610 unsigned int order)
638611 {
639− struct xarray *xa = xa_param(test);
640−
641612 XA_STATE(xas, xa, index);
642613 xa_store_order(xa, index, order, xa_mk_value(0), GFP_KERNEL);
643614
@@ -649,11 +620,9 @@ static noinline void check_multi_store_2(struct kunit *test, unsigned long index · 5 unmodified lines
649620 XA_BUG_ON(xa, !xa_empty(xa));
650621 }
651622
652−static noinline void check_multi_store_3(struct kunit *test, unsigned long index,
623+static noinline void check_multi_store_3(struct xarray *xa, unsigned long index,
653624 unsigned int order)
654625 {
655− struct xarray *xa = xa_param(test);
656−
657626 XA_STATE(xas, xa, 0);
658627 void *entry;
659628 int n = 0;
@@ -678,11 +647,9 @@ static noinline void check_multi_store_3(struct kunit *test, unsigned long index · 18 unmodified lines
678647 }
679648 #endif
680649
681−static noinline void check_multi_store(struct kunit *test)
650+static noinline void check_multi_store(struct xarray *xa)
682651 {
683652 #ifdef CONFIG_XARRAY_MULTI
684− struct xarray *xa = xa_param(test);
685−
686653 unsigned long i, j, k;
687654 unsigned int max_order = (sizeof(long) == 4) ? 30 : 60;
688655
@@ -747,28 +714,26 @@ static noinline void check_multi_store(struct kunit *test) · 58 unmodified lines
747714 }
748715
749716 for (i = 0; i < 20; i++) {
750− check_multi_store_1(test, 200, i);
751− check_multi_store_1(test, 0, i);
752− check_multi_store_1(test, (1UL << i) + 1, i);
717+ check_multi_store_1(xa, 200, i);
718+ check_multi_store_1(xa, 0, i);
719+ check_multi_store_1(xa, (1UL << i) + 1, i);
753720 }
754− check_multi_store_2(test, 4095, 9);
721+ check_multi_store_2(xa, 4095, 9);
755722
756723 for (i = 1; i < 20; i++) {
757− check_multi_store_3(test, 0, i);
758− check_multi_store_3(test, 1UL << i, i);
724+ check_multi_store_3(xa, 0, i);
725+ check_multi_store_3(xa, 1UL << i, i);
759726 }
760727 #endif
761728 }
762729
763730 #ifdef CONFIG_XARRAY_MULTI
764731 /* mimics page cache __filemap_add_folio() */
765−static noinline void check_xa_multi_store_adv_add(struct kunit *test,
732+static noinline void check_xa_multi_store_adv_add(struct xarray *xa,
766733 unsigned long index,
767734 unsigned int order,
768735 void *p)
769736 {
770− struct xarray *xa = xa_param(test);
771−
772737 XA_STATE(xas, xa, index);
773738 unsigned int nrpages = 1UL << order;
774739
@@ -796,12 +761,10 @@ static noinline void check_xa_multi_store_adv_add(struct kunit *test, · 21 unmodified lines
796761 }
797762
798763 /* mimics page_cache_delete() */
799−static noinline void check_xa_multi_store_adv_del_entry(struct kunit *test,
764+static noinline void check_xa_multi_store_adv_del_entry(struct xarray *xa,
800765 unsigned long index,
801766 unsigned int order)
802767 {
803− struct xarray *xa = xa_param(test);
804−
805768 XA_STATE(xas, xa, index);
806769
807770 xas_set_order(&xas, index, order);
@@ -809,14 +772,12 @@ static noinline void check_xa_multi_store_adv_del_entry(struct kunit *test, · 1 unmodified line
809772 xas_init_marks(&xas);
810773 }
811774
812−static noinline void check_xa_multi_store_adv_delete(struct kunit *test,
775+static noinline void check_xa_multi_store_adv_delete(struct xarray *xa,
813776 unsigned long index,
814777 unsigned int order)
815778 {
816− struct xarray *xa = xa_param(test);
817−
818779 xa_lock_irq(xa);
819− check_xa_multi_store_adv_del_entry(test, index, order);
780+ check_xa_multi_store_adv_del_entry(xa, index, order);
820781 xa_unlock_irq(xa);
821782 }
822783
@@ -853,12 +814,10 @@ static unsigned long some_val = 0xdeadbeef; · 30 unmodified lines
853814 static unsigned long some_val_2 = 0xdeaddead;
854815
855816 /* mimics the page cache usage */
856−static noinline void check_xa_multi_store_adv(struct kunit *test,
817+static noinline void check_xa_multi_store_adv(struct xarray *xa,
857818 unsigned long pos,
858819 unsigned int order)
859820 {
860− struct xarray *xa = xa_param(test);
861−
862821 unsigned int nrpages = 1UL << order;
863822 unsigned long index, base, next_index, next_next_index;
864823 unsigned int i;
@@ -868,7 +827,7 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 3 unmodified lines
868827 next_index = round_down(base + nrpages, nrpages);
869828 next_next_index = round_down(next_index + nrpages, nrpages);
870829
871− check_xa_multi_store_adv_add(test, base, order, &some_val);
830+ check_xa_multi_store_adv_add(xa, base, order, &some_val);
872831
873832 for (i = 0; i < nrpages; i++)
874833 XA_BUG_ON(xa, test_get_entry(xa, base + i) != &some_val);
@@ -876,20 +835,20 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 1 unmodified line
876835 XA_BUG_ON(xa, test_get_entry(xa, next_index) != NULL);
877836
878837 /* Use order 0 for the next item */
879− check_xa_multi_store_adv_add(test, next_index, 0, &some_val_2);
838+ check_xa_multi_store_adv_add(xa, next_index, 0, &some_val_2);
880839 XA_BUG_ON(xa, test_get_entry(xa, next_index) != &some_val_2);
881840
882841 /* Remove the next item */
883− check_xa_multi_store_adv_delete(test, next_index, 0);
842+ check_xa_multi_store_adv_delete(xa, next_index, 0);
884843
885844 /* Now use order for a new pointer */
886− check_xa_multi_store_adv_add(test, next_index, order, &some_val_2);
845+ check_xa_multi_store_adv_add(xa, next_index, order, &some_val_2);
887846
888847 for (i = 0; i < nrpages; i++)
889848 XA_BUG_ON(xa, test_get_entry(xa, next_index + i) != &some_val_2);
890849
891− check_xa_multi_store_adv_delete(test, next_index, order);
892− check_xa_multi_store_adv_delete(test, base, order);
850+ check_xa_multi_store_adv_delete(xa, next_index, order);
851+ check_xa_multi_store_adv_delete(xa, base, order);
893852 XA_BUG_ON(xa, !xa_empty(xa));
894853
895854 /* starting fresh again */
@@ -897,7 +856,7 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 1 unmodified line
897856 /* let's test some holes now */
898857
899858 /* hole at base and next_next */
900− check_xa_multi_store_adv_add(test, next_index, order, &some_val_2);
859+ check_xa_multi_store_adv_add(xa, next_index, order, &some_val_2);
901860
902861 for (i = 0; i < nrpages; i++)
903862 XA_BUG_ON(xa, test_get_entry(xa, base + i) != NULL);
@@ -908,12 +867,12 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 4 unmodified lines
908867 for (i = 0; i < nrpages; i++)
909868 XA_BUG_ON(xa, test_get_entry(xa, next_next_index + i) != NULL);
910869
911− check_xa_multi_store_adv_delete(test, next_index, order);
870+ check_xa_multi_store_adv_delete(xa, next_index, order);
912871 XA_BUG_ON(xa, !xa_empty(xa));
913872
914873 /* hole at base and next */
915874
916− check_xa_multi_store_adv_add(test, next_next_index, order, &some_val_2);
875+ check_xa_multi_store_adv_add(xa, next_next_index, order, &some_val_2);
917876
918877 for (i = 0; i < nrpages; i++)
919878 XA_BUG_ON(xa, test_get_entry(xa, base + i) != NULL);
@@ -924,12 +883,12 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 4 unmodified lines
924883 for (i = 0; i < nrpages; i++)
925884 XA_BUG_ON(xa, test_get_entry(xa, next_next_index + i) != &some_val_2);
926885
927− check_xa_multi_store_adv_delete(test, next_next_index, order);
886+ check_xa_multi_store_adv_delete(xa, next_next_index, order);
928887 XA_BUG_ON(xa, !xa_empty(xa));
929888 }
930889 #endif
931890
932−static noinline void check_multi_store_advanced(struct kunit *test)
891+static noinline void check_multi_store_advanced(struct xarray *xa)
933892 {
934893 #ifdef CONFIG_XARRAY_MULTI
935894 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
@@ -941,59 +900,59 @@ static noinline void check_multi_store_advanced(struct kunit *test) · 5 unmodified lines
941900 */
942901 for (pos = 7; pos < end; pos = (pos * pos) + 564) {
943902 for (i = 0; i < max_order; i++) {
944− check_xa_multi_store_adv(test, pos, i);
945− check_xa_multi_store_adv(test, pos + 157, i);
903+ check_xa_multi_store_adv(xa, pos, i);
904+ check_xa_multi_store_adv(xa, pos + 157, i);
946905 }
947906 }
948907 #endif
949908 }
950909
951−static noinline void check_xa_alloc_1(struct kunit *test, struct xarray *xa, unsigned int base)
910+static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base)
952911 {
953912 int i;
954913 u32 id;
955914
956915 XA_BUG_ON(xa, !xa_empty(xa));
957916 /* An empty array should assign %base to the first alloc */
958− xa_alloc_index(test, xa, base, GFP_KERNEL);
917+ xa_alloc_index(xa, base, GFP_KERNEL);
959918
960919 /* Erasing it should make the array empty again */
961− xa_erase_index(test, xa, base);
920+ xa_erase_index(xa, base);
962921 XA_BUG_ON(xa, !xa_empty(xa));
963922
964923 /* And it should assign %base again */
965− xa_alloc_index(test, xa, base, GFP_KERNEL);
924+ xa_alloc_index(xa, base, GFP_KERNEL);
966925
967926 /* Allocating and then erasing a lot should not lose base */
968927 for (i = base + 1; i < 2 * XA_CHUNK_SIZE; i++)
969− xa_alloc_index(test, xa, i, GFP_KERNEL);
928+ xa_alloc_index(xa, i, GFP_KERNEL);
970929 for (i = base; i < 2 * XA_CHUNK_SIZE; i++)
971− xa_erase_index(test, xa, i);
972− xa_alloc_index(test, xa, base, GFP_KERNEL);
930+ xa_erase_index(xa, i);
931+ xa_alloc_index(xa, base, GFP_KERNEL);
973932
974933 /* Destroying the array should do the same as erasing */
975934 xa_destroy(xa);
976935
977936 /* And it should assign %base again */
978− xa_alloc_index(test, xa, base, GFP_KERNEL);
937+ xa_alloc_index(xa, base, GFP_KERNEL);
979938
980939 /* The next assigned ID should be base+1 */
981− xa_alloc_index(test, xa, base + 1, GFP_KERNEL);
982− xa_erase_index(test, xa, base + 1);
940+ xa_alloc_index(xa, base + 1, GFP_KERNEL);
941+ xa_erase_index(xa, base + 1);
983942
984943 /* Storing a value should mark it used */
985944 xa_store_index(xa, base + 1, GFP_KERNEL);
986− xa_alloc_index(test, xa, base + 2, GFP_KERNEL);
945+ xa_alloc_index(xa, base + 2, GFP_KERNEL);
987946
988947 /* If we then erase base, it should be free */
989− xa_erase_index(test, xa, base);
990− xa_alloc_index(test, xa, base, GFP_KERNEL);
948+ xa_erase_index(xa, base);
949+ xa_alloc_index(xa, base, GFP_KERNEL);
991950
992− xa_erase_index(test, xa, base + 1);
993− xa_erase_index(test, xa, base + 2);
951+ xa_erase_index(xa, base + 1);
952+ xa_erase_index(xa, base + 2);
994953
995954 for (i = 1; i < 5000; i++) {
996− xa_alloc_index(test, xa, base + i, GFP_KERNEL);
955+ xa_alloc_index(xa, base + i, GFP_KERNEL);
997956 }
998957
999958 xa_destroy(xa);
@@ -1016,14 +975,14 @@ static noinline void check_xa_alloc_1(struct kunit *test, struct xarray *xa, uns · 16 unmodified lines
1016975
1017976 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),
1018977 GFP_KERNEL) != -EBUSY);
1019− XA_BUG_ON(xa, xa_store_index(xa, 3, GFP_KERNEL) != NULL);
978+ XA_BUG_ON(xa, xa_store_index(xa, 3, GFP_KERNEL) != 0);
1020979 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),
1021980 GFP_KERNEL) != -EBUSY);
1022− xa_erase_index(test, xa, 3);
981+ xa_erase_index(xa, 3);
1023982 XA_BUG_ON(xa, !xa_empty(xa));
1024983 }
1025984
1026−static noinline void check_xa_alloc_2(struct kunit *test, struct xarray *xa, unsigned int base)
985+static noinline void check_xa_alloc_2(struct xarray *xa, unsigned int base)
1027986 {
1028987 unsigned int i, id;
1029988 unsigned long index;
@@ -1059,7 +1018,7 @@ static noinline void check_xa_alloc_2(struct kunit *test, struct xarray *xa, uns · 29 unmodified lines
10591018 XA_BUG_ON(xa, id != 5);
10601019
10611020 xa_for_each(xa, index, entry) {
1062− xa_erase_index(test, xa, index);
1021+ xa_erase_index(xa, index);
10631022 }
10641023
10651024 for (i = base; i < base + 9; i++) {
@@ -1074,7 +1033,7 @@ static noinline void check_xa_alloc_2(struct kunit *test, struct xarray *xa, uns · 8 unmodified lines
10741033 xa_destroy(xa);
10751034 }
10761035
1077−static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, unsigned int base)
1036+static noinline void check_xa_alloc_3(struct xarray *xa, unsigned int base)
10781037 {
10791038 struct xa_limit limit = XA_LIMIT(1, 0x3fff);
10801039 u32 next = 0;
@@ -1090,8 +1049,8 @@ static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, uns · 9 unmodified lines
10901049 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(0x3ffd), limit,
10911050 &next, GFP_KERNEL) != 0);
10921051 XA_BUG_ON(xa, id != 0x3ffd);
1093− xa_erase_index(test, xa, 0x3ffd);
1094− xa_erase_index(test, xa, 1);
1052+ xa_erase_index(xa, 0x3ffd);
1053+ xa_erase_index(xa, 1);
10951054 XA_BUG_ON(xa, !xa_empty(xa));
10961055
10971056 for (i = 0x3ffe; i < 0x4003; i++) {
@@ -1106,8 +1065,8 @@ static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, uns · 8 unmodified lines
11061065
11071066 /* Check wrap-around is handled correctly */
11081067 if (base != 0)
1109− xa_erase_index(test, xa, base);
1110− xa_erase_index(test, xa, base + 1);
1068+ xa_erase_index(xa, base);
1069+ xa_erase_index(xa, base + 1);
11111070 next = UINT_MAX;
11121071 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(UINT_MAX),
11131072 xa_limit_32b, &next, GFP_KERNEL) != 0);
@@ -1120,7 +1079,7 @@ static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, uns · 6 unmodified lines
11201079 XA_BUG_ON(xa, id != base + 1);
11211080
11221081 xa_for_each(xa, index, entry)
1123− xa_erase_index(test, xa, index);
1082+ xa_erase_index(xa, index);
11241083
11251084 XA_BUG_ON(xa, !xa_empty(xa));
11261085 }
@@ -1128,21 +1087,19 @@ static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, uns · 1 unmodified line
11281087 static DEFINE_XARRAY_ALLOC(xa0);
11291088 static DEFINE_XARRAY_ALLOC1(xa1);
11301089
1131−static noinline void check_xa_alloc(struct kunit *test)
1090+static noinline void check_xa_alloc(void)
11321091 {
1133− check_xa_alloc_1(test, &xa0, 0);
1134− check_xa_alloc_1(test, &xa1, 1);
1135− check_xa_alloc_2(test, &xa0, 0);
1136− check_xa_alloc_2(test, &xa1, 1);
1137− check_xa_alloc_3(test, &xa0, 0);
1138− check_xa_alloc_3(test, &xa1, 1);
1092+ check_xa_alloc_1(&xa0, 0);
1093+ check_xa_alloc_1(&xa1, 1);
1094+ check_xa_alloc_2(&xa0, 0);
1095+ check_xa_alloc_2(&xa1, 1);
1096+ check_xa_alloc_3(&xa0, 0);
1097+ check_xa_alloc_3(&xa1, 1);
11391098 }
11401099
1141−static noinline void __check_store_iter(struct kunit *test, unsigned long start,
1100+static noinline void __check_store_iter(struct xarray *xa, unsigned long start,
11421101 unsigned int order, unsigned int present)
11431102 {
1144− struct xarray *xa = xa_param(test);
1145−
11461103 XA_STATE_ORDER(xas, xa, start, order);
11471104 void *entry;
11481105 unsigned int count = 0;
@@ -1166,54 +1123,50 @@ retry: · 17 unmodified lines
11661123 XA_BUG_ON(xa, xa_load(xa, start) != xa_mk_index(start));
11671124 XA_BUG_ON(xa, xa_load(xa, start + (1UL << order) - 1) !=
11681125 xa_mk_index(start));
1169− xa_erase_index(test, xa, start);
1126+ xa_erase_index(xa, start);
11701127 }
11711128
1172−static noinline void check_store_iter(struct kunit *test)
1129+static noinline void check_store_iter(struct xarray *xa)
11731130 {
1174− struct xarray *xa = xa_param(test);
1175−
11761131 unsigned int i, j;
11771132 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
11781133
11791134 for (i = 0; i < max_order; i++) {
11801135 unsigned int min = 1 << i;
11811136 unsigned int max = (2 << i) - 1;
1182− __check_store_iter(test, 0, i, 0);
1137+ __check_store_iter(xa, 0, i, 0);
11831138 XA_BUG_ON(xa, !xa_empty(xa));
1184− __check_store_iter(test, min, i, 0);
1139+ __check_store_iter(xa, min, i, 0);
11851140 XA_BUG_ON(xa, !xa_empty(xa));
11861141
11871142 xa_store_index(xa, min, GFP_KERNEL);
1188− __check_store_iter(test, min, i, 1);
1143+ __check_store_iter(xa, min, i, 1);
11891144 XA_BUG_ON(xa, !xa_empty(xa));
11901145 xa_store_index(xa, max, GFP_KERNEL);
1191− __check_store_iter(test, min, i, 1);
1146+ __check_store_iter(xa, min, i, 1);
11921147 XA_BUG_ON(xa, !xa_empty(xa));
11931148
11941149 for (j = 0; j < min; j++)
11951150 xa_store_index(xa, j, GFP_KERNEL);
1196− __check_store_iter(test, 0, i, min);
1151+ __check_store_iter(xa, 0, i, min);
11971152 XA_BUG_ON(xa, !xa_empty(xa));
11981153 for (j = 0; j < min; j++)
11991154 xa_store_index(xa, min + j, GFP_KERNEL);
1200− __check_store_iter(test, min, i, min);
1155+ __check_store_iter(xa, min, i, min);
12011156 XA_BUG_ON(xa, !xa_empty(xa));
12021157 }
12031158 #ifdef CONFIG_XARRAY_MULTI
12041159 xa_store_index(xa, 63, GFP_KERNEL);
12051160 xa_store_index(xa, 65, GFP_KERNEL);
1206− __check_store_iter(test, 64, 2, 1);
1207− xa_erase_index(test, xa, 63);
1161+ __check_store_iter(xa, 64, 2, 1);
1162+ xa_erase_index(xa, 63);
12081163 #endif
12091164 XA_BUG_ON(xa, !xa_empty(xa));
12101165 }
12111166
1212−static noinline void check_multi_find_1(struct kunit *test, unsigned int order)
1167+static noinline void check_multi_find_1(struct xarray *xa, unsigned order)
12131168 {
12141169 #ifdef CONFIG_XARRAY_MULTI
1215− struct xarray *xa = xa_param(test);
1216−
12171170 unsigned long multi = 3 << order;
12181171 unsigned long next = 4 << order;
12191172 unsigned long index;
@@ -1236,17 +1189,15 @@ static noinline void check_multi_find_1(struct kunit *test, unsigned int order) · 16 unmodified lines
12361189 XA_BUG_ON(xa, xa_find_after(xa, &index, next, XA_PRESENT) != NULL);
12371190 XA_BUG_ON(xa, index != next);
12381191
1239− xa_erase_index(test, xa, multi);
1240− xa_erase_index(test, xa, next);
1241− xa_erase_index(test, xa, next + 1);
1192+ xa_erase_index(xa, multi);
1193+ xa_erase_index(xa, next);
1194+ xa_erase_index(xa, next + 1);
12421195 XA_BUG_ON(xa, !xa_empty(xa));
12431196 #endif
12441197 }
12451198
1246−static noinline void check_multi_find_2(struct kunit *test)
1199+static noinline void check_multi_find_2(struct xarray *xa)
12471200 {
1248− struct xarray *xa = xa_param(test);
1249−
12501201 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 10 : 1;
12511202 unsigned int i, j;
12521203 void *entry;
@@ -1260,19 +1211,17 @@ static noinline void check_multi_find_2(struct kunit *test) · 7 unmodified lines
12601211 GFP_KERNEL);
12611212 rcu_read_lock();
12621213 xas_for_each(&xas, entry, ULONG_MAX) {
1263− xa_erase_index(test, xa, index);
1214+ xa_erase_index(xa, index);
12641215 }
12651216 rcu_read_unlock();
1266− xa_erase_index(test, xa, index - 1);
1217+ xa_erase_index(xa, index - 1);
12671218 XA_BUG_ON(xa, !xa_empty(xa));
12681219 }
12691220 }
12701221 }
12711222
1272−static noinline void check_multi_find_3(struct kunit *test)
1223+static noinline void check_multi_find_3(struct xarray *xa)
12731224 {
1274− struct xarray *xa = xa_param(test);
1275−
12761225 unsigned int order;
12771226
12781227 for (order = 5; order < order_limit; order++) {
@@ -1281,14 +1230,12 @@ static noinline void check_multi_find_3(struct kunit *test) · 2 unmodified lines
12811230 XA_BUG_ON(xa, !xa_empty(xa));
12821231 xa_store_order(xa, 0, order - 4, xa_mk_index(0), GFP_KERNEL);
12831232 XA_BUG_ON(xa, xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT));
1284− xa_erase_index(test, xa, 0);
1233+ xa_erase_index(xa, 0);
12851234 }
12861235 }
12871236
1288−static noinline void check_find_1(struct kunit *test)
1237+static noinline void check_find_1(struct xarray *xa)
12891238 {
1290− struct xarray *xa = xa_param(test);
1291−
12921239 unsigned long i, j, k;
12931240
12941241 XA_BUG_ON(xa, !xa_empty(xa));
@@ -1325,20 +1272,18 @@ static noinline void check_find_1(struct kunit *test) · 30 unmodified lines
13251272 else
13261273 XA_BUG_ON(xa, entry != NULL);
13271274 }
1328− xa_erase_index(test, xa, j);
1275+ xa_erase_index(xa, j);
13291276 XA_BUG_ON(xa, xa_get_mark(xa, j, XA_MARK_0));
13301277 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0));
13311278 }
1332− xa_erase_index(test, xa, i);
1279+ xa_erase_index(xa, i);
13331280 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_0));
13341281 }
13351282 XA_BUG_ON(xa, !xa_empty(xa));
13361283 }
13371284
1338−static noinline void check_find_2(struct kunit *test)
1285+static noinline void check_find_2(struct xarray *xa)
13391286 {
1340− struct xarray *xa = xa_param(test);
1341−
13421287 void *entry;
13431288 unsigned long i, j, index;
13441289
@@ -1358,10 +1303,8 @@ static noinline void check_find_2(struct kunit *test) · 13 unmodified lines
13581303 xa_destroy(xa);
13591304 }
13601305
1361−static noinline void check_find_3(struct kunit *test)
1306+static noinline void check_find_3(struct xarray *xa)
13621307 {
1363− struct xarray *xa = xa_param(test);
1364−
13651308 XA_STATE(xas, xa, 0);
13661309 unsigned long i, j, k;
13671310 void *entry;
@@ -1385,10 +1328,8 @@ static noinline void check_find_3(struct kunit *test) · 17 unmodified lines
13851328 xa_destroy(xa);
13861329 }
13871330
1388−static noinline void check_find_4(struct kunit *test)
1331+static noinline void check_find_4(struct xarray *xa)
13891332 {
1390− struct xarray *xa = xa_param(test);
1391−
13921333 unsigned long index = 0;
13931334 void *entry;
13941335
@@ -1400,22 +1341,22 @@ static noinline void check_find_4(struct kunit *test) · 5 unmodified lines
14001341 entry = xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT);
14011342 XA_BUG_ON(xa, entry);
14021343
1403− xa_erase_index(test, xa, ULONG_MAX);
1344+ xa_erase_index(xa, ULONG_MAX);
14041345 }
14051346
1406−static noinline void check_find(struct kunit *test)
1347+static noinline void check_find(struct xarray *xa)
14071348 {
14081349 unsigned i;
14091350
1410− check_find_1(test);
1411− check_find_2(test);
1412− check_find_3(test);
1413− check_find_4(test);
1351+ check_find_1(xa);
1352+ check_find_2(xa);
1353+ check_find_3(xa);
1354+ check_find_4(xa);
14141355
14151356 for (i = 2; i < 10; i++)
1416− check_multi_find_1(test, i);
1417− check_multi_find_2(test);
1418− check_multi_find_3(test);
1357+ check_multi_find_1(xa, i);
1358+ check_multi_find_2(xa);
1359+ check_multi_find_3(xa);
14191360 }
14201361
14211362 /* See find_swap_entry() in mm/shmem.c */
@@ -1441,10 +1382,8 @@ static noinline unsigned long xa_find_entry(struct xarray *xa, void *item) · 19 unmodified lines
14411382 return entry ? xas.xa_index : -1;
14421383 }
14431384
1444−static noinline void check_find_entry(struct kunit *test)
1385+static noinline void check_find_entry(struct xarray *xa)
14451386 {
1446− struct xarray *xa = xa_param(test);
1447−
14481387 #ifdef CONFIG_XARRAY_MULTI
14491388 unsigned int order;
14501389 unsigned long offset, index;
@@ -1471,14 +1410,12 @@ static noinline void check_find_entry(struct kunit *test) · 20 unmodified lines
14711410 xa_store_index(xa, ULONG_MAX, GFP_KERNEL);
14721411 XA_BUG_ON(xa, xa_find_entry(xa, xa) != -1);
14731412 XA_BUG_ON(xa, xa_find_entry(xa, xa_mk_index(ULONG_MAX)) != -1);
1474− xa_erase_index(test, xa, ULONG_MAX);
1413+ xa_erase_index(xa, ULONG_MAX);
14751414 XA_BUG_ON(xa, !xa_empty(xa));
14761415 }
14771416
1478−static noinline void check_pause(struct kunit *test)
1417+static noinline void check_pause(struct xarray *xa)
14791418 {
1480− struct xarray *xa = xa_param(test);
1481−
14821419 XA_STATE(xas, xa, 0);
14831420 void *entry;
14841421 unsigned int order;
@@ -1548,10 +1485,8 @@ static noinline void check_pause(struct kunit *test) · 63 unmodified lines
15481485
15491486 }
15501487
1551−static noinline void check_move_tiny(struct kunit *test)
1488+static noinline void check_move_tiny(struct xarray *xa)
15521489 {
1553− struct xarray *xa = xa_param(test);
1554−
15551490 XA_STATE(xas, xa, 0);
15561491
15571492 XA_BUG_ON(xa, !xa_empty(xa));
@@ -1568,14 +1503,12 @@ static noinline void check_move_tiny(struct kunit *test) · 10 unmodified lines
15681503 XA_BUG_ON(xa, xas_prev(&xas) != xa_mk_index(0));
15691504 XA_BUG_ON(xa, xas_prev(&xas) != NULL);
15701505 rcu_read_unlock();
1571− xa_erase_index(test, xa, 0);
1506+ xa_erase_index(xa, 0);
15721507 XA_BUG_ON(xa, !xa_empty(xa));
15731508 }
15741509
1575−static noinline void check_move_max(struct kunit *test)
1510+static noinline void check_move_max(struct xarray *xa)
15761511 {
1577− struct xarray *xa = xa_param(test);
1578−
15791512 XA_STATE(xas, xa, 0);
15801513
15811514 xa_store_index(xa, ULONG_MAX, GFP_KERNEL);
@@ -1591,14 +1524,12 @@ static noinline void check_move_max(struct kunit *test) · 9 unmodified lines
15911524 XA_BUG_ON(xa, xas_find(&xas, ULONG_MAX) != NULL);
15921525 rcu_read_unlock();
15931526
1594− xa_erase_index(test, xa, ULONG_MAX);
1527+ xa_erase_index(xa, ULONG_MAX);
15951528 XA_BUG_ON(xa, !xa_empty(xa));
15961529 }
15971530
1598−static noinline void check_move_small(struct kunit *test, unsigned long idx)
1531+static noinline void check_move_small(struct xarray *xa, unsigned long idx)
15991532 {
1600− struct xarray *xa = xa_param(test);
1601−
16021533 XA_STATE(xas, xa, 0);
16031534 unsigned long i;
16041535
@@ -1640,15 +1571,13 @@ static noinline void check_move_small(struct kunit *test, unsigned long idx) · 35 unmodified lines
16401571 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX);
16411572 rcu_read_unlock();
16421573
1643− xa_erase_index(test, xa, 0);
1644− xa_erase_index(test, xa, idx);
1574+ xa_erase_index(xa, 0);
1575+ xa_erase_index(xa, idx);
16451576 XA_BUG_ON(xa, !xa_empty(xa));
16461577 }
16471578
1648−static noinline void check_move(struct kunit *test)
1579+static noinline void check_move(struct xarray *xa)
16491580 {
1650− struct xarray *xa = xa_param(test);
1651−
16521581 XA_STATE(xas, xa, (1 << 16) - 1);
16531582 unsigned long i;
16541583
@@ -1675,7 +1604,7 @@ static noinline void check_move(struct kunit *test) · 20 unmodified lines
16751604 rcu_read_unlock();
16761605
16771606 for (i = (1 << 8); i < (1 << 15); i++)
1678− xa_erase_index(test, xa, i);
1607+ xa_erase_index(xa, i);
16791608
16801609 i = xas.xa_index;
16811610
@@ -1706,17 +1635,17 @@ static noinline void check_move(struct kunit *test) · 24 unmodified lines
17061635
17071636 xa_destroy(xa);
17081637
1709− check_move_tiny(test);
1710− check_move_max(test);
1638+ check_move_tiny(xa);
1639+ check_move_max(xa);
17111640
17121641 for (i = 0; i < 16; i++)
1713− check_move_small(test, 1UL << i);
1642+ check_move_small(xa, 1UL << i);
17141643
17151644 for (i = 2; i < 16; i++)
1716− check_move_small(test, (1UL << i) - 1);
1645+ check_move_small(xa, (1UL << i) - 1);
17171646 }
17181647
1719−static noinline void xa_store_many_order(struct kunit *test, struct xarray *xa,
1648+static noinline void xa_store_many_order(struct xarray *xa,
17201649 unsigned long index, unsigned order)
17211650 {
17221651 XA_STATE_ORDER(xas, xa, index, order);
@@ -1739,34 +1668,30 @@ unlock: · 16 unmodified lines
17391668 XA_BUG_ON(xa, xas_error(&xas));
17401669 }
17411670
1742−static noinline void check_create_range_1(struct kunit *test,
1671+static noinline void check_create_range_1(struct xarray *xa,
17431672 unsigned long index, unsigned order)
17441673 {
1745− struct xarray *xa = xa_param(test);
1746−
17471674 unsigned long i;
17481675
1749− xa_store_many_order(test, xa, index, order);
1676+ xa_store_many_order(xa, index, order);
17501677 for (i = index; i < index + (1UL << order); i++)
1751− xa_erase_index(test, xa, i);
1678+ xa_erase_index(xa, i);
17521679 XA_BUG_ON(xa, !xa_empty(xa));
17531680 }
17541681
1755−static noinline void check_create_range_2(struct kunit *test, unsigned int order)
1682+static noinline void check_create_range_2(struct xarray *xa, unsigned order)
17561683 {
1757− struct xarray *xa = xa_param(test);
1758−
17591684 unsigned long i;
17601685 unsigned long nr = 1UL << order;
17611686
17621687 for (i = 0; i < nr * nr; i += nr)
1763− xa_store_many_order(test, xa, i, order);
1688+ xa_store_many_order(xa, i, order);
17641689 for (i = 0; i < nr * nr; i++)
1765− xa_erase_index(test, xa, i);
1690+ xa_erase_index(xa, i);
17661691 XA_BUG_ON(xa, !xa_empty(xa));
17671692 }
17681693
1769−static noinline void check_create_range_3(struct kunit *test)
1694+static noinline void check_create_range_3(void)
17701695 {
17711696 XA_STATE(xas, NULL, 0);
17721697 xas_set_err(&xas, -EEXIST);
@@ -1774,11 +1699,9 @@ static noinline void check_create_range_3(struct kunit *test) · 1 unmodified line
17741699 XA_BUG_ON(NULL, xas_error(&xas) != -EEXIST);
17751700 }
17761701
1777−static noinline void check_create_range_4(struct kunit *test,
1702+static noinline void check_create_range_4(struct xarray *xa,
17781703 unsigned long index, unsigned order)
17791704 {
1780− struct xarray *xa = xa_param(test);
1781−
17821705 XA_STATE_ORDER(xas, xa, index, order);
17831706 unsigned long base = xas.xa_index;
17841707 unsigned long i = 0;
@@ -1804,15 +1727,13 @@ unlock: · 19 unmodified lines
18041727 XA_BUG_ON(xa, xas_error(&xas));
18051728
18061729 for (i = base; i < base + (1UL << order); i++)
1807− xa_erase_index(test, xa, i);
1730+ xa_erase_index(xa, i);
18081731 XA_BUG_ON(xa, !xa_empty(xa));
18091732 }
18101733
1811−static noinline void check_create_range_5(struct kunit *test,
1734+static noinline void check_create_range_5(struct xarray *xa,
18121735 unsigned long index, unsigned int order)
18131736 {
1814− struct xarray *xa = xa_param(test);
1815−
18161737 XA_STATE_ORDER(xas, xa, index, order);
18171738 unsigned int i;
18181739
@@ -1829,46 +1750,44 @@ static noinline void check_create_range_5(struct kunit *test, · 10 unmodified lines
18291750 xa_destroy(xa);
18301751 }
18311752
1832−static noinline void check_create_range(struct kunit *test)
1753+static noinline void check_create_range(struct xarray *xa)
18331754 {
18341755 unsigned int order;
18351756 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 12 : 1;
18361757
18371758 for (order = 0; order < max_order; order++) {
1838− check_create_range_1(test, 0, order);
1839− check_create_range_1(test, 1U << order, order);
1840− check_create_range_1(test, 2U << order, order);
1841− check_create_range_1(test, 3U << order, order);
1842− check_create_range_1(test, 1U << 24, order);
1759+ check_create_range_1(xa, 0, order);
1760+ check_create_range_1(xa, 1U << order, order);
1761+ check_create_range_1(xa, 2U << order, order);
1762+ check_create_range_1(xa, 3U << order, order);
1763+ check_create_range_1(xa, 1U << 24, order);
18431764 if (order < 10)
1844− check_create_range_2(test, order);
1845−
1846− check_create_range_4(test, 0, order);
1847− check_create_range_4(test, 1U << order, order);
1848− check_create_range_4(test, 2U << order, order);
1849− check_create_range_4(test, 3U << order, order);
1850− check_create_range_4(test, 1U << 24, order);
1851−
1852− check_create_range_4(test, 1, order);
1853− check_create_range_4(test, (1U << order) + 1, order);
1854− check_create_range_4(test, (2U << order) + 1, order);
1855− check_create_range_4(test, (2U << order) - 1, order);
1856− check_create_range_4(test, (3U << order) + 1, order);
1857− check_create_range_4(test, (3U << order) - 1, order);
1858− check_create_range_4(test, (1U << 24) + 1, order);
1859−
1860− check_create_range_5(test, 0, order);
1861− check_create_range_5(test, (1U << order), order);
1765+ check_create_range_2(xa, order);
1766+
1767+ check_create_range_4(xa, 0, order);
1768+ check_create_range_4(xa, 1U << order, order);
1769+ check_create_range_4(xa, 2U << order, order);
1770+ check_create_range_4(xa, 3U << order, order);
1771+ check_create_range_4(xa, 1U << 24, order);
1772+
1773+ check_create_range_4(xa, 1, order);
1774+ check_create_range_4(xa, (1U << order) + 1, order);
1775+ check_create_range_4(xa, (2U << order) + 1, order);
1776+ check_create_range_4(xa, (2U << order) - 1, order);
1777+ check_create_range_4(xa, (3U << order) + 1, order);
1778+ check_create_range_4(xa, (3U << order) - 1, order);
1779+ check_create_range_4(xa, (1U << 24) + 1, order);
1780+
1781+ check_create_range_5(xa, 0, order);
1782+ check_create_range_5(xa, (1U << order), order);
18621783 }
18631784
1864− check_create_range_3(test);
1785+ check_create_range_3();
18651786 }
18661787
1867−static noinline void __check_store_range(struct kunit *test, unsigned long first,
1788+static noinline void __check_store_range(struct xarray *xa, unsigned long first,
18681789 unsigned long last)
18691790 {
1870− struct xarray *xa = xa_param(test);
1871−
18721791 #ifdef CONFIG_XARRAY_MULTI
18731792 xa_store_range(xa, first, last, xa_mk_index(first), GFP_KERNEL);
18741793
@@ -1883,28 +1802,26 @@ static noinline void __check_store_range(struct kunit *test, unsigned long first · 8 unmodified lines
18831802 XA_BUG_ON(xa, !xa_empty(xa));
18841803 }
18851804
1886−static noinline void check_store_range(struct kunit *test)
1805+static noinline void check_store_range(struct xarray *xa)
18871806 {
18881807 unsigned long i, j;
18891808
18901809 for (i = 0; i < 128; i++) {
18911810 for (j = i; j < 128; j++) {
1892− __check_store_range(test, i, j);
1893− __check_store_range(test, 128 + i, 128 + j);
1894− __check_store_range(test, 4095 + i, 4095 + j);
1895− __check_store_range(test, 4096 + i, 4096 + j);
1896− __check_store_range(test, 123456 + i, 123456 + j);
1897− __check_store_range(test, (1 << 24) + i, (1 << 24) + j);
1811+ __check_store_range(xa, i, j);
1812+ __check_store_range(xa, 128 + i, 128 + j);
1813+ __check_store_range(xa, 4095 + i, 4095 + j);
1814+ __check_store_range(xa, 4096 + i, 4096 + j);
1815+ __check_store_range(xa, 123456 + i, 123456 + j);
1816+ __check_store_range(xa, (1 << 24) + i, (1 << 24) + j);
18981817 }
18991818 }
19001819 }
19011820
19021821 #ifdef CONFIG_XARRAY_MULTI
1903−static void check_split_1(struct kunit *test, unsigned long index,
1822+static void check_split_1(struct xarray *xa, unsigned long index,
19041823 unsigned int order, unsigned int new_order)
19051824 {
1906− struct xarray *xa = xa_param(test);
1907−
19081825 XA_STATE_ORDER(xas, xa, index, new_order);
19091826 unsigned int i, found;
19101827 void *entry;
@@ -1940,30 +1857,26 @@ static void check_split_1(struct kunit *test, unsigned long index, · 29 unmodified lines
19401857 xa_destroy(xa);
19411858 }
19421859
1943−static noinline void check_split(struct kunit *test)
1860+static noinline void check_split(struct xarray *xa)
19441861 {
1945− struct xarray *xa = xa_param(test);
1946−
19471862 unsigned int order, new_order;
19481863
19491864 XA_BUG_ON(xa, !xa_empty(xa));
19501865
19511866 for (order = 1; order < 2 * XA_CHUNK_SHIFT; order++) {
19521867 for (new_order = 0; new_order < order; new_order++) {
1953− check_split_1(test, 0, order, new_order);
1954− check_split_1(test, 1UL << order, order, new_order);
1955− check_split_1(test, 3UL << order, order, new_order);
1868+ check_split_1(xa, 0, order, new_order);
1869+ check_split_1(xa, 1UL << order, order, new_order);
1870+ check_split_1(xa, 3UL << order, order, new_order);
19561871 }
19571872 }
19581873 }
19591874 #else
1960−static void check_split(struct kunit *test) { }
1875+static void check_split(struct xarray *xa) { }
19611876 #endif
19621877
1963−static void check_align_1(struct kunit *test, char *name)
1878+static void check_align_1(struct xarray *xa, char *name)
19641879 {
1965− struct xarray *xa = xa_param(test);
1966−
19671880 int i;
19681881 unsigned int id;
19691882 unsigned long index;
@@ -1983,10 +1896,8 @@ static void check_align_1(struct kunit *test, char *name) · 13 unmodified lines
19831896 * We should always be able to store without allocating memory after
19841897 * reserving a slot.
19851898 */
1986−static void check_align_2(struct kunit *test, char *name)
1899+static void check_align_2(struct xarray *xa, char *name)
19871900 {
1988− struct xarray *xa = xa_param(test);
1989−
19901901 int i;
19911902
19921903 XA_BUG_ON(xa, !xa_empty(xa));
@@ -2005,15 +1916,15 @@ static void check_align_2(struct kunit *test, char *name) · 12 unmodified lines
20051916 XA_BUG_ON(xa, !xa_empty(xa));
20061917 }
20071918
2008−static noinline void check_align(struct kunit *test)
1919+static noinline void check_align(struct xarray *xa)
20091920 {
20101921 char name[] = "Motorola 68000";
20111922
2012− check_align_1(test, name);
2013− check_align_1(test, name + 1);
2014− check_align_1(test, name + 2);
2015− check_align_1(test, name + 3);
2016− check_align_2(test, name);
1923+ check_align_1(xa, name);
1924+ check_align_1(xa, name + 1);
1925+ check_align_1(xa, name + 2);
1926+ check_align_1(xa, name + 3);
1927+ check_align_2(xa, name);
20171928 }
20181929
20191930 static LIST_HEAD(shadow_nodes);
@@ -2029,7 +1940,7 @@ static void test_update_node(struct xa_node *node) · 9 unmodified lines
20291940 }
20301941 }
20311942
2032−static noinline void shadow_remove(struct kunit *test, struct xarray *xa)
1943+static noinline void shadow_remove(struct xarray *xa)
20331944 {
20341945 struct xa_node *node;
20351946
@@ -2043,17 +1954,8 @@ static noinline void shadow_remove(struct kunit *test, struct xarray *xa) · 7 unmodified lines
20431954 xa_unlock(xa);
20441955 }
20451956
2046−struct workingset_testcase {
2047− struct xarray *xa;
2048− unsigned long index;
2049−};
2050−
2051−static noinline void check_workingset(struct kunit *test)
1957+static noinline void check_workingset(struct xarray *xa, unsigned long index)
20521958 {
2053− struct workingset_testcase tc = *(struct workingset_testcase *)test->param_value;
2054− struct xarray *xa = tc.xa;
2055− unsigned long index = tc.index;
2056−
20571959 XA_STATE(xas, xa, index);
20581960 xas_set_update(&xas, test_update_node);
20591961
@@ -2076,7 +1978,7 @@ static noinline void check_workingset(struct kunit *test) · 16 unmodified lines
20761978 xas_unlock(&xas);
20771979 XA_BUG_ON(xa, list_empty(&shadow_nodes));
20781980
2079− shadow_remove(test, xa);
1981+ shadow_remove(xa);
20801982 XA_BUG_ON(xa, !list_empty(&shadow_nodes));
20811983 XA_BUG_ON(xa, !xa_empty(xa));
20821984 }
@@ -2085,11 +1987,9 @@ static noinline void check_workingset(struct kunit *test) · 2 unmodified lines
20851987 * Check that the pointer / value / sibling entries are accounted the
20861988 * way we expect them to be.
20871989 */
2088−static noinline void check_account(struct kunit *test)
1990+static noinline void check_account(struct xarray *xa)
20891991 {
20901992 #ifdef CONFIG_XARRAY_MULTI
2091− struct xarray *xa = xa_param(test);
2092−
20931993 unsigned int order;
20941994
20951995 for (order = 1; order < 12; order++) {
@@ -2116,10 +2016,8 @@ static noinline void check_account(struct kunit *test) · 20 unmodified lines
21162016 #endif
21172017 }
21182018
2119−static noinline void check_get_order(struct kunit *test)
2019+static noinline void check_get_order(struct xarray *xa)
21202020 {
2121− struct xarray *xa = xa_param(test);
2122−
21232021 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
21242022 unsigned int order;
21252023 unsigned long i, j;
@@ -2138,10 +2036,8 @@ static noinline void check_get_order(struct kunit *test) · 12 unmodified lines
21382036 }
21392037 }
21402038
2141−static noinline void check_xas_get_order(struct kunit *test)
2039+static noinline void check_xas_get_order(struct xarray *xa)
21422040 {
2143− struct xarray *xa = xa_param(test);
2144−
21452041 XA_STATE(xas, xa, 0);
21462042
21472043 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
@@ -2173,10 +2069,8 @@ static noinline void check_xas_get_order(struct kunit *test) · 25 unmodified lines
21732069 }
21742070 }
21752071
2176−static noinline void check_xas_conflict_get_order(struct kunit *test)
2072+static noinline void check_xas_conflict_get_order(struct xarray *xa)
21772073 {
2178− struct xarray *xa = xa_param(test);
2179−
21802074 XA_STATE(xas, xa, 0);
21812075
21822076 void *entry;
@@ -2233,10 +2127,8 @@ static noinline void check_xas_conflict_get_order(struct kunit *test) · 50 unmodified lines
22332127 }
22342128
22352129
2236−static noinline void check_destroy(struct kunit *test)
2130+static noinline void check_destroy(struct xarray *xa)
22372131 {
2238− struct xarray *xa = xa_param(test);
2239−
22402132 unsigned long index;
22412133
22422134 XA_BUG_ON(xa, !xa_empty(xa));
@@ -2269,59 +2161,52 @@ static noinline void check_destroy(struct kunit *test) · 26 unmodified lines
22692161 }
22702162
22712163 static DEFINE_XARRAY(array);
2272−static struct xarray *arrays[] = { &array };
2273−KUNIT_ARRAY_PARAM(array, arrays, NULL);
2274−
2275−static struct xarray *xa0s[] = { &xa0 };
2276−KUNIT_ARRAY_PARAM(xa0, xa0s, NULL);
2277−
2278−static struct workingset_testcase workingset_testcases[] = {
2279− { &array, 0 },
2280− { &array, 64 },
2281− { &array, 4096 },
2282−};
2283−KUNIT_ARRAY_PARAM(workingset, workingset_testcases, NULL);
2284−
2285−static struct kunit_case xarray_cases[] = {
2286− KUNIT_CASE_PARAM(check_xa_err, array_gen_params),
2287− KUNIT_CASE_PARAM(check_xas_retry, array_gen_params),
2288− KUNIT_CASE_PARAM(check_xa_load, array_gen_params),
2289− KUNIT_CASE_PARAM(check_xa_mark, array_gen_params),
2290− KUNIT_CASE_PARAM(check_xa_shrink, array_gen_params),
2291− KUNIT_CASE_PARAM(check_xas_erase, array_gen_params),
2292− KUNIT_CASE_PARAM(check_insert, array_gen_params),
2293− KUNIT_CASE_PARAM(check_cmpxchg, array_gen_params),
2294− KUNIT_CASE_PARAM(check_cmpxchg_order, array_gen_params),
2295− KUNIT_CASE_PARAM(check_reserve, array_gen_params),
2296− KUNIT_CASE_PARAM(check_reserve, xa0_gen_params),
2297− KUNIT_CASE_PARAM(check_multi_store, array_gen_params),
2298− KUNIT_CASE_PARAM(check_multi_store_advanced, array_gen_params),
2299− KUNIT_CASE_PARAM(check_get_order, array_gen_params),
2300− KUNIT_CASE_PARAM(check_xas_get_order, array_gen_params),
2301− KUNIT_CASE_PARAM(check_xas_conflict_get_order, array_gen_params),
2302− KUNIT_CASE(check_xa_alloc),
2303− KUNIT_CASE_PARAM(check_find, array_gen_params),
2304− KUNIT_CASE_PARAM(check_find_entry, array_gen_params),
2305− KUNIT_CASE_PARAM(check_pause, array_gen_params),
2306− KUNIT_CASE_PARAM(check_account, array_gen_params),
2307− KUNIT_CASE_PARAM(check_destroy, array_gen_params),
2308− KUNIT_CASE_PARAM(check_move, array_gen_params),
2309− KUNIT_CASE_PARAM(check_create_range, array_gen_params),
2310− KUNIT_CASE_PARAM(check_store_range, array_gen_params),
2311− KUNIT_CASE_PARAM(check_store_iter, array_gen_params),
2312− KUNIT_CASE_PARAM(check_align, xa0_gen_params),
2313− KUNIT_CASE_PARAM(check_split, array_gen_params),
2314− KUNIT_CASE_PARAM(check_workingset, workingset_gen_params),
2315− {},
2316−};
2317−
2318−static struct kunit_suite xarray_suite = {
2319− .name = "xarray",
2320− .test_cases = xarray_cases,
2321−};
2322−
2323−kunit_test_suite(xarray_suite);
23242164
2165+static int xarray_checks(void)
2166+{
2167+ check_xa_err(&array);
2168+ check_xas_retry(&array);
2169+ check_xa_load(&array);
2170+ check_xa_mark(&array);
2171+ check_xa_shrink(&array);
2172+ check_xas_erase(&array);
2173+ check_insert(&array);
2174+ check_cmpxchg(&array);
2175+ check_cmpxchg_order(&array);
2176+ check_reserve(&array);
2177+ check_reserve(&xa0);
2178+ check_multi_store(&array);
2179+ check_multi_store_advanced(&array);
2180+ check_get_order(&array);
2181+ check_xas_get_order(&array);
2182+ check_xas_conflict_get_order(&array);
2183+ check_xa_alloc();
2184+ check_find(&array);
2185+ check_find_entry(&array);
2186+ check_pause(&array);
2187+ check_account(&array);
2188+ check_destroy(&array);
2189+ check_move(&array);
2190+ check_create_range(&array);
2191+ check_store_range(&array);
2192+ check_store_iter(&array);
2193+ check_align(&xa0);
2194+ check_split(&array);
2195+
2196+ check_workingset(&array, 0);
2197+ check_workingset(&array, 64);
2198+ check_workingset(&array, 4096);
2199+
2200+ printk("XArray: %u of %u tests passed\n", tests_passed, tests_run);
2201+ return (tests_run == tests_passed) ? 0 : -EINVAL;
2202+}
2203+
2204+static void xarray_exit(void)
2205+{
2206+}
2207+
2208+module_init(xarray_checks);
2209+module_exit(xarray_exit);
23252210 MODULE_AUTHOR("Matthew Wilcox <willy@infradead.org>");
23262211 MODULE_DESCRIPTION("XArray API test module");
23272212 MODULE_LICENSE("GPL");
mm/compaction.c+25−4
@@ -2491,7 +2491,8 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, · 2490 unmodified lines
24912491 */
24922492 static enum compact_result
24932493 compaction_suit_allocation_order(struct zone *zone, unsigned int order,
2494− int highest_zoneidx, unsigned int alloc_flags)
2494+ int highest_zoneidx, unsigned int alloc_flags,
2495+ bool async)
24952496 {
24962497 unsigned long watermark;
24972498
@@ -2500,6 +2501,23 @@ compaction_suit_allocation_order(struct zone *zone, unsigned int order, · 2 unmodified lines
25002501 alloc_flags))
25012502 return COMPACT_SUCCESS;
25022503
2504+ /*
2505+ * For unmovable allocations (without ALLOC_CMA), check if there is enough
2506+ * free memory in the non-CMA pageblocks. Otherwise compaction could form
2507+ * the high-order page in CMA pageblocks, which would not help the
2508+ * allocation to succeed. However, limit the check to costly order async
2509+ * compaction (such as opportunistic THP attempts) because there is the
2510+ * possibility that compaction would migrate pages from non-CMA to CMA
2511+ * pageblock.
2512+ */
2513+ if (order > PAGE_ALLOC_COSTLY_ORDER && async &&
2514+ !(alloc_flags & ALLOC_CMA)) {
2515+ watermark = low_wmark_pages(zone) + compact_gap(order);
2516+ if (!__zone_watermark_ok(zone, 0, watermark, highest_zoneidx,
2517+ 0, zone_page_state(zone, NR_FREE_PAGES)))
2518+ return COMPACT_SKIPPED;
2519+ }
2520+
25032521 if (!compaction_suitable(zone, order, highest_zoneidx))
25042522 return COMPACT_SKIPPED;
25052523
@@ -2535,7 +2553,8 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) · 29 unmodified lines
25352553 if (!is_via_compact_memory(cc->order)) {
25362554 ret = compaction_suit_allocation_order(cc->zone, cc->order,
25372555 cc->highest_zoneidx,
2538− cc->alloc_flags);
2556+ cc->alloc_flags,
2557+ cc->mode == MIGRATE_ASYNC);
25392558 if (ret != COMPACT_CONTINUE)
25402559 return ret;
25412560 }
@@ -3038,7 +3057,8 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat) · 496 unmodified lines
30383057
30393058 ret = compaction_suit_allocation_order(zone,
30403059 pgdat->kcompactd_max_order,
3041− highest_zoneidx, ALLOC_WMARK_MIN);
3060+ highest_zoneidx, ALLOC_WMARK_MIN,
3061+ false);
30423062 if (ret == COMPACT_CONTINUE)
30433063 return true;
30443064 }
@@ -3079,7 +3099,8 @@ static void kcompactd_do_work(pg_data_t *pgdat) · 34 unmodified lines
30793099 continue;
30803100
30813101 ret = compaction_suit_allocation_order(zone,
3082− cc.order, zoneid, ALLOC_WMARK_MIN);
3102+ cc.order, zoneid, ALLOC_WMARK_MIN,
3103+ false);
30833104 if (ret != COMPACT_CONTINUE)
30843105 continue;
30853106
mm/gup.c+4−10
@@ -2320,13 +2320,13 @@ static void pofs_unpin(struct pages_or_folios *pofs) · 2319 unmodified lines
23202320 /*
23212321 * Returns the number of collected folios. Return value is always >= 0.
23222322 */
2323−static unsigned long collect_longterm_unpinnable_folios(
2323+static void collect_longterm_unpinnable_folios(
23242324 struct list_head *movable_folio_list,
23252325 struct pages_or_folios *pofs)
23262326 {
2327− unsigned long i, collected = 0;
23282327 struct folio *prev_folio = NULL;
23292328 bool drain_allow = true;
2329+ unsigned long i;
23302330
23312331 for (i = 0; i < pofs->nr_entries; i++) {
23322332 struct folio *folio = pofs_get_folio(pofs, i);
@@ -2338,8 +2338,6 @@ static unsigned long collect_longterm_unpinnable_folios( · 5 unmodified lines
23382338 if (folio_is_longterm_pinnable(folio))
23392339 continue;
23402340
2341− collected++;
2342−
23432341 if (folio_is_device_coherent(folio))
23442342 continue;
23452343
@@ -2361,8 +2359,6 @@ static unsigned long collect_longterm_unpinnable_folios( · 15 unmodified lines
23612359 NR_ISOLATED_ANON + folio_is_file_lru(folio),
23622360 folio_nr_pages(folio));
23632361 }
2364−
2365− return collected;
23662362 }
23672363
23682364 /*
@@ -2439,11 +2435,9 @@ static long · 70 unmodified lines
24392435 check_and_migrate_movable_pages_or_folios(struct pages_or_folios *pofs)
24402436 {
24412437 LIST_HEAD(movable_folio_list);
2442− unsigned long collected;
24432438
2444− collected = collect_longterm_unpinnable_folios(&movable_folio_list,
2445− pofs);
2446− if (!collected)
2439+ collect_longterm_unpinnable_folios(&movable_folio_list, pofs);
2440+ if (list_empty(&movable_folio_list))
24472441 return 0;
24482442
24492443 return migrate_longterm_unpinnable_folios(&movable_folio_list, pofs);
mm/hugetlb.c+1−1
@@ -3309,7 +3309,7 @@ static void __init gather_bootmem_prealloc(void) · 3308 unmodified lines
33093309 .thread_fn = gather_bootmem_prealloc_parallel,
33103310 .fn_arg = NULL,
33113311 .start = 0,
3312− .size = num_node_state(N_MEMORY),
3312+ .size = nr_node_ids,
33133313 .align = 1,
33143314 .min_chunk = 1,
33153315 .max_threads = num_node_state(N_MEMORY),
mm/kfence/core.c+2−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <linux/log2.h>
2222 #include <linux/memblock.h>
2323 #include <linux/moduleparam.h>
24+#include <linux/nodemask.h>
2425 #include <linux/notifier.h>
2526 #include <linux/panic_notifier.h>
2627 #include <linux/random.h>
@@ -1084,6 +1085,7 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags) · 1057 unmodified lines
10841085 * properties (e.g. reside in DMAable memory).
10851086 */
10861087 if ((flags & GFP_ZONEMASK) ||
1088+ ((flags & __GFP_THISNODE) && num_online_nodes() > 1) ||
10871089 (s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) {
10881090 atomic_long_inc(&counters[KFENCE_COUNTER_SKIP_INCOMPAT]);
10891091 return NULL;
mm/kmemleak.c+1−1
@@ -1689,7 +1689,7 @@ static void kmemleak_scan(void) · 1688 unmodified lines
16891689 unsigned long phys = object->pointer;
16901690
16911691 if (PHYS_PFN(phys) < min_low_pfn ||
1692− PHYS_PFN(phys + object->size) >= max_low_pfn)
1692+ PHYS_PFN(phys + object->size) > max_low_pfn)
16931693 __paint_it(object, KMEMLEAK_BLACK);
16941694 }
16951695
mm/swapfile.c+1−1
@@ -794,7 +794,7 @@ static unsigned int alloc_swap_scan_cluster(struct swap_info_struct *si, · 793 unmodified lines
794794 if (!cluster_scan_range(si, ci, offset, nr_pages, &need_reclaim))
795795 continue;
796796 if (need_reclaim) {
797− ret = cluster_reclaim_range(si, ci, start, end);
797+ ret = cluster_reclaim_range(si, ci, offset, offset + nr_pages);
798798 /*
799799 * Reclaim drops ci->lock and cluster could be used
800800 * by another order. Not checking flag as off-list
mm/vmscan.c+9−4
@@ -1086,7 +1086,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, · 1085 unmodified lines
10861086 struct folio_batch free_folios;
10871087 LIST_HEAD(ret_folios);
10881088 LIST_HEAD(demote_folios);
1089− unsigned int nr_reclaimed = 0;
1089+ unsigned int nr_reclaimed = 0, nr_demoted = 0;
10901090 unsigned int pgactivate = 0;
10911091 bool do_demote_pass;
10921092 struct swap_iocb *plug = NULL;
@@ -1550,8 +1550,9 @@ keep: · 457 unmodified lines
15501550 /* 'folio_list' is always empty here */
15511551
15521552 /* Migrate folios selected for demotion */
1553− stat->nr_demoted = demote_folio_list(&demote_folios, pgdat);
1554− nr_reclaimed += stat->nr_demoted;
1553+ nr_demoted = demote_folio_list(&demote_folios, pgdat);
1554+ nr_reclaimed += nr_demoted;
1555+ stat->nr_demoted += nr_demoted;
15551556 /* Folios that could not be demoted are still in @demote_folios */
15561557 if (!list_empty(&demote_folios)) {
15571558 /* Folios which weren't demoted go back on @folio_list */
@@ -1692,6 +1693,7 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, · 134 unmodified lines
16921693 unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };
16931694 unsigned long skipped = 0;
16941695 unsigned long scan, total_scan, nr_pages;
1696+ unsigned long max_nr_skipped = 0;
16951697 LIST_HEAD(folios_skipped);
16961698
16971699 total_scan = 0;
@@ -1706,9 +1708,12 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, · 8 unmodified lines
17061708 nr_pages = folio_nr_pages(folio);
17071709 total_scan += nr_pages;
17081710
1709− if (folio_zonenum(folio) > sc->reclaim_idx) {
1711+ /* Using max_nr_skipped to prevent hard LOCKUP*/
1712+ if (max_nr_skipped < SWAP_CLUSTER_MAX_SKIPPED &&
1713+ (folio_zonenum(folio) > sc->reclaim_idx)) {
17101714 nr_skipped[folio_zonenum(folio)] += nr_pages;
17111715 move_to = &folios_skipped;
1716+ max_nr_skipped++;
17121717 goto move;
17131718 }
17141719
mm/zsmalloc.c+1−1
@@ -452,7 +452,7 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { · 451 unmodified lines
452452 .lock = INIT_LOCAL_LOCK(lock),
453453 };
454454
455−static inline bool is_first_zpdesc(struct zpdesc *zpdesc)
455+static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc)
456456 {
457457 return PagePrivate(zpdesc_page(zpdesc));
458458 }
scripts/gdb/linux/cpus.py+1−1
@@ -167,7 +167,7 @@ def get_current_task(cpu): · 166 unmodified lines
167167 var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")
168168 return per_cpu(var_ptr, cpu).dereference()
169169 elif utils.is_target_arch("aarch64"):
170− current_task_addr = gdb.parse_and_eval("$SP_EL0")
170+ current_task_addr = gdb.parse_and_eval("(unsigned long)$SP_EL0")
171171 if (current_task_addr >> 63) != 0:
172172 current_task = current_task_addr.cast(task_ptr_type)
173173 return current_task.dereference()