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
150Cai Huoqing <cai.huoqing@linux.dev> <caihuoqing@baidu.com>150Cai Huoqing <cai.huoqing@linux.dev> <caihuoqing@baidu.com>
151Can Guo <quic_cang@quicinc.com> <cang@codeaurora.org>151Can Guo <quic_cang@quicinc.com> <cang@codeaurora.org>
152Carl Huang <quic_cjhuang@quicinc.com> <cjhuang@codeaurora.org>152Carl Huang <quic_cjhuang@quicinc.com> <cjhuang@codeaurora.org>
153Carlos Bilbao <carlos.bilbao.osdev@gmail.com> <carlos.bilbao@amd.com>153Carlos Bilbao <carlos.bilbao@kernel.org> <carlos.bilbao@amd.com>
154Carlos Bilbao <carlos.bilbao@kernel.org> <carlos.bilbao.osdev@gmail.com>
155Carlos Bilbao <carlos.bilbao@kernel.org> <bilbao@vt.edu>
154Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com>156Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com>
155Changbin Du <changbin.du@intel.com> <changbin.du@intel.com>157Changbin Du <changbin.du@intel.com> <changbin.du@intel.com>
156Chao Yu <chao@kernel.org> <chao2.yu@samsung.com>158Chao Yu <chao@kernel.org> <chao2.yu@samsung.com>
@@ -167,6 +169,7 @@ Christian Brauner <brauner@kernel.org> <christian.brauner@canonical.com> · 10 unmodified lines
167Christian Brauner <brauner@kernel.org> <christian.brauner@ubuntu.com>169Christian Brauner <brauner@kernel.org> <christian.brauner@ubuntu.com>
168Christian Marangi <ansuelsmth@gmail.com>170Christian Marangi <ansuelsmth@gmail.com>
169Christophe Ricard <christophe.ricard@gmail.com>171Christophe Ricard <christophe.ricard@gmail.com>
172Christopher Obbard <christopher.obbard@linaro.org> <chris.obbard@collabora.com>
170Christoph Hellwig <hch@lst.de>173Christoph Hellwig <hch@lst.de>
171Chuck Lever <chuck.lever@oracle.com> <cel@kernel.org>174Chuck Lever <chuck.lever@oracle.com> <cel@kernel.org>
172Chuck Lever <chuck.lever@oracle.com> <cel@netapp.com>175Chuck 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
263Guru Das Srinagesh <quic_gurus@quicinc.com> <gurus@codeaurora.org>266Guru Das Srinagesh <quic_gurus@quicinc.com> <gurus@codeaurora.org>
264Gustavo Padovan <gustavo@las.ic.unicamp.br>267Gustavo Padovan <gustavo@las.ic.unicamp.br>
265Gustavo Padovan <padovan@profusion.mobi>268Gustavo Padovan <padovan@profusion.mobi>
269Hamza Mahfooz <hamzamahfooz@linux.microsoft.com> <hamza.mahfooz@amd.com>
266Hanjun Guo <guohanjun@huawei.com> <hanjun.guo@linaro.org>270Hanjun Guo <guohanjun@huawei.com> <hanjun.guo@linaro.org>
267Hans Verkuil <hverkuil@xs4all.nl> <hansverk@cisco.com>271Hans Verkuil <hverkuil@xs4all.nl> <hansverk@cisco.com>
268Hans Verkuil <hverkuil@xs4all.nl> <hverkuil-cisco@xs4all.nl>272Hans Verkuil <hverkuil@xs4all.nl> <hverkuil-cisco@xs4all.nl>
@@ -763,6 +767,7 @@ Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de> · 494 unmodified lines
763Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>767Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>
764Yanteng Si <si.yanteng@linux.dev> <siyanteng@loongson.cn>768Yanteng Si <si.yanteng@linux.dev> <siyanteng@loongson.cn>
765Ying Huang <huang.ying.caritas@gmail.com> <ying.huang@intel.com>769Ying Huang <huang.ying.caritas@gmail.com> <ying.huang@intel.com>
770Yosry Ahmed <yosry.ahmed@linux.dev> <yosryahmed@google.com>
766Yusuke Goda <goda.yusuke@renesas.com>771Yusuke Goda <goda.yusuke@renesas.com>
767Zack Rusin <zack.rusin@broadcom.com> <zackr@vmware.com>772Zack Rusin <zack.rusin@broadcom.com> <zackr@vmware.com>
768Zhu Yanjun <zyjzyj2000@gmail.com> <yanjunz@nvidia.com>773Zhu 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
7 7
8 \kerneldocCJKoff8 \kerneldocCJKoff
9 9
10:maintainer: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>10:maintainer: Carlos Bilbao <carlos.bilbao@kernel.org>
11 11
12.. _sp_disclaimer:12.. _sp_disclaimer:
13 13
MAINTAINERS+7−5
@@ -1090,7 +1090,7 @@ F: drivers/video/fbdev/geode/ · 1089 unmodified lines
1090 1090
1091AMD HSMP DRIVER1091AMD HSMP DRIVER
1092M: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>1092M: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
1093R: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>1093R: Carlos Bilbao <carlos.bilbao@kernel.org>
1094L: platform-driver-x86@vger.kernel.org1094L: platform-driver-x86@vger.kernel.org
1095S: Maintained1095S: Maintained
1096F: Documentation/arch/x86/amd_hsmp.rst1096F: Documentation/arch/x86/amd_hsmp.rst
@@ -5857,7 +5857,7 @@ F: drivers/usb/atm/cxacru.c · 4760 unmodified lines
5857 5857
5858CONFIDENTIAL COMPUTING THREAT MODEL FOR X86 VIRTUALIZATION (SNP/TDX)5858CONFIDENTIAL COMPUTING THREAT MODEL FOR X86 VIRTUALIZATION (SNP/TDX)
5859M: Elena Reshetova <elena.reshetova@intel.com>5859M: Elena Reshetova <elena.reshetova@intel.com>
5860M: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>5860M: Carlos Bilbao <carlos.bilbao@kernel.org>
5861S: Maintained5861S: Maintained
5862F: Documentation/security/snp-tdx-threat-model.rst5862F: Documentation/security/snp-tdx-threat-model.rst
5863 5863
@@ -11331,7 +11331,7 @@ S: Orphan · 5467 unmodified lines
11331F: drivers/video/fbdev/imsttfb.c11331F: drivers/video/fbdev/imsttfb.c
11332 11332
11333INDEX OF FURTHER KERNEL DOCUMENTATION11333INDEX OF FURTHER KERNEL DOCUMENTATION
11334M: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>11334M: Carlos Bilbao <carlos.bilbao@kernel.org>
11335S: Maintained11335S: Maintained
11336F: Documentation/process/kernel-docs.rst11336F: Documentation/process/kernel-docs.rst
11337 11337
@@ -22215,7 +22215,7 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/ · 10877 unmodified lines
22215F: drivers/media/dvb-frontends/sp2*22215F: drivers/media/dvb-frontends/sp2*
22216 22216
22217SPANISH DOCUMENTATION22217SPANISH DOCUMENTATION
22218M: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>22218M: Carlos Bilbao <carlos.bilbao@kernel.org>
22219R: Avadhut Naik <avadhut.naik@amd.com>22219R: Avadhut Naik <avadhut.naik@amd.com>
22220S: Maintained22220S: Maintained
22221F: Documentation/translations/sp_SP/22221F: Documentation/translations/sp_SP/
@@ -25739,11 +25739,13 @@ F: arch/x86/entry/vdso/ · 3517 unmodified lines
25739XARRAY25739XARRAY
25740M: Matthew Wilcox <willy@infradead.org>25740M: Matthew Wilcox <willy@infradead.org>
25741L: linux-fsdevel@vger.kernel.org25741L: linux-fsdevel@vger.kernel.org
25742L: linux-mm@kvack.org
25742S: Supported25743S: Supported
25743F: Documentation/core-api/xarray.rst25744F: Documentation/core-api/xarray.rst
25744F: include/linux/idr.h25745F: include/linux/idr.h
25745F: include/linux/xarray.h25746F: include/linux/xarray.h
25746F: lib/idr.c25747F: lib/idr.c
25748F: lib/test_xarray.c
25747F: lib/xarray.c25749F: lib/xarray.c
25748F: tools/testing/radix-tree25750F: tools/testing/radix-tree
25749 25751
@@ -26223,7 +26225,7 @@ K: zstd · 473 unmodified lines
26223 26225
26224ZSWAP COMPRESSED SWAP CACHING26226ZSWAP COMPRESSED SWAP CACHING
26225M: Johannes Weiner <hannes@cmpxchg.org>26227M: Johannes Weiner <hannes@cmpxchg.org>
26226M: Yosry Ahmed <yosryahmed@google.com>26228M: Yosry Ahmed <yosry.ahmed@linux.dev>
26227M: Nhat Pham <nphamcs@gmail.com>26229M: Nhat Pham <nphamcs@gmail.com>
26228R: Chengming Zhou <chengming.zhou@linux.dev>26230R: Chengming Zhou <chengming.zhou@linux.dev>
26229L: linux-mm@kvack.org26231L: linux-mm@kvack.org
arch/m68k/configs/amiga_defconfig+1−0
@@ -626,6 +626,7 @@ CONFIG_TEST_PRINTF=m · 625 unmodified lines
626CONFIG_TEST_SCANF=m626CONFIG_TEST_SCANF=m
627CONFIG_TEST_BITMAP=m627CONFIG_TEST_BITMAP=m
628CONFIG_TEST_UUID=m628CONFIG_TEST_UUID=m
629CONFIG_TEST_XARRAY=m
629CONFIG_TEST_MAPLE_TREE=m630CONFIG_TEST_MAPLE_TREE=m
630CONFIG_TEST_RHASHTABLE=m631CONFIG_TEST_RHASHTABLE=m
631CONFIG_TEST_IDA=m632CONFIG_TEST_IDA=m
arch/m68k/configs/apollo_defconfig+1−0
@@ -583,6 +583,7 @@ CONFIG_TEST_PRINTF=m · 582 unmodified lines
583CONFIG_TEST_SCANF=m583CONFIG_TEST_SCANF=m
584CONFIG_TEST_BITMAP=m584CONFIG_TEST_BITMAP=m
585CONFIG_TEST_UUID=m585CONFIG_TEST_UUID=m
586CONFIG_TEST_XARRAY=m
586CONFIG_TEST_MAPLE_TREE=m587CONFIG_TEST_MAPLE_TREE=m
587CONFIG_TEST_RHASHTABLE=m588CONFIG_TEST_RHASHTABLE=m
588CONFIG_TEST_IDA=m589CONFIG_TEST_IDA=m
arch/m68k/configs/atari_defconfig+1−0
@@ -603,6 +603,7 @@ CONFIG_TEST_PRINTF=m · 602 unmodified lines
603CONFIG_TEST_SCANF=m603CONFIG_TEST_SCANF=m
604CONFIG_TEST_BITMAP=m604CONFIG_TEST_BITMAP=m
605CONFIG_TEST_UUID=m605CONFIG_TEST_UUID=m
606CONFIG_TEST_XARRAY=m
606CONFIG_TEST_MAPLE_TREE=m607CONFIG_TEST_MAPLE_TREE=m
607CONFIG_TEST_RHASHTABLE=m608CONFIG_TEST_RHASHTABLE=m
608CONFIG_TEST_IDA=m609CONFIG_TEST_IDA=m
arch/m68k/configs/bvme6000_defconfig+1−0
@@ -575,6 +575,7 @@ CONFIG_TEST_PRINTF=m · 574 unmodified lines
575CONFIG_TEST_SCANF=m575CONFIG_TEST_SCANF=m
576CONFIG_TEST_BITMAP=m576CONFIG_TEST_BITMAP=m
577CONFIG_TEST_UUID=m577CONFIG_TEST_UUID=m
578CONFIG_TEST_XARRAY=m
578CONFIG_TEST_MAPLE_TREE=m579CONFIG_TEST_MAPLE_TREE=m
579CONFIG_TEST_RHASHTABLE=m580CONFIG_TEST_RHASHTABLE=m
580CONFIG_TEST_IDA=m581CONFIG_TEST_IDA=m
arch/m68k/configs/hp300_defconfig+1−0
@@ -585,6 +585,7 @@ CONFIG_TEST_PRINTF=m · 584 unmodified lines
585CONFIG_TEST_SCANF=m585CONFIG_TEST_SCANF=m
586CONFIG_TEST_BITMAP=m586CONFIG_TEST_BITMAP=m
587CONFIG_TEST_UUID=m587CONFIG_TEST_UUID=m
588CONFIG_TEST_XARRAY=m
588CONFIG_TEST_MAPLE_TREE=m589CONFIG_TEST_MAPLE_TREE=m
589CONFIG_TEST_RHASHTABLE=m590CONFIG_TEST_RHASHTABLE=m
590CONFIG_TEST_IDA=m591CONFIG_TEST_IDA=m
arch/m68k/configs/mac_defconfig+1−0
@@ -602,6 +602,7 @@ CONFIG_TEST_PRINTF=m · 601 unmodified lines
602CONFIG_TEST_SCANF=m602CONFIG_TEST_SCANF=m
603CONFIG_TEST_BITMAP=m603CONFIG_TEST_BITMAP=m
604CONFIG_TEST_UUID=m604CONFIG_TEST_UUID=m
605CONFIG_TEST_XARRAY=m
605CONFIG_TEST_MAPLE_TREE=m606CONFIG_TEST_MAPLE_TREE=m
606CONFIG_TEST_RHASHTABLE=m607CONFIG_TEST_RHASHTABLE=m
607CONFIG_TEST_IDA=m608CONFIG_TEST_IDA=m
arch/m68k/configs/multi_defconfig+1−0
@@ -689,6 +689,7 @@ CONFIG_TEST_PRINTF=m · 688 unmodified lines
689CONFIG_TEST_SCANF=m689CONFIG_TEST_SCANF=m
690CONFIG_TEST_BITMAP=m690CONFIG_TEST_BITMAP=m
691CONFIG_TEST_UUID=m691CONFIG_TEST_UUID=m
692CONFIG_TEST_XARRAY=m
692CONFIG_TEST_MAPLE_TREE=m693CONFIG_TEST_MAPLE_TREE=m
693CONFIG_TEST_RHASHTABLE=m694CONFIG_TEST_RHASHTABLE=m
694CONFIG_TEST_IDA=m695CONFIG_TEST_IDA=m
arch/m68k/configs/mvme147_defconfig+1−0
@@ -575,6 +575,7 @@ CONFIG_TEST_PRINTF=m · 574 unmodified lines
575CONFIG_TEST_SCANF=m575CONFIG_TEST_SCANF=m
576CONFIG_TEST_BITMAP=m576CONFIG_TEST_BITMAP=m
577CONFIG_TEST_UUID=m577CONFIG_TEST_UUID=m
578CONFIG_TEST_XARRAY=m
578CONFIG_TEST_MAPLE_TREE=m579CONFIG_TEST_MAPLE_TREE=m
579CONFIG_TEST_RHASHTABLE=m580CONFIG_TEST_RHASHTABLE=m
580CONFIG_TEST_IDA=m581CONFIG_TEST_IDA=m
arch/m68k/configs/mvme16x_defconfig+1−0
@@ -576,6 +576,7 @@ CONFIG_TEST_PRINTF=m · 575 unmodified lines
576CONFIG_TEST_SCANF=m576CONFIG_TEST_SCANF=m
577CONFIG_TEST_BITMAP=m577CONFIG_TEST_BITMAP=m
578CONFIG_TEST_UUID=m578CONFIG_TEST_UUID=m
579CONFIG_TEST_XARRAY=m
579CONFIG_TEST_MAPLE_TREE=m580CONFIG_TEST_MAPLE_TREE=m
580CONFIG_TEST_RHASHTABLE=m581CONFIG_TEST_RHASHTABLE=m
581CONFIG_TEST_IDA=m582CONFIG_TEST_IDA=m
arch/m68k/configs/q40_defconfig+1−0
@@ -592,6 +592,7 @@ CONFIG_TEST_PRINTF=m · 591 unmodified lines
592CONFIG_TEST_SCANF=m592CONFIG_TEST_SCANF=m
593CONFIG_TEST_BITMAP=m593CONFIG_TEST_BITMAP=m
594CONFIG_TEST_UUID=m594CONFIG_TEST_UUID=m
595CONFIG_TEST_XARRAY=m
595CONFIG_TEST_MAPLE_TREE=m596CONFIG_TEST_MAPLE_TREE=m
596CONFIG_TEST_RHASHTABLE=m597CONFIG_TEST_RHASHTABLE=m
597CONFIG_TEST_IDA=m598CONFIG_TEST_IDA=m
arch/m68k/configs/sun3_defconfig+1−0
@@ -572,6 +572,7 @@ CONFIG_TEST_PRINTF=m · 571 unmodified lines
572CONFIG_TEST_SCANF=m572CONFIG_TEST_SCANF=m
573CONFIG_TEST_BITMAP=m573CONFIG_TEST_BITMAP=m
574CONFIG_TEST_UUID=m574CONFIG_TEST_UUID=m
575CONFIG_TEST_XARRAY=m
575CONFIG_TEST_MAPLE_TREE=m576CONFIG_TEST_MAPLE_TREE=m
576CONFIG_TEST_RHASHTABLE=m577CONFIG_TEST_RHASHTABLE=m
577CONFIG_TEST_IDA=m578CONFIG_TEST_IDA=m
arch/m68k/configs/sun3x_defconfig+1−0
@@ -573,6 +573,7 @@ CONFIG_TEST_PRINTF=m · 572 unmodified lines
573CONFIG_TEST_SCANF=m573CONFIG_TEST_SCANF=m
574CONFIG_TEST_BITMAP=m574CONFIG_TEST_BITMAP=m
575CONFIG_TEST_UUID=m575CONFIG_TEST_UUID=m
576CONFIG_TEST_XARRAY=m
576CONFIG_TEST_MAPLE_TREE=m577CONFIG_TEST_MAPLE_TREE=m
577CONFIG_TEST_RHASHTABLE=m578CONFIG_TEST_RHASHTABLE=m
578CONFIG_TEST_IDA=m579CONFIG_TEST_IDA=m
arch/powerpc/configs/ppc64_defconfig+1−0
@@ -448,6 +448,7 @@ CONFIG_TEST_PRINTF=m · 447 unmodified lines
448CONFIG_TEST_SCANF=m448CONFIG_TEST_SCANF=m
449CONFIG_TEST_BITMAP=m449CONFIG_TEST_BITMAP=m
450CONFIG_TEST_UUID=m450CONFIG_TEST_UUID=m
451CONFIG_TEST_XARRAY=m
451CONFIG_TEST_MAPLE_TREE=m452CONFIG_TEST_MAPLE_TREE=m
452CONFIG_TEST_RHASHTABLE=m453CONFIG_TEST_RHASHTABLE=m
453CONFIG_TEST_IDA=m454CONFIG_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
95 int i, j, index = -1, count = 0;95 int i, j, index = -1, count = 0;
96 nodemask_t nodes_to_enable;96 nodemask_t nodes_to_enable;
97 97
98 if (numa_off || srat_disabled())98 if (numa_off)
99 return -1;99 return -1;
100 100
101 /* no or incomplete node/PXM mapping set, nothing to do */
102 if (srat_disabled())
103 return 0;
104
101 /* find fake nodes PXM mapping */105 /* find fake nodes PXM mapping */
102 for (i = 0; i < MAX_NUMNODES; i++) {106 for (i = 0; i < MAX_NUMNODES; i++) {
103 if (node_to_pxm_map[i] != PXM_INVAL) {107 if (node_to_pxm_map[i] != PXM_INVAL) {
@@ -117,6 +121,11 @@ int __init fix_pxm_node_maps(int max_nid) · 13 unmodified lines
117 }121 }
118 }122 }
119 }123 }
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 }
120 if (WARN(index != max_nid, "%d max nid when expected %d\n",129 if (WARN(index != max_nid, "%d max nid when expected %d\n",
121 index, max_nid))130 index, max_nid))
122 return -1;131 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
1186 if (size) {1186 if (size) {
1187 if (phys && blkphy << blkbits == phys + size) {1187 if (phys && blkphy << blkbits == phys + size) {
1188 /* The current extent goes on */1188 /* The current extent goes on */
1189 size += n << blkbits;1189 size += (u64)n << blkbits;
1190 } else {1190 } else {
1191 /* Terminate the current extent */1191 /* Terminate the current extent */
1192 ret = fiemap_fill_next_extent(1192 ret = fiemap_fill_next_extent(
@@ -1199,14 +1199,14 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · 6 unmodified lines
1199 flags = FIEMAP_EXTENT_MERGED;1199 flags = FIEMAP_EXTENT_MERGED;
1200 logical = blkoff << blkbits;1200 logical = blkoff << blkbits;
1201 phys = blkphy << blkbits;1201 phys = blkphy << blkbits;
1202 size = n << blkbits;1202 size = (u64)n << blkbits;
1203 }1203 }
1204 } else {1204 } else {
1205 /* Start a new extent */1205 /* Start a new extent */
1206 flags = FIEMAP_EXTENT_MERGED;1206 flags = FIEMAP_EXTENT_MERGED;
1207 logical = blkoff << blkbits;1207 logical = blkoff << blkbits;
1208 phys = blkphy << blkbits;1208 phys = blkphy << blkbits;
1209 size = n << blkbits;1209 size = (u64)n << blkbits;
1210 }1210 }
1211 blkoff += n;1211 blkoff += n;
1212 }1212 }
fs/ocfs2/super.c+1−1
@@ -2285,7 +2285,7 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di, · 2284 unmodified lines
2285 mlog(ML_ERROR, "found superblock with incorrect block "2285 mlog(ML_ERROR, "found superblock with incorrect block "
2286 "size bits: found %u, should be 9, 10, 11, or 12\n",2286 "size bits: found %u, should be 9, 10, 11, or 12\n",
2287 blksz_bits);2287 blksz_bits);
2288 } else if ((1 << le32_to_cpu(blksz_bits)) != blksz) {2288 } else if ((1 << blksz_bits) != blksz) {
2289 mlog(ML_ERROR, "found superblock with incorrect block "2289 mlog(ML_ERROR, "found superblock with incorrect block "
2290 "size: found %u, should be %u\n", 1 << blksz_bits, blksz);2290 "size: found %u, should be %u\n", 1 << blksz_bits, blksz);
2291 } else if (le16_to_cpu(di->id2.i_super.s_major_rev_level) !=2291 } 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
222};222};
223 223
224#define SWAP_CLUSTER_MAX 32UL224#define SWAP_CLUSTER_MAX 32UL
225#define SWAP_CLUSTER_MAX_SKIPPED (SWAP_CLUSTER_MAX << 10)
225#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX226#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
226 227
227/* Bit flag in swap_map */228/* Bit flag in swap_map */
kernel/events/uprobes.c+4−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
28#include <linux/rcupdate_trace.h>28#include <linux/rcupdate_trace.h>
29#include <linux/workqueue.h>29#include <linux/workqueue.h>
30#include <linux/srcu.h>30#include <linux/srcu.h>
31#include <linux/oom.h> /* check_stable_address_space */
31 32
32#include <linux/uprobes.h>33#include <linux/uprobes.h>
33 34
@@ -1260,6 +1261,9 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new) · 1226 unmodified lines
1260 * returns NULL in find_active_uprobe_rcu().1261 * returns NULL in find_active_uprobe_rcu().
1261 */1262 */
1262 mmap_write_lock(mm);1263 mmap_write_lock(mm);
1264 if (check_stable_address_space(mm))
1265 goto unlock;
1266
1263 vma = find_vma(mm, info->vaddr);1267 vma = find_vma(mm, info->vaddr);
1264 if (!vma || !valid_vma(vma, is_register) ||1268 if (!vma || !valid_vma(vma, is_register) ||
1265 file_inode(vma->vm_file) != uprobe->inode)1269 file_inode(vma->vm_file) != uprobe->inode)
kernel/fork.c+14−3
@@ -760,7 +760,8 @@ loop_out: · 759 unmodified lines
760 mt_set_in_rcu(vmi.mas.tree);760 mt_set_in_rcu(vmi.mas.tree);
761 ksm_fork(mm, oldmm);761 ksm_fork(mm, oldmm);
762 khugepaged_fork(mm, oldmm);762 khugepaged_fork(mm, oldmm);
763 } else if (mpnt) {763 } else {
764
764 /*765 /*
765 * The entire maple tree has already been duplicated. If the766 * The entire maple tree has already been duplicated. If the
766 * mmap duplication fails, mark the failure point with767 * mmap duplication fails, mark the failure point with
@@ -768,8 +769,18 @@ loop_out: · 1 unmodified line
768 * stop releasing VMAs that have not been duplicated after this769 * stop releasing VMAs that have not been duplicated after this
769 * point.770 * point.
770 */771 */
771 mas_set_range(&vmi.mas, mpnt->vm_start, mpnt->vm_end - 1);772 if (mpnt) {
772 mas_store(&vmi.mas, XA_ZERO_ENTRY);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);
773 }784 }
774out:785out:
775 mmap_write_unlock(mm);786 mmap_write_unlock(mm);
lib/Kconfig.debug+2−16
@@ -2456,22 +2456,8 @@ config TEST_BITMAP · 2455 unmodified lines
2456config TEST_UUID2456config TEST_UUID
2457 tristate "Test functions located in the uuid module at runtime"2457 tristate "Test functions located in the uuid module at runtime"
2458 2458
2459config XARRAY_KUNIT2459config TEST_XARRAY
2460 tristate "KUnit test XArray code at runtime" if !KUNIT_ALL_TESTS2460 tristate "Test the XArray code at runtime"
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.
2475 2461
2476config TEST_MAPLE_TREE2462config TEST_MAPLE_TREE
2477 tristate "Test the Maple Tree code at runtime or module load"2463 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
94endif94endif
95 95
96obj-$(CONFIG_TEST_UUID) += test_uuid.o96obj-$(CONFIG_TEST_UUID) += test_uuid.o
97obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
97obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o98obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o
98obj-$(CONFIG_TEST_PARMAN) += test_parman.o99obj-$(CONFIG_TEST_PARMAN) += test_parman.o
99obj-$(CONFIG_TEST_KMOD) += test_kmod.o100obj-$(CONFIG_TEST_KMOD) += test_kmod.o
@@ -372,7 +373,6 @@ CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN) · 272 unmodified lines
372obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o373obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
373obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o374obj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o
374obj-$(CONFIG_UTIL_MACROS_KUNIT) += util_macros_kunit.o375obj-$(CONFIG_UTIL_MACROS_KUNIT) += util_macros_kunit.o
375obj-$(CONFIG_XARRAY_KUNIT) += test_xarray.o
376obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o376obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
377obj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o377obj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o
378obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o378obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
lib/test_xarray.c+278−393
@@ -6,10 +6,11 @@ · 5 unmodified lines
6 * Author: Matthew Wilcox <willy@infradead.org>6 * Author: Matthew Wilcox <willy@infradead.org>
7 */7 */
8 8
9#include <kunit/test.h>
10
11#include <linux/module.h>
12#include <linux/xarray.h>9#include <linux/xarray.h>
10#include <linux/module.h>
11
12static unsigned int tests_run;
13static unsigned int tests_passed;
13 14
14static const unsigned int order_limit =15static const unsigned int order_limit =
15 IS_ENABLED(CONFIG_XARRAY_MULTI) ? BITS_PER_LONG : 1;16 IS_ENABLED(CONFIG_XARRAY_MULTI) ? BITS_PER_LONG : 1;
@@ -19,12 +20,15 @@ static const unsigned int order_limit = · 3 unmodified lines
19void xa_dump(const struct xarray *xa) { }20void xa_dump(const struct xarray *xa) { }
20# endif21# endif
21#undef XA_BUG_ON22#undef XA_BUG_ON
22#define XA_BUG_ON(xa, x) do { \23#define XA_BUG_ON(xa, x) do { \
23 if (x) { \24 tests_run++; \
24 KUNIT_FAIL(test, #x); \25 if (x) { \
25 xa_dump(xa); \26 printk("BUG at %s:%d\n", __func__, __LINE__); \
26 dump_stack(); \27 xa_dump(xa); \
27 } \28 dump_stack(); \
29 } else { \
30 tests_passed++; \
31 } \
28} while (0)32} while (0)
29#endif33#endif
30 34
@@ -38,13 +42,13 @@ static void *xa_store_index(struct xarray *xa, unsigned long index, gfp_t gfp) · 7 unmodified lines
38 return xa_store(xa, index, xa_mk_index(index), gfp);42 return xa_store(xa, index, xa_mk_index(index), gfp);
39}43}
40 44
41static void xa_insert_index(struct kunit *test, struct xarray *xa, unsigned long index)45static void xa_insert_index(struct xarray *xa, unsigned long index)
42{46{
43 XA_BUG_ON(xa, xa_insert(xa, index, xa_mk_index(index),47 XA_BUG_ON(xa, xa_insert(xa, index, xa_mk_index(index),
44 GFP_KERNEL) != 0);48 GFP_KERNEL) != 0);
45}49}
46 50
47static void xa_alloc_index(struct kunit *test, struct xarray *xa, unsigned long index, gfp_t gfp)51static void xa_alloc_index(struct xarray *xa, unsigned long index, gfp_t gfp)
48{52{
49 u32 id;53 u32 id;
50 54
@@ -53,7 +57,7 @@ static void xa_alloc_index(struct kunit *test, struct xarray *xa, unsigned long · 2 unmodified lines
53 XA_BUG_ON(xa, id != index);57 XA_BUG_ON(xa, id != index);
54}58}
55 59
56static void xa_erase_index(struct kunit *test, struct xarray *xa, unsigned long index)60static void xa_erase_index(struct xarray *xa, unsigned long index)
57{61{
58 XA_BUG_ON(xa, xa_erase(xa, index) != xa_mk_index(index));62 XA_BUG_ON(xa, xa_erase(xa, index) != xa_mk_index(index));
59 XA_BUG_ON(xa, xa_load(xa, index) != NULL);63 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
79 return curr;83 return curr;
80}84}
81 85
82static inline struct xarray *xa_param(struct kunit *test)86static noinline void check_xa_err(struct xarray *xa)
83{87{
84 return *(struct xarray **)test->param_value;
85}
86
87static noinline void check_xa_err(struct kunit *test)
88{
89 struct xarray *xa = xa_param(test);
90
91 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 0, GFP_NOWAIT)) != 0);88 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 0, GFP_NOWAIT)) != 0);
92 XA_BUG_ON(xa, xa_err(xa_erase(xa, 0)) != 0);89 XA_BUG_ON(xa, xa_err(xa_erase(xa, 0)) != 0);
93#ifndef __KERNEL__90#ifndef __KERNEL__
@@ -102,10 +99,8 @@ static noinline void check_xa_err(struct kunit *test) · 8 unmodified lines
102// XA_BUG_ON(xa, xa_err(xa_store(xa, 0, xa_mk_internal(0), 0)) != -EINVAL);99// XA_BUG_ON(xa, xa_err(xa_store(xa, 0, xa_mk_internal(0), 0)) != -EINVAL);
103}100}
104 101
105static noinline void check_xas_retry(struct kunit *test)102static noinline void check_xas_retry(struct xarray *xa)
106{103{
107 struct xarray *xa = xa_param(test);
108
109 XA_STATE(xas, xa, 0);104 XA_STATE(xas, xa, 0);
110 void *entry;105 void *entry;
111 106
@@ -114,7 +109,7 @@ static noinline void check_xas_retry(struct kunit *test) · 2 unmodified lines
114 109
115 rcu_read_lock();110 rcu_read_lock();
116 XA_BUG_ON(xa, xas_find(&xas, ULONG_MAX) != xa_mk_value(0));111 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);
118 XA_BUG_ON(xa, !xa_is_retry(xas_reload(&xas)));113 XA_BUG_ON(xa, !xa_is_retry(xas_reload(&xas)));
119 XA_BUG_ON(xa, xas_retry(&xas, NULL));114 XA_BUG_ON(xa, xas_retry(&xas, NULL));
120 XA_BUG_ON(xa, xas_retry(&xas, xa_mk_value(0)));115 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
145 }140 }
146 xas_unlock(&xas);141 xas_unlock(&xas);
147 142
148 xa_erase_index(test, xa, 0);143 xa_erase_index(xa, 0);
149 xa_erase_index(test, xa, 1);144 xa_erase_index(xa, 1);
150}145}
151 146
152static noinline void check_xa_load(struct kunit *test)147static noinline void check_xa_load(struct xarray *xa)
153{148{
154 struct xarray *xa = xa_param(test);
155
156 unsigned long i, j;149 unsigned long i, j;
157 150
158 for (i = 0; i < 1024; i++) {151 for (i = 0; i < 1024; i++) {
@@ -174,15 +167,13 @@ static noinline void check_xa_load(struct kunit *test) · 15 unmodified lines
174 else167 else
175 XA_BUG_ON(xa, entry);168 XA_BUG_ON(xa, entry);
176 }169 }
177 xa_erase_index(test, xa, i);170 xa_erase_index(xa, i);
178 }171 }
179 XA_BUG_ON(xa, !xa_empty(xa));172 XA_BUG_ON(xa, !xa_empty(xa));
180}173}
181 174
182static noinline void check_xa_mark_1(struct kunit *test, unsigned long index)175static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index)
183{176{
184 struct xarray *xa = xa_param(test);
185
186 unsigned int order;177 unsigned int order;
187 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 8 : 1;178 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 8 : 1;
188 179
@@ -202,7 +193,7 @@ static noinline void check_xa_mark_1(struct kunit *test, unsigned long index) · 13 unmodified lines
202 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_1));193 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_1));
203 194
204 /* Storing NULL clears marks, and they can't be set again */195 /* Storing NULL clears marks, and they can't be set again */
205 xa_erase_index(test, xa, index);196 xa_erase_index(xa, index);
206 XA_BUG_ON(xa, !xa_empty(xa));197 XA_BUG_ON(xa, !xa_empty(xa));
207 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0));198 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0));
208 xa_set_mark(xa, index, XA_MARK_0);199 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
253 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_0));244 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_0));
254 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_1));245 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_1));
255 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_2));246 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_2));
256 xa_erase_index(test, xa, index);247 xa_erase_index(xa, index);
257 xa_erase_index(test, xa, next);248 xa_erase_index(xa, next);
258 XA_BUG_ON(xa, !xa_empty(xa));249 XA_BUG_ON(xa, !xa_empty(xa));
259 }250 }
260 XA_BUG_ON(xa, !xa_empty(xa));251 XA_BUG_ON(xa, !xa_empty(xa));
261}252}
262 253
263static noinline void check_xa_mark_2(struct kunit *test)254static noinline void check_xa_mark_2(struct xarray *xa)
264{255{
265 struct xarray *xa = xa_param(test);
266
267 XA_STATE(xas, xa, 0);256 XA_STATE(xas, xa, 0);
268 unsigned long index;257 unsigned long index;
269 unsigned int count = 0;258 unsigned int count = 0;
@@ -300,11 +289,9 @@ static noinline void check_xa_mark_2(struct kunit *test) · 30 unmodified lines
300 xa_destroy(xa);289 xa_destroy(xa);
301}290}
302 291
303static noinline void check_xa_mark_3(struct kunit *test)292static noinline void check_xa_mark_3(struct xarray *xa)
304{293{
305#ifdef CONFIG_XARRAY_MULTI294#ifdef CONFIG_XARRAY_MULTI
306 struct xarray *xa = xa_param(test);
307
308 XA_STATE(xas, xa, 0x41);295 XA_STATE(xas, xa, 0x41);
309 void *entry;296 void *entry;
310 int count = 0;297 int count = 0;
@@ -323,21 +310,19 @@ static noinline void check_xa_mark_3(struct kunit *test) · 12 unmodified lines
323#endif310#endif
324}311}
325 312
326static noinline void check_xa_mark(struct kunit *test)313static noinline void check_xa_mark(struct xarray *xa)
327{314{
328 unsigned long index;315 unsigned long index;
329 316
330 for (index = 0; index < 16384; index += 4)317 for (index = 0; index < 16384; index += 4)
331 check_xa_mark_1(test, index);318 check_xa_mark_1(xa, index);
332 319
333 check_xa_mark_2(test);320 check_xa_mark_2(xa);
334 check_xa_mark_3(test);321 check_xa_mark_3(xa);
335}322}
336 323
337static noinline void check_xa_shrink(struct kunit *test)324static noinline void check_xa_shrink(struct xarray *xa)
338{325{
339 struct xarray *xa = xa_param(test);
340
341 XA_STATE(xas, xa, 1);326 XA_STATE(xas, xa, 1);
342 struct xa_node *node;327 struct xa_node *node;
343 unsigned int order;328 unsigned int order;
@@ -362,7 +347,7 @@ static noinline void check_xa_shrink(struct kunit *test) · 18 unmodified lines
362 XA_BUG_ON(xa, xas_load(&xas) != NULL);347 XA_BUG_ON(xa, xas_load(&xas) != NULL);
363 xas_unlock(&xas);348 xas_unlock(&xas);
364 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0));349 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);
366 XA_BUG_ON(xa, !xa_empty(xa));351 XA_BUG_ON(xa, !xa_empty(xa));
367 352
368 for (order = 0; order < max_order; order++) {353 for (order = 0; order < max_order; order++) {
@@ -379,49 +364,45 @@ static noinline void check_xa_shrink(struct kunit *test) · 10 unmodified lines
379 XA_BUG_ON(xa, xa_head(xa) == node);364 XA_BUG_ON(xa, xa_head(xa) == node);
380 rcu_read_unlock();365 rcu_read_unlock();
381 XA_BUG_ON(xa, xa_load(xa, max + 1) != NULL);366 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);
383 XA_BUG_ON(xa, xa->xa_head != node);368 XA_BUG_ON(xa, xa->xa_head != node);
384 xa_erase_index(test, xa, 0);369 xa_erase_index(xa, 0);
385 }370 }
386}371}
387 372
388static noinline void check_insert(struct kunit *test)373static noinline void check_insert(struct xarray *xa)
389{374{
390 struct xarray *xa = xa_param(test);
391
392 unsigned long i;375 unsigned long i;
393 376
394 for (i = 0; i < 1024; i++) {377 for (i = 0; i < 1024; i++) {
395 xa_insert_index(test, xa, i);378 xa_insert_index(xa, i);
396 XA_BUG_ON(xa, xa_load(xa, i - 1) != NULL);379 XA_BUG_ON(xa, xa_load(xa, i - 1) != NULL);
397 XA_BUG_ON(xa, xa_load(xa, i + 1) != NULL);380 XA_BUG_ON(xa, xa_load(xa, i + 1) != NULL);
398 xa_erase_index(test, xa, i);381 xa_erase_index(xa, i);
399 }382 }
400 383
401 for (i = 10; i < BITS_PER_LONG; i++) {384 for (i = 10; i < BITS_PER_LONG; i++) {
402 xa_insert_index(test, xa, 1UL << i);385 xa_insert_index(xa, 1UL << i);
403 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 1) != NULL);386 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 1) != NULL);
404 XA_BUG_ON(xa, xa_load(xa, (1UL << i) + 1) != NULL);387 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);
406 389
407 xa_insert_index(test, xa, (1UL << i) - 1);390 xa_insert_index(xa, (1UL << i) - 1);
408 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 2) != NULL);391 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 2) != NULL);
409 XA_BUG_ON(xa, xa_load(xa, 1UL << i) != NULL);392 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);
411 }394 }
412 395
413 xa_insert_index(test, xa, ~0UL);396 xa_insert_index(xa, ~0UL);
414 XA_BUG_ON(xa, xa_load(xa, 0UL) != NULL);397 XA_BUG_ON(xa, xa_load(xa, 0UL) != NULL);
415 XA_BUG_ON(xa, xa_load(xa, ~1UL) != NULL);398 XA_BUG_ON(xa, xa_load(xa, ~1UL) != NULL);
416 xa_erase_index(test, xa, ~0UL);399 xa_erase_index(xa, ~0UL);
417 400
418 XA_BUG_ON(xa, !xa_empty(xa));401 XA_BUG_ON(xa, !xa_empty(xa));
419}402}
420 403
421static noinline void check_cmpxchg(struct kunit *test)404static noinline void check_cmpxchg(struct xarray *xa)
422{405{
423 struct xarray *xa = xa_param(test);
424
425 void *FIVE = xa_mk_value(5);406 void *FIVE = xa_mk_value(5);
426 void *SIX = xa_mk_value(6);407 void *SIX = xa_mk_value(6);
427 void *LOTS = xa_mk_value(12345678);408 void *LOTS = xa_mk_value(12345678);
@@ -437,16 +418,14 @@ static noinline void check_cmpxchg(struct kunit *test) · 9 unmodified lines
437 XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) != -EBUSY);418 XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) != -EBUSY);
438 XA_BUG_ON(xa, xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL) != FIVE);419 XA_BUG_ON(xa, xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL) != FIVE);
439 XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) == -EBUSY);420 XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) == -EBUSY);
440 xa_erase_index(test, xa, 12345678);421 xa_erase_index(xa, 12345678);
441 xa_erase_index(test, xa, 5);422 xa_erase_index(xa, 5);
442 XA_BUG_ON(xa, !xa_empty(xa));423 XA_BUG_ON(xa, !xa_empty(xa));
443}424}
444 425
445static noinline void check_cmpxchg_order(struct kunit *test)426static noinline void check_cmpxchg_order(struct xarray *xa)
446{427{
447#ifdef CONFIG_XARRAY_MULTI428#ifdef CONFIG_XARRAY_MULTI
448 struct xarray *xa = xa_param(test);
449
450 void *FIVE = xa_mk_value(5);429 void *FIVE = xa_mk_value(5);
451 unsigned int i, order = 3;430 unsigned int i, order = 3;
452 431
@@ -497,10 +476,8 @@ static noinline void check_cmpxchg_order(struct kunit *test) · 44 unmodified lines
497#endif476#endif
498}477}
499 478
500static noinline void check_reserve(struct kunit *test)479static noinline void check_reserve(struct xarray *xa)
501{480{
502 struct xarray *xa = xa_param(test);
503
504 void *entry;481 void *entry;
505 unsigned long index;482 unsigned long index;
506 int count;483 int count;
@@ -517,7 +494,7 @@ static noinline void check_reserve(struct kunit *test) · 10 unmodified lines
517 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0);494 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0);
518 XA_BUG_ON(xa, xa_store_index(xa, 12345678, GFP_NOWAIT) != NULL);495 XA_BUG_ON(xa, xa_store_index(xa, 12345678, GFP_NOWAIT) != NULL);
519 xa_release(xa, 12345678);496 xa_release(xa, 12345678);
520 xa_erase_index(test, xa, 12345678);497 xa_erase_index(xa, 12345678);
521 XA_BUG_ON(xa, !xa_empty(xa));498 XA_BUG_ON(xa, !xa_empty(xa));
522 499
523 /* cmpxchg sees a reserved entry as ZERO */500 /* cmpxchg sees a reserved entry as ZERO */
@@ -525,7 +502,7 @@ static noinline void check_reserve(struct kunit *test) · 1 unmodified line
525 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, XA_ZERO_ENTRY,502 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, XA_ZERO_ENTRY,
526 xa_mk_value(12345678), GFP_NOWAIT) != NULL);503 xa_mk_value(12345678), GFP_NOWAIT) != NULL);
527 xa_release(xa, 12345678);504 xa_release(xa, 12345678);
528 xa_erase_index(test, xa, 12345678);505 xa_erase_index(xa, 12345678);
529 XA_BUG_ON(xa, !xa_empty(xa));506 XA_BUG_ON(xa, !xa_empty(xa));
530 507
531 /* xa_insert treats it as busy */508 /* xa_insert treats it as busy */
@@ -565,10 +542,8 @@ static noinline void check_reserve(struct kunit *test) · 33 unmodified lines
565 xa_destroy(xa);542 xa_destroy(xa);
566}543}
567 544
568static noinline void check_xas_erase(struct kunit *test)545static noinline void check_xas_erase(struct xarray *xa)
569{546{
570 struct xarray *xa = xa_param(test);
571
572 XA_STATE(xas, xa, 0);547 XA_STATE(xas, xa, 0);
573 void *entry;548 void *entry;
574 unsigned long i, j;549 unsigned long i, j;
@@ -606,11 +581,9 @@ static noinline void check_xas_erase(struct kunit *test) · 31 unmodified lines
606}581}
607 582
608#ifdef CONFIG_XARRAY_MULTI583#ifdef CONFIG_XARRAY_MULTI
609static noinline void check_multi_store_1(struct kunit *test, unsigned long index,584static noinline void check_multi_store_1(struct xarray *xa, unsigned long index,
610 unsigned int order)585 unsigned int order)
611{586{
612 struct xarray *xa = xa_param(test);
613
614 XA_STATE(xas, xa, index);587 XA_STATE(xas, xa, index);
615 unsigned long min = index & ~((1UL << order) - 1);588 unsigned long min = index & ~((1UL << order) - 1);
616 unsigned long max = min + (1UL << order);589 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
629 XA_BUG_ON(xa, xa_load(xa, max) != NULL);602 XA_BUG_ON(xa, xa_load(xa, max) != NULL);
630 XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL);603 XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL);
631 604
632 xa_erase_index(test, xa, min);605 xa_erase_index(xa, min);
633 XA_BUG_ON(xa, !xa_empty(xa));606 XA_BUG_ON(xa, !xa_empty(xa));
634}607}
635 608
636static noinline void check_multi_store_2(struct kunit *test, unsigned long index,609static noinline void check_multi_store_2(struct xarray *xa, unsigned long index,
637 unsigned int order)610 unsigned int order)
638{611{
639 struct xarray *xa = xa_param(test);
640
641 XA_STATE(xas, xa, index);612 XA_STATE(xas, xa, index);
642 xa_store_order(xa, index, order, xa_mk_value(0), GFP_KERNEL);613 xa_store_order(xa, index, order, xa_mk_value(0), GFP_KERNEL);
643 614
@@ -649,11 +620,9 @@ static noinline void check_multi_store_2(struct kunit *test, unsigned long index · 5 unmodified lines
649 XA_BUG_ON(xa, !xa_empty(xa));620 XA_BUG_ON(xa, !xa_empty(xa));
650}621}
651 622
652static noinline void check_multi_store_3(struct kunit *test, unsigned long index,623static noinline void check_multi_store_3(struct xarray *xa, unsigned long index,
653 unsigned int order)624 unsigned int order)
654{625{
655 struct xarray *xa = xa_param(test);
656
657 XA_STATE(xas, xa, 0);626 XA_STATE(xas, xa, 0);
658 void *entry;627 void *entry;
659 int n = 0;628 int n = 0;
@@ -678,11 +647,9 @@ static noinline void check_multi_store_3(struct kunit *test, unsigned long index · 18 unmodified lines
678}647}
679#endif648#endif
680 649
681static noinline void check_multi_store(struct kunit *test)650static noinline void check_multi_store(struct xarray *xa)
682{651{
683#ifdef CONFIG_XARRAY_MULTI652#ifdef CONFIG_XARRAY_MULTI
684 struct xarray *xa = xa_param(test);
685
686 unsigned long i, j, k;653 unsigned long i, j, k;
687 unsigned int max_order = (sizeof(long) == 4) ? 30 : 60;654 unsigned int max_order = (sizeof(long) == 4) ? 30 : 60;
688 655
@@ -747,28 +714,26 @@ static noinline void check_multi_store(struct kunit *test) · 58 unmodified lines
747 }714 }
748 715
749 for (i = 0; i < 20; i++) {716 for (i = 0; i < 20; i++) {
750 check_multi_store_1(test, 200, i);717 check_multi_store_1(xa, 200, i);
751 check_multi_store_1(test, 0, i);718 check_multi_store_1(xa, 0, i);
752 check_multi_store_1(test, (1UL << i) + 1, i);719 check_multi_store_1(xa, (1UL << i) + 1, i);
753 }720 }
754 check_multi_store_2(test, 4095, 9);721 check_multi_store_2(xa, 4095, 9);
755 722
756 for (i = 1; i < 20; i++) {723 for (i = 1; i < 20; i++) {
757 check_multi_store_3(test, 0, i);724 check_multi_store_3(xa, 0, i);
758 check_multi_store_3(test, 1UL << i, i);725 check_multi_store_3(xa, 1UL << i, i);
759 }726 }
760#endif727#endif
761}728}
762 729
763#ifdef CONFIG_XARRAY_MULTI730#ifdef CONFIG_XARRAY_MULTI
764/* mimics page cache __filemap_add_folio() */731/* mimics page cache __filemap_add_folio() */
765static noinline void check_xa_multi_store_adv_add(struct kunit *test,732static noinline void check_xa_multi_store_adv_add(struct xarray *xa,
766 unsigned long index,733 unsigned long index,
767 unsigned int order,734 unsigned int order,
768 void *p)735 void *p)
769{736{
770 struct xarray *xa = xa_param(test);
771
772 XA_STATE(xas, xa, index);737 XA_STATE(xas, xa, index);
773 unsigned int nrpages = 1UL << order;738 unsigned int nrpages = 1UL << order;
774 739
@@ -796,12 +761,10 @@ static noinline void check_xa_multi_store_adv_add(struct kunit *test, · 21 unmodified lines
796}761}
797 762
798/* mimics page_cache_delete() */763/* mimics page_cache_delete() */
799static noinline void check_xa_multi_store_adv_del_entry(struct kunit *test,764static noinline void check_xa_multi_store_adv_del_entry(struct xarray *xa,
800 unsigned long index,765 unsigned long index,
801 unsigned int order)766 unsigned int order)
802{767{
803 struct xarray *xa = xa_param(test);
804
805 XA_STATE(xas, xa, index);768 XA_STATE(xas, xa, index);
806 769
807 xas_set_order(&xas, index, order);770 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
809 xas_init_marks(&xas);772 xas_init_marks(&xas);
810}773}
811 774
812static noinline void check_xa_multi_store_adv_delete(struct kunit *test,775static noinline void check_xa_multi_store_adv_delete(struct xarray *xa,
813 unsigned long index,776 unsigned long index,
814 unsigned int order)777 unsigned int order)
815{778{
816 struct xarray *xa = xa_param(test);
817
818 xa_lock_irq(xa);779 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);
820 xa_unlock_irq(xa);781 xa_unlock_irq(xa);
821}782}
822 783
@@ -853,12 +814,10 @@ static unsigned long some_val = 0xdeadbeef; · 30 unmodified lines
853static unsigned long some_val_2 = 0xdeaddead;814static unsigned long some_val_2 = 0xdeaddead;
854 815
855/* mimics the page cache usage */816/* mimics the page cache usage */
856static noinline void check_xa_multi_store_adv(struct kunit *test,817static noinline void check_xa_multi_store_adv(struct xarray *xa,
857 unsigned long pos,818 unsigned long pos,
858 unsigned int order)819 unsigned int order)
859{820{
860 struct xarray *xa = xa_param(test);
861
862 unsigned int nrpages = 1UL << order;821 unsigned int nrpages = 1UL << order;
863 unsigned long index, base, next_index, next_next_index;822 unsigned long index, base, next_index, next_next_index;
864 unsigned int i;823 unsigned int i;
@@ -868,7 +827,7 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 3 unmodified lines
868 next_index = round_down(base + nrpages, nrpages);827 next_index = round_down(base + nrpages, nrpages);
869 next_next_index = round_down(next_index + nrpages, nrpages);828 next_next_index = round_down(next_index + nrpages, nrpages);
870 829
871 check_xa_multi_store_adv_add(test, base, order, &some_val);830 check_xa_multi_store_adv_add(xa, base, order, &some_val);
872 831
873 for (i = 0; i < nrpages; i++)832 for (i = 0; i < nrpages; i++)
874 XA_BUG_ON(xa, test_get_entry(xa, base + i) != &some_val);833 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
876 XA_BUG_ON(xa, test_get_entry(xa, next_index) != NULL);835 XA_BUG_ON(xa, test_get_entry(xa, next_index) != NULL);
877 836
878 /* Use order 0 for the next item */837 /* 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);
880 XA_BUG_ON(xa, test_get_entry(xa, next_index) != &some_val_2);839 XA_BUG_ON(xa, test_get_entry(xa, next_index) != &some_val_2);
881 840
882 /* Remove the next item */841 /* 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);
884 843
885 /* Now use order for a new pointer */844 /* 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);
887 846
888 for (i = 0; i < nrpages; i++)847 for (i = 0; i < nrpages; i++)
889 XA_BUG_ON(xa, test_get_entry(xa, next_index + i) != &some_val_2);848 XA_BUG_ON(xa, test_get_entry(xa, next_index + i) != &some_val_2);
890 849
891 check_xa_multi_store_adv_delete(test, next_index, order);850 check_xa_multi_store_adv_delete(xa, next_index, order);
892 check_xa_multi_store_adv_delete(test, base, order);851 check_xa_multi_store_adv_delete(xa, base, order);
893 XA_BUG_ON(xa, !xa_empty(xa));852 XA_BUG_ON(xa, !xa_empty(xa));
894 853
895 /* starting fresh again */854 /* starting fresh again */
@@ -897,7 +856,7 @@ static noinline void check_xa_multi_store_adv(struct kunit *test, · 1 unmodified line
897 /* let's test some holes now */856 /* let's test some holes now */
898 857
899 /* hole at base and next_next */858 /* 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);
901 860
902 for (i = 0; i < nrpages; i++)861 for (i = 0; i < nrpages; i++)
903 XA_BUG_ON(xa, test_get_entry(xa, base + i) != NULL);862 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
908 for (i = 0; i < nrpages; i++)867 for (i = 0; i < nrpages; i++)
909 XA_BUG_ON(xa, test_get_entry(xa, next_next_index + i) != NULL);868 XA_BUG_ON(xa, test_get_entry(xa, next_next_index + i) != NULL);
910 869
911 check_xa_multi_store_adv_delete(test, next_index, order);870 check_xa_multi_store_adv_delete(xa, next_index, order);
912 XA_BUG_ON(xa, !xa_empty(xa));871 XA_BUG_ON(xa, !xa_empty(xa));
913 872
914 /* hole at base and next */873 /* hole at base and next */
915 874
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);
917 876
918 for (i = 0; i < nrpages; i++)877 for (i = 0; i < nrpages; i++)
919 XA_BUG_ON(xa, test_get_entry(xa, base + i) != NULL);878 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
924 for (i = 0; i < nrpages; i++)883 for (i = 0; i < nrpages; i++)
925 XA_BUG_ON(xa, test_get_entry(xa, next_next_index + i) != &some_val_2);884 XA_BUG_ON(xa, test_get_entry(xa, next_next_index + i) != &some_val_2);
926 885
927 check_xa_multi_store_adv_delete(test, next_next_index, order);886 check_xa_multi_store_adv_delete(xa, next_next_index, order);
928 XA_BUG_ON(xa, !xa_empty(xa));887 XA_BUG_ON(xa, !xa_empty(xa));
929}888}
930#endif889#endif
931 890
932static noinline void check_multi_store_advanced(struct kunit *test)891static noinline void check_multi_store_advanced(struct xarray *xa)
933{892{
934#ifdef CONFIG_XARRAY_MULTI893#ifdef CONFIG_XARRAY_MULTI
935 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;894 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
941 */900 */
942 for (pos = 7; pos < end; pos = (pos * pos) + 564) {901 for (pos = 7; pos < end; pos = (pos * pos) + 564) {
943 for (i = 0; i < max_order; i++) {902 for (i = 0; i < max_order; i++) {
944 check_xa_multi_store_adv(test, pos, i);903 check_xa_multi_store_adv(xa, pos, i);
945 check_xa_multi_store_adv(test, pos + 157, i);904 check_xa_multi_store_adv(xa, pos + 157, i);
946 }905 }
947 }906 }
948#endif907#endif
949}908}
950 909
951static noinline void check_xa_alloc_1(struct kunit *test, struct xarray *xa, unsigned int base)910static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base)
952{911{
953 int i;912 int i;
954 u32 id;913 u32 id;
955 914
956 XA_BUG_ON(xa, !xa_empty(xa));915 XA_BUG_ON(xa, !xa_empty(xa));
957 /* An empty array should assign %base to the first alloc */916 /* 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);
959 918
960 /* Erasing it should make the array empty again */919 /* Erasing it should make the array empty again */
961 xa_erase_index(test, xa, base);920 xa_erase_index(xa, base);
962 XA_BUG_ON(xa, !xa_empty(xa));921 XA_BUG_ON(xa, !xa_empty(xa));
963 922
964 /* And it should assign %base again */923 /* And it should assign %base again */
965 xa_alloc_index(test, xa, base, GFP_KERNEL);924 xa_alloc_index(xa, base, GFP_KERNEL);
966 925
967 /* Allocating and then erasing a lot should not lose base */926 /* Allocating and then erasing a lot should not lose base */
968 for (i = base + 1; i < 2 * XA_CHUNK_SIZE; i++)927 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);
970 for (i = base; i < 2 * XA_CHUNK_SIZE; i++)929 for (i = base; i < 2 * XA_CHUNK_SIZE; i++)
971 xa_erase_index(test, xa, i);930 xa_erase_index(xa, i);
972 xa_alloc_index(test, xa, base, GFP_KERNEL);931 xa_alloc_index(xa, base, GFP_KERNEL);
973 932
974 /* Destroying the array should do the same as erasing */933 /* Destroying the array should do the same as erasing */
975 xa_destroy(xa);934 xa_destroy(xa);
976 935
977 /* And it should assign %base again */936 /* And it should assign %base again */
978 xa_alloc_index(test, xa, base, GFP_KERNEL);937 xa_alloc_index(xa, base, GFP_KERNEL);
979 938
980 /* The next assigned ID should be base+1 */939 /* The next assigned ID should be base+1 */
981 xa_alloc_index(test, xa, base + 1, GFP_KERNEL);940 xa_alloc_index(xa, base + 1, GFP_KERNEL);
982 xa_erase_index(test, xa, base + 1);941 xa_erase_index(xa, base + 1);
983 942
984 /* Storing a value should mark it used */943 /* Storing a value should mark it used */
985 xa_store_index(xa, base + 1, GFP_KERNEL);944 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);
987 946
988 /* If we then erase base, it should be free */947 /* If we then erase base, it should be free */
989 xa_erase_index(test, xa, base);948 xa_erase_index(xa, base);
990 xa_alloc_index(test, xa, base, GFP_KERNEL);949 xa_alloc_index(xa, base, GFP_KERNEL);
991 950
992 xa_erase_index(test, xa, base + 1);951 xa_erase_index(xa, base + 1);
993 xa_erase_index(test, xa, base + 2);952 xa_erase_index(xa, base + 2);
994 953
995 for (i = 1; i < 5000; i++) {954 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);
997 }956 }
998 957
999 xa_destroy(xa);958 xa_destroy(xa);
@@ -1016,14 +975,14 @@ static noinline void check_xa_alloc_1(struct kunit *test, struct xarray *xa, uns · 16 unmodified lines
1016 975
1017 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),976 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),
1018 GFP_KERNEL) != -EBUSY);977 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);
1020 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),979 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),
1021 GFP_KERNEL) != -EBUSY);980 GFP_KERNEL) != -EBUSY);
1022 xa_erase_index(test, xa, 3);981 xa_erase_index(xa, 3);
1023 XA_BUG_ON(xa, !xa_empty(xa));982 XA_BUG_ON(xa, !xa_empty(xa));
1024}983}
1025 984
1026static noinline void check_xa_alloc_2(struct kunit *test, struct xarray *xa, unsigned int base)985static noinline void check_xa_alloc_2(struct xarray *xa, unsigned int base)
1027{986{
1028 unsigned int i, id;987 unsigned int i, id;
1029 unsigned long index;988 unsigned long index;
@@ -1059,7 +1018,7 @@ static noinline void check_xa_alloc_2(struct kunit *test, struct xarray *xa, uns · 29 unmodified lines
1059 XA_BUG_ON(xa, id != 5);1018 XA_BUG_ON(xa, id != 5);
1060 1019
1061 xa_for_each(xa, index, entry) {1020 xa_for_each(xa, index, entry) {
1062 xa_erase_index(test, xa, index);1021 xa_erase_index(xa, index);
1063 }1022 }
1064 1023
1065 for (i = base; i < base + 9; i++) {1024 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
1074 xa_destroy(xa);1033 xa_destroy(xa);
1075}1034}
1076 1035
1077static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, unsigned int base)1036static noinline void check_xa_alloc_3(struct xarray *xa, unsigned int base)
1078{1037{
1079 struct xa_limit limit = XA_LIMIT(1, 0x3fff);1038 struct xa_limit limit = XA_LIMIT(1, 0x3fff);
1080 u32 next = 0;1039 u32 next = 0;
@@ -1090,8 +1049,8 @@ static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, uns · 9 unmodified lines
1090 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(0x3ffd), limit,1049 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(0x3ffd), limit,
1091 &next, GFP_KERNEL) != 0);1050 &next, GFP_KERNEL) != 0);
1092 XA_BUG_ON(xa, id != 0x3ffd);1051 XA_BUG_ON(xa, id != 0x3ffd);
1093 xa_erase_index(test, xa, 0x3ffd);1052 xa_erase_index(xa, 0x3ffd);
1094 xa_erase_index(test, xa, 1);1053 xa_erase_index(xa, 1);
1095 XA_BUG_ON(xa, !xa_empty(xa));1054 XA_BUG_ON(xa, !xa_empty(xa));
1096 1055
1097 for (i = 0x3ffe; i < 0x4003; i++) {1056 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
1106 1065
1107 /* Check wrap-around is handled correctly */1066 /* Check wrap-around is handled correctly */
1108 if (base != 0)1067 if (base != 0)
1109 xa_erase_index(test, xa, base);1068 xa_erase_index(xa, base);
1110 xa_erase_index(test, xa, base + 1);1069 xa_erase_index(xa, base + 1);
1111 next = UINT_MAX;1070 next = UINT_MAX;
1112 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(UINT_MAX),1071 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(UINT_MAX),
1113 xa_limit_32b, &next, GFP_KERNEL) != 0);1072 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
1120 XA_BUG_ON(xa, id != base + 1);1079 XA_BUG_ON(xa, id != base + 1);
1121 1080
1122 xa_for_each(xa, index, entry)1081 xa_for_each(xa, index, entry)
1123 xa_erase_index(test, xa, index);1082 xa_erase_index(xa, index);
1124 1083
1125 XA_BUG_ON(xa, !xa_empty(xa));1084 XA_BUG_ON(xa, !xa_empty(xa));
1126}1085}
@@ -1128,21 +1087,19 @@ static noinline void check_xa_alloc_3(struct kunit *test, struct xarray *xa, uns · 1 unmodified line
1128static DEFINE_XARRAY_ALLOC(xa0);1087static DEFINE_XARRAY_ALLOC(xa0);
1129static DEFINE_XARRAY_ALLOC1(xa1);1088static DEFINE_XARRAY_ALLOC1(xa1);
1130 1089
1131static noinline void check_xa_alloc(struct kunit *test)1090static noinline void check_xa_alloc(void)
1132{1091{
1133 check_xa_alloc_1(test, &xa0, 0);1092 check_xa_alloc_1(&xa0, 0);
1134 check_xa_alloc_1(test, &xa1, 1);1093 check_xa_alloc_1(&xa1, 1);
1135 check_xa_alloc_2(test, &xa0, 0);1094 check_xa_alloc_2(&xa0, 0);
1136 check_xa_alloc_2(test, &xa1, 1);1095 check_xa_alloc_2(&xa1, 1);
1137 check_xa_alloc_3(test, &xa0, 0);1096 check_xa_alloc_3(&xa0, 0);
1138 check_xa_alloc_3(test, &xa1, 1);1097 check_xa_alloc_3(&xa1, 1);
1139}1098}
1140 1099
1141static noinline void __check_store_iter(struct kunit *test, unsigned long start,1100static noinline void __check_store_iter(struct xarray *xa, unsigned long start,
1142 unsigned int order, unsigned int present)1101 unsigned int order, unsigned int present)
1143{1102{
1144 struct xarray *xa = xa_param(test);
1145
1146 XA_STATE_ORDER(xas, xa, start, order);1103 XA_STATE_ORDER(xas, xa, start, order);
1147 void *entry;1104 void *entry;
1148 unsigned int count = 0;1105 unsigned int count = 0;
@@ -1166,54 +1123,50 @@ retry: · 17 unmodified lines
1166 XA_BUG_ON(xa, xa_load(xa, start) != xa_mk_index(start));1123 XA_BUG_ON(xa, xa_load(xa, start) != xa_mk_index(start));
1167 XA_BUG_ON(xa, xa_load(xa, start + (1UL << order) - 1) !=1124 XA_BUG_ON(xa, xa_load(xa, start + (1UL << order) - 1) !=
1168 xa_mk_index(start));1125 xa_mk_index(start));
1169 xa_erase_index(test, xa, start);1126 xa_erase_index(xa, start);
1170}1127}
1171 1128
1172static noinline void check_store_iter(struct kunit *test)1129static noinline void check_store_iter(struct xarray *xa)
1173{1130{
1174 struct xarray *xa = xa_param(test);
1175
1176 unsigned int i, j;1131 unsigned int i, j;
1177 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;1132 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
1178 1133
1179 for (i = 0; i < max_order; i++) {1134 for (i = 0; i < max_order; i++) {
1180 unsigned int min = 1 << i;1135 unsigned int min = 1 << i;
1181 unsigned int max = (2 << i) - 1;1136 unsigned int max = (2 << i) - 1;
1182 __check_store_iter(test, 0, i, 0);1137 __check_store_iter(xa, 0, i, 0);
1183 XA_BUG_ON(xa, !xa_empty(xa));1138 XA_BUG_ON(xa, !xa_empty(xa));
1184 __check_store_iter(test, min, i, 0);1139 __check_store_iter(xa, min, i, 0);
1185 XA_BUG_ON(xa, !xa_empty(xa));1140 XA_BUG_ON(xa, !xa_empty(xa));
1186 1141
1187 xa_store_index(xa, min, GFP_KERNEL);1142 xa_store_index(xa, min, GFP_KERNEL);
1188 __check_store_iter(test, min, i, 1);1143 __check_store_iter(xa, min, i, 1);
1189 XA_BUG_ON(xa, !xa_empty(xa));1144 XA_BUG_ON(xa, !xa_empty(xa));
1190 xa_store_index(xa, max, GFP_KERNEL);1145 xa_store_index(xa, max, GFP_KERNEL);
1191 __check_store_iter(test, min, i, 1);1146 __check_store_iter(xa, min, i, 1);
1192 XA_BUG_ON(xa, !xa_empty(xa));1147 XA_BUG_ON(xa, !xa_empty(xa));
1193 1148
1194 for (j = 0; j < min; j++)1149 for (j = 0; j < min; j++)
1195 xa_store_index(xa, j, GFP_KERNEL);1150 xa_store_index(xa, j, GFP_KERNEL);
1196 __check_store_iter(test, 0, i, min);1151 __check_store_iter(xa, 0, i, min);
1197 XA_BUG_ON(xa, !xa_empty(xa));1152 XA_BUG_ON(xa, !xa_empty(xa));
1198 for (j = 0; j < min; j++)1153 for (j = 0; j < min; j++)
1199 xa_store_index(xa, min + j, GFP_KERNEL);1154 xa_store_index(xa, min + j, GFP_KERNEL);
1200 __check_store_iter(test, min, i, min);1155 __check_store_iter(xa, min, i, min);
1201 XA_BUG_ON(xa, !xa_empty(xa));1156 XA_BUG_ON(xa, !xa_empty(xa));
1202 }1157 }
1203#ifdef CONFIG_XARRAY_MULTI1158#ifdef CONFIG_XARRAY_MULTI
1204 xa_store_index(xa, 63, GFP_KERNEL);1159 xa_store_index(xa, 63, GFP_KERNEL);
1205 xa_store_index(xa, 65, GFP_KERNEL);1160 xa_store_index(xa, 65, GFP_KERNEL);
1206 __check_store_iter(test, 64, 2, 1);1161 __check_store_iter(xa, 64, 2, 1);
1207 xa_erase_index(test, xa, 63);1162 xa_erase_index(xa, 63);
1208#endif1163#endif
1209 XA_BUG_ON(xa, !xa_empty(xa));1164 XA_BUG_ON(xa, !xa_empty(xa));
1210}1165}
1211 1166
1212static noinline void check_multi_find_1(struct kunit *test, unsigned int order)1167static noinline void check_multi_find_1(struct xarray *xa, unsigned order)
1213{1168{
1214#ifdef CONFIG_XARRAY_MULTI1169#ifdef CONFIG_XARRAY_MULTI
1215 struct xarray *xa = xa_param(test);
1216
1217 unsigned long multi = 3 << order;1170 unsigned long multi = 3 << order;
1218 unsigned long next = 4 << order;1171 unsigned long next = 4 << order;
1219 unsigned long index;1172 unsigned long index;
@@ -1236,17 +1189,15 @@ static noinline void check_multi_find_1(struct kunit *test, unsigned int order) · 16 unmodified lines
1236 XA_BUG_ON(xa, xa_find_after(xa, &index, next, XA_PRESENT) != NULL);1189 XA_BUG_ON(xa, xa_find_after(xa, &index, next, XA_PRESENT) != NULL);
1237 XA_BUG_ON(xa, index != next);1190 XA_BUG_ON(xa, index != next);
1238 1191
1239 xa_erase_index(test, xa, multi);1192 xa_erase_index(xa, multi);
1240 xa_erase_index(test, xa, next);1193 xa_erase_index(xa, next);
1241 xa_erase_index(test, xa, next + 1);1194 xa_erase_index(xa, next + 1);
1242 XA_BUG_ON(xa, !xa_empty(xa));1195 XA_BUG_ON(xa, !xa_empty(xa));
1243#endif1196#endif
1244}1197}
1245 1198
1246static noinline void check_multi_find_2(struct kunit *test)1199static noinline void check_multi_find_2(struct xarray *xa)
1247{1200{
1248 struct xarray *xa = xa_param(test);
1249
1250 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 10 : 1;1201 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 10 : 1;
1251 unsigned int i, j;1202 unsigned int i, j;
1252 void *entry;1203 void *entry;
@@ -1260,19 +1211,17 @@ static noinline void check_multi_find_2(struct kunit *test) · 7 unmodified lines
1260 GFP_KERNEL);1211 GFP_KERNEL);
1261 rcu_read_lock();1212 rcu_read_lock();
1262 xas_for_each(&xas, entry, ULONG_MAX) {1213 xas_for_each(&xas, entry, ULONG_MAX) {
1263 xa_erase_index(test, xa, index);1214 xa_erase_index(xa, index);
1264 }1215 }
1265 rcu_read_unlock();1216 rcu_read_unlock();
1266 xa_erase_index(test, xa, index - 1);1217 xa_erase_index(xa, index - 1);
1267 XA_BUG_ON(xa, !xa_empty(xa));1218 XA_BUG_ON(xa, !xa_empty(xa));
1268 }1219 }
1269 }1220 }
1270}1221}
1271 1222
1272static noinline void check_multi_find_3(struct kunit *test)1223static noinline void check_multi_find_3(struct xarray *xa)
1273{1224{
1274 struct xarray *xa = xa_param(test);
1275
1276 unsigned int order;1225 unsigned int order;
1277 1226
1278 for (order = 5; order < order_limit; order++) {1227 for (order = 5; order < order_limit; order++) {
@@ -1281,14 +1230,12 @@ static noinline void check_multi_find_3(struct kunit *test) · 2 unmodified lines
1281 XA_BUG_ON(xa, !xa_empty(xa));1230 XA_BUG_ON(xa, !xa_empty(xa));
1282 xa_store_order(xa, 0, order - 4, xa_mk_index(0), GFP_KERNEL);1231 xa_store_order(xa, 0, order - 4, xa_mk_index(0), GFP_KERNEL);
1283 XA_BUG_ON(xa, xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT));1232 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);
1285 }1234 }
1286}1235}
1287 1236
1288static noinline void check_find_1(struct kunit *test)1237static noinline void check_find_1(struct xarray *xa)
1289{1238{
1290 struct xarray *xa = xa_param(test);
1291
1292 unsigned long i, j, k;1239 unsigned long i, j, k;
1293 1240
1294 XA_BUG_ON(xa, !xa_empty(xa));1241 XA_BUG_ON(xa, !xa_empty(xa));
@@ -1325,20 +1272,18 @@ static noinline void check_find_1(struct kunit *test) · 30 unmodified lines
1325 else1272 else
1326 XA_BUG_ON(xa, entry != NULL);1273 XA_BUG_ON(xa, entry != NULL);
1327 }1274 }
1328 xa_erase_index(test, xa, j);1275 xa_erase_index(xa, j);
1329 XA_BUG_ON(xa, xa_get_mark(xa, j, XA_MARK_0));1276 XA_BUG_ON(xa, xa_get_mark(xa, j, XA_MARK_0));
1330 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0));1277 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0));
1331 }1278 }
1332 xa_erase_index(test, xa, i);1279 xa_erase_index(xa, i);
1333 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_0));1280 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_0));
1334 }1281 }
1335 XA_BUG_ON(xa, !xa_empty(xa));1282 XA_BUG_ON(xa, !xa_empty(xa));
1336}1283}
1337 1284
1338static noinline void check_find_2(struct kunit *test)1285static noinline void check_find_2(struct xarray *xa)
1339{1286{
1340 struct xarray *xa = xa_param(test);
1341
1342 void *entry;1287 void *entry;
1343 unsigned long i, j, index;1288 unsigned long i, j, index;
1344 1289
@@ -1358,10 +1303,8 @@ static noinline void check_find_2(struct kunit *test) · 13 unmodified lines
1358 xa_destroy(xa);1303 xa_destroy(xa);
1359}1304}
1360 1305
1361static noinline void check_find_3(struct kunit *test)1306static noinline void check_find_3(struct xarray *xa)
1362{1307{
1363 struct xarray *xa = xa_param(test);
1364
1365 XA_STATE(xas, xa, 0);1308 XA_STATE(xas, xa, 0);
1366 unsigned long i, j, k;1309 unsigned long i, j, k;
1367 void *entry;1310 void *entry;
@@ -1385,10 +1328,8 @@ static noinline void check_find_3(struct kunit *test) · 17 unmodified lines
1385 xa_destroy(xa);1328 xa_destroy(xa);
1386}1329}
1387 1330
1388static noinline void check_find_4(struct kunit *test)1331static noinline void check_find_4(struct xarray *xa)
1389{1332{
1390 struct xarray *xa = xa_param(test);
1391
1392 unsigned long index = 0;1333 unsigned long index = 0;
1393 void *entry;1334 void *entry;
1394 1335
@@ -1400,22 +1341,22 @@ static noinline void check_find_4(struct kunit *test) · 5 unmodified lines
1400 entry = xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT);1341 entry = xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT);
1401 XA_BUG_ON(xa, entry);1342 XA_BUG_ON(xa, entry);
1402 1343
1403 xa_erase_index(test, xa, ULONG_MAX);1344 xa_erase_index(xa, ULONG_MAX);
1404}1345}
1405 1346
1406static noinline void check_find(struct kunit *test)1347static noinline void check_find(struct xarray *xa)
1407{1348{
1408 unsigned i;1349 unsigned i;
1409 1350
1410 check_find_1(test);1351 check_find_1(xa);
1411 check_find_2(test);1352 check_find_2(xa);
1412 check_find_3(test);1353 check_find_3(xa);
1413 check_find_4(test);1354 check_find_4(xa);
1414 1355
1415 for (i = 2; i < 10; i++)1356 for (i = 2; i < 10; i++)
1416 check_multi_find_1(test, i);1357 check_multi_find_1(xa, i);
1417 check_multi_find_2(test);1358 check_multi_find_2(xa);
1418 check_multi_find_3(test);1359 check_multi_find_3(xa);
1419}1360}
1420 1361
1421/* See find_swap_entry() in mm/shmem.c */1362/* 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
1441 return entry ? xas.xa_index : -1;1382 return entry ? xas.xa_index : -1;
1442}1383}
1443 1384
1444static noinline void check_find_entry(struct kunit *test)1385static noinline void check_find_entry(struct xarray *xa)
1445{1386{
1446 struct xarray *xa = xa_param(test);
1447
1448#ifdef CONFIG_XARRAY_MULTI1387#ifdef CONFIG_XARRAY_MULTI
1449 unsigned int order;1388 unsigned int order;
1450 unsigned long offset, index;1389 unsigned long offset, index;
@@ -1471,14 +1410,12 @@ static noinline void check_find_entry(struct kunit *test) · 20 unmodified lines
1471 xa_store_index(xa, ULONG_MAX, GFP_KERNEL);1410 xa_store_index(xa, ULONG_MAX, GFP_KERNEL);
1472 XA_BUG_ON(xa, xa_find_entry(xa, xa) != -1);1411 XA_BUG_ON(xa, xa_find_entry(xa, xa) != -1);
1473 XA_BUG_ON(xa, xa_find_entry(xa, xa_mk_index(ULONG_MAX)) != -1);1412 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);
1475 XA_BUG_ON(xa, !xa_empty(xa));1414 XA_BUG_ON(xa, !xa_empty(xa));
1476}1415}
1477 1416
1478static noinline void check_pause(struct kunit *test)1417static noinline void check_pause(struct xarray *xa)
1479{1418{
1480 struct xarray *xa = xa_param(test);
1481
1482 XA_STATE(xas, xa, 0);1419 XA_STATE(xas, xa, 0);
1483 void *entry;1420 void *entry;
1484 unsigned int order;1421 unsigned int order;
@@ -1548,10 +1485,8 @@ static noinline void check_pause(struct kunit *test) · 63 unmodified lines
1548 1485
1549}1486}
1550 1487
1551static noinline void check_move_tiny(struct kunit *test)1488static noinline void check_move_tiny(struct xarray *xa)
1552{1489{
1553 struct xarray *xa = xa_param(test);
1554
1555 XA_STATE(xas, xa, 0);1490 XA_STATE(xas, xa, 0);
1556 1491
1557 XA_BUG_ON(xa, !xa_empty(xa));1492 XA_BUG_ON(xa, !xa_empty(xa));
@@ -1568,14 +1503,12 @@ static noinline void check_move_tiny(struct kunit *test) · 10 unmodified lines
1568 XA_BUG_ON(xa, xas_prev(&xas) != xa_mk_index(0));1503 XA_BUG_ON(xa, xas_prev(&xas) != xa_mk_index(0));
1569 XA_BUG_ON(xa, xas_prev(&xas) != NULL);1504 XA_BUG_ON(xa, xas_prev(&xas) != NULL);
1570 rcu_read_unlock();1505 rcu_read_unlock();
1571 xa_erase_index(test, xa, 0);1506 xa_erase_index(xa, 0);
1572 XA_BUG_ON(xa, !xa_empty(xa));1507 XA_BUG_ON(xa, !xa_empty(xa));
1573}1508}
1574 1509
1575static noinline void check_move_max(struct kunit *test)1510static noinline void check_move_max(struct xarray *xa)
1576{1511{
1577 struct xarray *xa = xa_param(test);
1578
1579 XA_STATE(xas, xa, 0);1512 XA_STATE(xas, xa, 0);
1580 1513
1581 xa_store_index(xa, ULONG_MAX, GFP_KERNEL);1514 xa_store_index(xa, ULONG_MAX, GFP_KERNEL);
@@ -1591,14 +1524,12 @@ static noinline void check_move_max(struct kunit *test) · 9 unmodified lines
1591 XA_BUG_ON(xa, xas_find(&xas, ULONG_MAX) != NULL);1524 XA_BUG_ON(xa, xas_find(&xas, ULONG_MAX) != NULL);
1592 rcu_read_unlock();1525 rcu_read_unlock();
1593 1526
1594 xa_erase_index(test, xa, ULONG_MAX);1527 xa_erase_index(xa, ULONG_MAX);
1595 XA_BUG_ON(xa, !xa_empty(xa));1528 XA_BUG_ON(xa, !xa_empty(xa));
1596}1529}
1597 1530
1598static noinline void check_move_small(struct kunit *test, unsigned long idx)1531static noinline void check_move_small(struct xarray *xa, unsigned long idx)
1599{1532{
1600 struct xarray *xa = xa_param(test);
1601
1602 XA_STATE(xas, xa, 0);1533 XA_STATE(xas, xa, 0);
1603 unsigned long i;1534 unsigned long i;
1604 1535
@@ -1640,15 +1571,13 @@ static noinline void check_move_small(struct kunit *test, unsigned long idx) · 35 unmodified lines
1640 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX);1571 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX);
1641 rcu_read_unlock();1572 rcu_read_unlock();
1642 1573
1643 xa_erase_index(test, xa, 0);1574 xa_erase_index(xa, 0);
1644 xa_erase_index(test, xa, idx);1575 xa_erase_index(xa, idx);
1645 XA_BUG_ON(xa, !xa_empty(xa));1576 XA_BUG_ON(xa, !xa_empty(xa));
1646}1577}
1647 1578
1648static noinline void check_move(struct kunit *test)1579static noinline void check_move(struct xarray *xa)
1649{1580{
1650 struct xarray *xa = xa_param(test);
1651
1652 XA_STATE(xas, xa, (1 << 16) - 1);1581 XA_STATE(xas, xa, (1 << 16) - 1);
1653 unsigned long i;1582 unsigned long i;
1654 1583
@@ -1675,7 +1604,7 @@ static noinline void check_move(struct kunit *test) · 20 unmodified lines
1675 rcu_read_unlock();1604 rcu_read_unlock();
1676 1605
1677 for (i = (1 << 8); i < (1 << 15); i++)1606 for (i = (1 << 8); i < (1 << 15); i++)
1678 xa_erase_index(test, xa, i);1607 xa_erase_index(xa, i);
1679 1608
1680 i = xas.xa_index;1609 i = xas.xa_index;
1681 1610
@@ -1706,17 +1635,17 @@ static noinline void check_move(struct kunit *test) · 24 unmodified lines
1706 1635
1707 xa_destroy(xa);1636 xa_destroy(xa);
1708 1637
1709 check_move_tiny(test);1638 check_move_tiny(xa);
1710 check_move_max(test);1639 check_move_max(xa);
1711 1640
1712 for (i = 0; i < 16; i++)1641 for (i = 0; i < 16; i++)
1713 check_move_small(test, 1UL << i);1642 check_move_small(xa, 1UL << i);
1714 1643
1715 for (i = 2; i < 16; i++)1644 for (i = 2; i < 16; i++)
1716 check_move_small(test, (1UL << i) - 1);1645 check_move_small(xa, (1UL << i) - 1);
1717}1646}
1718 1647
1719static noinline void xa_store_many_order(struct kunit *test, struct xarray *xa,1648static noinline void xa_store_many_order(struct xarray *xa,
1720 unsigned long index, unsigned order)1649 unsigned long index, unsigned order)
1721{1650{
1722 XA_STATE_ORDER(xas, xa, index, order);1651 XA_STATE_ORDER(xas, xa, index, order);
@@ -1739,34 +1668,30 @@ unlock: · 16 unmodified lines
1739 XA_BUG_ON(xa, xas_error(&xas));1668 XA_BUG_ON(xa, xas_error(&xas));
1740}1669}
1741 1670
1742static noinline void check_create_range_1(struct kunit *test,1671static noinline void check_create_range_1(struct xarray *xa,
1743 unsigned long index, unsigned order)1672 unsigned long index, unsigned order)
1744{1673{
1745 struct xarray *xa = xa_param(test);
1746
1747 unsigned long i;1674 unsigned long i;
1748 1675
1749 xa_store_many_order(test, xa, index, order);1676 xa_store_many_order(xa, index, order);
1750 for (i = index; i < index + (1UL << order); i++)1677 for (i = index; i < index + (1UL << order); i++)
1751 xa_erase_index(test, xa, i);1678 xa_erase_index(xa, i);
1752 XA_BUG_ON(xa, !xa_empty(xa));1679 XA_BUG_ON(xa, !xa_empty(xa));
1753}1680}
1754 1681
1755static noinline void check_create_range_2(struct kunit *test, unsigned int order)1682static noinline void check_create_range_2(struct xarray *xa, unsigned order)
1756{1683{
1757 struct xarray *xa = xa_param(test);
1758
1759 unsigned long i;1684 unsigned long i;
1760 unsigned long nr = 1UL << order;1685 unsigned long nr = 1UL << order;
1761 1686
1762 for (i = 0; i < nr * nr; i += nr)1687 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);
1764 for (i = 0; i < nr * nr; i++)1689 for (i = 0; i < nr * nr; i++)
1765 xa_erase_index(test, xa, i);1690 xa_erase_index(xa, i);
1766 XA_BUG_ON(xa, !xa_empty(xa));1691 XA_BUG_ON(xa, !xa_empty(xa));
1767}1692}
1768 1693
1769static noinline void check_create_range_3(struct kunit *test)1694static noinline void check_create_range_3(void)
1770{1695{
1771 XA_STATE(xas, NULL, 0);1696 XA_STATE(xas, NULL, 0);
1772 xas_set_err(&xas, -EEXIST);1697 xas_set_err(&xas, -EEXIST);
@@ -1774,11 +1699,9 @@ static noinline void check_create_range_3(struct kunit *test) · 1 unmodified line
1774 XA_BUG_ON(NULL, xas_error(&xas) != -EEXIST);1699 XA_BUG_ON(NULL, xas_error(&xas) != -EEXIST);
1775}1700}
1776 1701
1777static noinline void check_create_range_4(struct kunit *test,1702static noinline void check_create_range_4(struct xarray *xa,
1778 unsigned long index, unsigned order)1703 unsigned long index, unsigned order)
1779{1704{
1780 struct xarray *xa = xa_param(test);
1781
1782 XA_STATE_ORDER(xas, xa, index, order);1705 XA_STATE_ORDER(xas, xa, index, order);
1783 unsigned long base = xas.xa_index;1706 unsigned long base = xas.xa_index;
1784 unsigned long i = 0;1707 unsigned long i = 0;
@@ -1804,15 +1727,13 @@ unlock: · 19 unmodified lines
1804 XA_BUG_ON(xa, xas_error(&xas));1727 XA_BUG_ON(xa, xas_error(&xas));
1805 1728
1806 for (i = base; i < base + (1UL << order); i++)1729 for (i = base; i < base + (1UL << order); i++)
1807 xa_erase_index(test, xa, i);1730 xa_erase_index(xa, i);
1808 XA_BUG_ON(xa, !xa_empty(xa));1731 XA_BUG_ON(xa, !xa_empty(xa));
1809}1732}
1810 1733
1811static noinline void check_create_range_5(struct kunit *test,1734static noinline void check_create_range_5(struct xarray *xa,
1812 unsigned long index, unsigned int order)1735 unsigned long index, unsigned int order)
1813{1736{
1814 struct xarray *xa = xa_param(test);
1815
1816 XA_STATE_ORDER(xas, xa, index, order);1737 XA_STATE_ORDER(xas, xa, index, order);
1817 unsigned int i;1738 unsigned int i;
1818 1739
@@ -1829,46 +1750,44 @@ static noinline void check_create_range_5(struct kunit *test, · 10 unmodified lines
1829 xa_destroy(xa);1750 xa_destroy(xa);
1830}1751}
1831 1752
1832static noinline void check_create_range(struct kunit *test)1753static noinline void check_create_range(struct xarray *xa)
1833{1754{
1834 unsigned int order;1755 unsigned int order;
1835 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 12 : 1;1756 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 12 : 1;
1836 1757
1837 for (order = 0; order < max_order; order++) {1758 for (order = 0; order < max_order; order++) {
1838 check_create_range_1(test, 0, order);1759 check_create_range_1(xa, 0, order);
1839 check_create_range_1(test, 1U << order, order);1760 check_create_range_1(xa, 1U << order, order);
1840 check_create_range_1(test, 2U << order, order);1761 check_create_range_1(xa, 2U << order, order);
1841 check_create_range_1(test, 3U << order, order);1762 check_create_range_1(xa, 3U << order, order);
1842 check_create_range_1(test, 1U << 24, order);1763 check_create_range_1(xa, 1U << 24, order);
1843 if (order < 10)1764 if (order < 10)
1844 check_create_range_2(test, order);1765 check_create_range_2(xa, order);
1845 1766
1846 check_create_range_4(test, 0, order);1767 check_create_range_4(xa, 0, order);
1847 check_create_range_4(test, 1U << order, order);1768 check_create_range_4(xa, 1U << order, order);
1848 check_create_range_4(test, 2U << order, order);1769 check_create_range_4(xa, 2U << order, order);
1849 check_create_range_4(test, 3U << order, order);1770 check_create_range_4(xa, 3U << order, order);
1850 check_create_range_4(test, 1U << 24, order);1771 check_create_range_4(xa, 1U << 24, order);
1851 1772
1852 check_create_range_4(test, 1, order);1773 check_create_range_4(xa, 1, order);
1853 check_create_range_4(test, (1U << order) + 1, order);1774 check_create_range_4(xa, (1U << order) + 1, order);
1854 check_create_range_4(test, (2U << order) + 1, order);1775 check_create_range_4(xa, (2U << order) + 1, order);
1855 check_create_range_4(test, (2U << order) - 1, order);1776 check_create_range_4(xa, (2U << order) - 1, order);
1856 check_create_range_4(test, (3U << order) + 1, order);1777 check_create_range_4(xa, (3U << order) + 1, order);
1857 check_create_range_4(test, (3U << order) - 1, order);1778 check_create_range_4(xa, (3U << order) - 1, order);
1858 check_create_range_4(test, (1U << 24) + 1, order);1779 check_create_range_4(xa, (1U << 24) + 1, order);
1859 1780
1860 check_create_range_5(test, 0, order);1781 check_create_range_5(xa, 0, order);
1861 check_create_range_5(test, (1U << order), order);1782 check_create_range_5(xa, (1U << order), order);
1862 }1783 }
1863 1784
1864 check_create_range_3(test);1785 check_create_range_3();
1865}1786}
1866 1787
1867static noinline void __check_store_range(struct kunit *test, unsigned long first,1788static noinline void __check_store_range(struct xarray *xa, unsigned long first,
1868 unsigned long last)1789 unsigned long last)
1869{1790{
1870 struct xarray *xa = xa_param(test);
1871
1872#ifdef CONFIG_XARRAY_MULTI1791#ifdef CONFIG_XARRAY_MULTI
1873 xa_store_range(xa, first, last, xa_mk_index(first), GFP_KERNEL);1792 xa_store_range(xa, first, last, xa_mk_index(first), GFP_KERNEL);
1874 1793
@@ -1883,28 +1802,26 @@ static noinline void __check_store_range(struct kunit *test, unsigned long first · 8 unmodified lines
1883 XA_BUG_ON(xa, !xa_empty(xa));1802 XA_BUG_ON(xa, !xa_empty(xa));
1884}1803}
1885 1804
1886static noinline void check_store_range(struct kunit *test)1805static noinline void check_store_range(struct xarray *xa)
1887{1806{
1888 unsigned long i, j;1807 unsigned long i, j;
1889 1808
1890 for (i = 0; i < 128; i++) {1809 for (i = 0; i < 128; i++) {
1891 for (j = i; j < 128; j++) {1810 for (j = i; j < 128; j++) {
1892 __check_store_range(test, i, j);1811 __check_store_range(xa, i, j);
1893 __check_store_range(test, 128 + i, 128 + j);1812 __check_store_range(xa, 128 + i, 128 + j);
1894 __check_store_range(test, 4095 + i, 4095 + j);1813 __check_store_range(xa, 4095 + i, 4095 + j);
1895 __check_store_range(test, 4096 + i, 4096 + j);1814 __check_store_range(xa, 4096 + i, 4096 + j);
1896 __check_store_range(test, 123456 + i, 123456 + j);1815 __check_store_range(xa, 123456 + i, 123456 + j);
1897 __check_store_range(test, (1 << 24) + i, (1 << 24) + j);1816 __check_store_range(xa, (1 << 24) + i, (1 << 24) + j);
1898 }1817 }
1899 }1818 }
1900}1819}
1901 1820
1902#ifdef CONFIG_XARRAY_MULTI1821#ifdef CONFIG_XARRAY_MULTI
1903static void check_split_1(struct kunit *test, unsigned long index,1822static void check_split_1(struct xarray *xa, unsigned long index,
1904 unsigned int order, unsigned int new_order)1823 unsigned int order, unsigned int new_order)
1905{1824{
1906 struct xarray *xa = xa_param(test);
1907
1908 XA_STATE_ORDER(xas, xa, index, new_order);1825 XA_STATE_ORDER(xas, xa, index, new_order);
1909 unsigned int i, found;1826 unsigned int i, found;
1910 void *entry;1827 void *entry;
@@ -1940,30 +1857,26 @@ static void check_split_1(struct kunit *test, unsigned long index, · 29 unmodified lines
1940 xa_destroy(xa);1857 xa_destroy(xa);
1941}1858}
1942 1859
1943static noinline void check_split(struct kunit *test)1860static noinline void check_split(struct xarray *xa)
1944{1861{
1945 struct xarray *xa = xa_param(test);
1946
1947 unsigned int order, new_order;1862 unsigned int order, new_order;
1948 1863
1949 XA_BUG_ON(xa, !xa_empty(xa));1864 XA_BUG_ON(xa, !xa_empty(xa));
1950 1865
1951 for (order = 1; order < 2 * XA_CHUNK_SHIFT; order++) {1866 for (order = 1; order < 2 * XA_CHUNK_SHIFT; order++) {
1952 for (new_order = 0; new_order < order; new_order++) {1867 for (new_order = 0; new_order < order; new_order++) {
1953 check_split_1(test, 0, order, new_order);1868 check_split_1(xa, 0, order, new_order);
1954 check_split_1(test, 1UL << order, order, new_order);1869 check_split_1(xa, 1UL << order, order, new_order);
1955 check_split_1(test, 3UL << order, order, new_order);1870 check_split_1(xa, 3UL << order, order, new_order);
1956 }1871 }
1957 }1872 }
1958}1873}
1959#else1874#else
1960static void check_split(struct kunit *test) { }1875static void check_split(struct xarray *xa) { }
1961#endif1876#endif
1962 1877
1963static void check_align_1(struct kunit *test, char *name)1878static void check_align_1(struct xarray *xa, char *name)
1964{1879{
1965 struct xarray *xa = xa_param(test);
1966
1967 int i;1880 int i;
1968 unsigned int id;1881 unsigned int id;
1969 unsigned long index;1882 unsigned long index;
@@ -1983,10 +1896,8 @@ static void check_align_1(struct kunit *test, char *name) · 13 unmodified lines
1983 * We should always be able to store without allocating memory after1896 * We should always be able to store without allocating memory after
1984 * reserving a slot.1897 * reserving a slot.
1985 */1898 */
1986static void check_align_2(struct kunit *test, char *name)1899static void check_align_2(struct xarray *xa, char *name)
1987{1900{
1988 struct xarray *xa = xa_param(test);
1989
1990 int i;1901 int i;
1991 1902
1992 XA_BUG_ON(xa, !xa_empty(xa));1903 XA_BUG_ON(xa, !xa_empty(xa));
@@ -2005,15 +1916,15 @@ static void check_align_2(struct kunit *test, char *name) · 12 unmodified lines
2005 XA_BUG_ON(xa, !xa_empty(xa));1916 XA_BUG_ON(xa, !xa_empty(xa));
2006}1917}
2007 1918
2008static noinline void check_align(struct kunit *test)1919static noinline void check_align(struct xarray *xa)
2009{1920{
2010 char name[] = "Motorola 68000";1921 char name[] = "Motorola 68000";
2011 1922
2012 check_align_1(test, name);1923 check_align_1(xa, name);
2013 check_align_1(test, name + 1);1924 check_align_1(xa, name + 1);
2014 check_align_1(test, name + 2);1925 check_align_1(xa, name + 2);
2015 check_align_1(test, name + 3);1926 check_align_1(xa, name + 3);
2016 check_align_2(test, name);1927 check_align_2(xa, name);
2017}1928}
2018 1929
2019static LIST_HEAD(shadow_nodes);1930static LIST_HEAD(shadow_nodes);
@@ -2029,7 +1940,7 @@ static void test_update_node(struct xa_node *node) · 9 unmodified lines
2029 }1940 }
2030}1941}
2031 1942
2032static noinline void shadow_remove(struct kunit *test, struct xarray *xa)1943static noinline void shadow_remove(struct xarray *xa)
2033{1944{
2034 struct xa_node *node;1945 struct xa_node *node;
2035 1946
@@ -2043,17 +1954,8 @@ static noinline void shadow_remove(struct kunit *test, struct xarray *xa) · 7 unmodified lines
2043 xa_unlock(xa);1954 xa_unlock(xa);
2044}1955}
2045 1956
2046struct workingset_testcase {1957static noinline void check_workingset(struct xarray *xa, unsigned long index)
2047 struct xarray *xa;
2048 unsigned long index;
2049};
2050
2051static noinline void check_workingset(struct kunit *test)
2052{1958{
2053 struct workingset_testcase tc = *(struct workingset_testcase *)test->param_value;
2054 struct xarray *xa = tc.xa;
2055 unsigned long index = tc.index;
2056
2057 XA_STATE(xas, xa, index);1959 XA_STATE(xas, xa, index);
2058 xas_set_update(&xas, test_update_node);1960 xas_set_update(&xas, test_update_node);
2059 1961
@@ -2076,7 +1978,7 @@ static noinline void check_workingset(struct kunit *test) · 16 unmodified lines
2076 xas_unlock(&xas);1978 xas_unlock(&xas);
2077 XA_BUG_ON(xa, list_empty(&shadow_nodes));1979 XA_BUG_ON(xa, list_empty(&shadow_nodes));
2078 1980
2079 shadow_remove(test, xa);1981 shadow_remove(xa);
2080 XA_BUG_ON(xa, !list_empty(&shadow_nodes));1982 XA_BUG_ON(xa, !list_empty(&shadow_nodes));
2081 XA_BUG_ON(xa, !xa_empty(xa));1983 XA_BUG_ON(xa, !xa_empty(xa));
2082}1984}
@@ -2085,11 +1987,9 @@ static noinline void check_workingset(struct kunit *test) · 2 unmodified lines
2085 * Check that the pointer / value / sibling entries are accounted the1987 * Check that the pointer / value / sibling entries are accounted the
2086 * way we expect them to be.1988 * way we expect them to be.
2087 */1989 */
2088static noinline void check_account(struct kunit *test)1990static noinline void check_account(struct xarray *xa)
2089{1991{
2090#ifdef CONFIG_XARRAY_MULTI1992#ifdef CONFIG_XARRAY_MULTI
2091 struct xarray *xa = xa_param(test);
2092
2093 unsigned int order;1993 unsigned int order;
2094 1994
2095 for (order = 1; order < 12; order++) {1995 for (order = 1; order < 12; order++) {
@@ -2116,10 +2016,8 @@ static noinline void check_account(struct kunit *test) · 20 unmodified lines
2116#endif2016#endif
2117}2017}
2118 2018
2119static noinline void check_get_order(struct kunit *test)2019static noinline void check_get_order(struct xarray *xa)
2120{2020{
2121 struct xarray *xa = xa_param(test);
2122
2123 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;2021 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
2124 unsigned int order;2022 unsigned int order;
2125 unsigned long i, j;2023 unsigned long i, j;
@@ -2138,10 +2036,8 @@ static noinline void check_get_order(struct kunit *test) · 12 unmodified lines
2138 }2036 }
2139}2037}
2140 2038
2141static noinline void check_xas_get_order(struct kunit *test)2039static noinline void check_xas_get_order(struct xarray *xa)
2142{2040{
2143 struct xarray *xa = xa_param(test);
2144
2145 XA_STATE(xas, xa, 0);2041 XA_STATE(xas, xa, 0);
2146 2042
2147 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;2043 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
2173 }2069 }
2174}2070}
2175 2071
2176static noinline void check_xas_conflict_get_order(struct kunit *test)2072static noinline void check_xas_conflict_get_order(struct xarray *xa)
2177{2073{
2178 struct xarray *xa = xa_param(test);
2179
2180 XA_STATE(xas, xa, 0);2074 XA_STATE(xas, xa, 0);
2181 2075
2182 void *entry;2076 void *entry;
@@ -2233,10 +2127,8 @@ static noinline void check_xas_conflict_get_order(struct kunit *test) · 50 unmodified lines
2233}2127}
2234 2128
2235 2129
2236static noinline void check_destroy(struct kunit *test)2130static noinline void check_destroy(struct xarray *xa)
2237{2131{
2238 struct xarray *xa = xa_param(test);
2239
2240 unsigned long index;2132 unsigned long index;
2241 2133
2242 XA_BUG_ON(xa, !xa_empty(xa));2134 XA_BUG_ON(xa, !xa_empty(xa));
@@ -2269,59 +2161,52 @@ static noinline void check_destroy(struct kunit *test) · 26 unmodified lines
2269}2161}
2270 2162
2271static DEFINE_XARRAY(array);2163static DEFINE_XARRAY(array);
2272static struct xarray *arrays[] = { &array };
2273KUNIT_ARRAY_PARAM(array, arrays, NULL);
2274
2275static struct xarray *xa0s[] = { &xa0 };
2276KUNIT_ARRAY_PARAM(xa0, xa0s, NULL);
2277
2278static struct workingset_testcase workingset_testcases[] = {
2279 { &array, 0 },
2280 { &array, 64 },
2281 { &array, 4096 },
2282};
2283KUNIT_ARRAY_PARAM(workingset, workingset_testcases, NULL);
2284
2285static 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
2318static struct kunit_suite xarray_suite = {
2319 .name = "xarray",
2320 .test_cases = xarray_cases,
2321};
2322
2323kunit_test_suite(xarray_suite);
2324 2164
2165static 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
2204static void xarray_exit(void)
2205{
2206}
2207
2208module_init(xarray_checks);
2209module_exit(xarray_exit);
2325MODULE_AUTHOR("Matthew Wilcox <willy@infradead.org>");2210MODULE_AUTHOR("Matthew Wilcox <willy@infradead.org>");
2326MODULE_DESCRIPTION("XArray API test module");2211MODULE_DESCRIPTION("XArray API test module");
2327MODULE_LICENSE("GPL");2212MODULE_LICENSE("GPL");
mm/compaction.c+25−4
@@ -2491,7 +2491,8 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, · 2490 unmodified lines
2491 */2491 */
2492static enum compact_result2492static enum compact_result
2493compaction_suit_allocation_order(struct zone *zone, unsigned int order,2493compaction_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)
2495{2496{
2496 unsigned long watermark;2497 unsigned long watermark;
2497 2498
@@ -2500,6 +2501,23 @@ compaction_suit_allocation_order(struct zone *zone, unsigned int order, · 2 unmodified lines
2500 alloc_flags))2501 alloc_flags))
2501 return COMPACT_SUCCESS;2502 return COMPACT_SUCCESS;
2502 2503
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
2503 if (!compaction_suitable(zone, order, highest_zoneidx))2521 if (!compaction_suitable(zone, order, highest_zoneidx))
2504 return COMPACT_SKIPPED;2522 return COMPACT_SKIPPED;
2505 2523
@@ -2535,7 +2553,8 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) · 29 unmodified lines
2535 if (!is_via_compact_memory(cc->order)) {2553 if (!is_via_compact_memory(cc->order)) {
2536 ret = compaction_suit_allocation_order(cc->zone, cc->order,2554 ret = compaction_suit_allocation_order(cc->zone, cc->order,
2537 cc->highest_zoneidx,2555 cc->highest_zoneidx,
2538 cc->alloc_flags);2556 cc->alloc_flags,
2557 cc->mode == MIGRATE_ASYNC);
2539 if (ret != COMPACT_CONTINUE)2558 if (ret != COMPACT_CONTINUE)
2540 return ret;2559 return ret;
2541 }2560 }
@@ -3038,7 +3057,8 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat) · 496 unmodified lines
3038 3057
3039 ret = compaction_suit_allocation_order(zone,3058 ret = compaction_suit_allocation_order(zone,
3040 pgdat->kcompactd_max_order,3059 pgdat->kcompactd_max_order,
3041 highest_zoneidx, ALLOC_WMARK_MIN);3060 highest_zoneidx, ALLOC_WMARK_MIN,
3061 false);
3042 if (ret == COMPACT_CONTINUE)3062 if (ret == COMPACT_CONTINUE)
3043 return true;3063 return true;
3044 }3064 }
@@ -3079,7 +3099,8 @@ static void kcompactd_do_work(pg_data_t *pgdat) · 34 unmodified lines
3079 continue;3099 continue;
3080 3100
3081 ret = compaction_suit_allocation_order(zone,3101 ret = compaction_suit_allocation_order(zone,
3082 cc.order, zoneid, ALLOC_WMARK_MIN);3102 cc.order, zoneid, ALLOC_WMARK_MIN,
3103 false);
3083 if (ret != COMPACT_CONTINUE)3104 if (ret != COMPACT_CONTINUE)
3084 continue;3105 continue;
3085 3106
mm/gup.c+4−10
@@ -2320,13 +2320,13 @@ static void pofs_unpin(struct pages_or_folios *pofs) · 2319 unmodified lines
2320/*2320/*
2321 * Returns the number of collected folios. Return value is always >= 0.2321 * Returns the number of collected folios. Return value is always >= 0.
2322 */2322 */
2323static unsigned long collect_longterm_unpinnable_folios(2323static void collect_longterm_unpinnable_folios(
2324 struct list_head *movable_folio_list,2324 struct list_head *movable_folio_list,
2325 struct pages_or_folios *pofs)2325 struct pages_or_folios *pofs)
2326{2326{
2327 unsigned long i, collected = 0;
2328 struct folio *prev_folio = NULL;2327 struct folio *prev_folio = NULL;
2329 bool drain_allow = true;2328 bool drain_allow = true;
2329 unsigned long i;
2330 2330
2331 for (i = 0; i < pofs->nr_entries; i++) {2331 for (i = 0; i < pofs->nr_entries; i++) {
2332 struct folio *folio = pofs_get_folio(pofs, i);2332 struct folio *folio = pofs_get_folio(pofs, i);
@@ -2338,8 +2338,6 @@ static unsigned long collect_longterm_unpinnable_folios( · 5 unmodified lines
2338 if (folio_is_longterm_pinnable(folio))2338 if (folio_is_longterm_pinnable(folio))
2339 continue;2339 continue;
2340 2340
2341 collected++;
2342
2343 if (folio_is_device_coherent(folio))2341 if (folio_is_device_coherent(folio))
2344 continue;2342 continue;
2345 2343
@@ -2361,8 +2359,6 @@ static unsigned long collect_longterm_unpinnable_folios( · 15 unmodified lines
2361 NR_ISOLATED_ANON + folio_is_file_lru(folio),2359 NR_ISOLATED_ANON + folio_is_file_lru(folio),
2362 folio_nr_pages(folio));2360 folio_nr_pages(folio));
2363 }2361 }
2364
2365 return collected;
2366}2362}
2367 2363
2368/*2364/*
@@ -2439,11 +2435,9 @@ static long · 70 unmodified lines
2439check_and_migrate_movable_pages_or_folios(struct pages_or_folios *pofs)2435check_and_migrate_movable_pages_or_folios(struct pages_or_folios *pofs)
2440{2436{
2441 LIST_HEAD(movable_folio_list);2437 LIST_HEAD(movable_folio_list);
2442 unsigned long collected;
2443 2438
2444 collected = collect_longterm_unpinnable_folios(&movable_folio_list,2439 collect_longterm_unpinnable_folios(&movable_folio_list, pofs);
2445 pofs);2440 if (list_empty(&movable_folio_list))
2446 if (!collected)
2447 return 0;2441 return 0;
2448 2442
2449 return migrate_longterm_unpinnable_folios(&movable_folio_list, pofs);2443 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
3309 .thread_fn = gather_bootmem_prealloc_parallel,3309 .thread_fn = gather_bootmem_prealloc_parallel,
3310 .fn_arg = NULL,3310 .fn_arg = NULL,
3311 .start = 0,3311 .start = 0,
3312 .size = num_node_state(N_MEMORY),3312 .size = nr_node_ids,
3313 .align = 1,3313 .align = 1,
3314 .min_chunk = 1,3314 .min_chunk = 1,
3315 .max_threads = num_node_state(N_MEMORY),3315 .max_threads = num_node_state(N_MEMORY),
mm/kfence/core.c+2−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#include <linux/log2.h>21#include <linux/log2.h>
22#include <linux/memblock.h>22#include <linux/memblock.h>
23#include <linux/moduleparam.h>23#include <linux/moduleparam.h>
24#include <linux/nodemask.h>
24#include <linux/notifier.h>25#include <linux/notifier.h>
25#include <linux/panic_notifier.h>26#include <linux/panic_notifier.h>
26#include <linux/random.h>27#include <linux/random.h>
@@ -1084,6 +1085,7 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags) · 1057 unmodified lines
1084 * properties (e.g. reside in DMAable memory).1085 * properties (e.g. reside in DMAable memory).
1085 */1086 */
1086 if ((flags & GFP_ZONEMASK) ||1087 if ((flags & GFP_ZONEMASK) ||
1088 ((flags & __GFP_THISNODE) && num_online_nodes() > 1) ||
1087 (s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) {1089 (s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) {
1088 atomic_long_inc(&counters[KFENCE_COUNTER_SKIP_INCOMPAT]);1090 atomic_long_inc(&counters[KFENCE_COUNTER_SKIP_INCOMPAT]);
1089 return NULL;1091 return NULL;
mm/kmemleak.c+1−1
@@ -1689,7 +1689,7 @@ static void kmemleak_scan(void) · 1688 unmodified lines
1689 unsigned long phys = object->pointer;1689 unsigned long phys = object->pointer;
1690 1690
1691 if (PHYS_PFN(phys) < min_low_pfn ||1691 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)
1693 __paint_it(object, KMEMLEAK_BLACK);1693 __paint_it(object, KMEMLEAK_BLACK);
1694 }1694 }
1695 1695
mm/swapfile.c+1−1
@@ -794,7 +794,7 @@ static unsigned int alloc_swap_scan_cluster(struct swap_info_struct *si, · 793 unmodified lines
794 if (!cluster_scan_range(si, ci, offset, nr_pages, &need_reclaim))794 if (!cluster_scan_range(si, ci, offset, nr_pages, &need_reclaim))
795 continue;795 continue;
796 if (need_reclaim) {796 if (need_reclaim) {
797 ret = cluster_reclaim_range(si, ci, start, end);797 ret = cluster_reclaim_range(si, ci, offset, offset + nr_pages);
798 /*798 /*
799 * Reclaim drops ci->lock and cluster could be used799 * Reclaim drops ci->lock and cluster could be used
800 * by another order. Not checking flag as off-list800 * 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
1086 struct folio_batch free_folios;1086 struct folio_batch free_folios;
1087 LIST_HEAD(ret_folios);1087 LIST_HEAD(ret_folios);
1088 LIST_HEAD(demote_folios);1088 LIST_HEAD(demote_folios);
1089 unsigned int nr_reclaimed = 0;1089 unsigned int nr_reclaimed = 0, nr_demoted = 0;
1090 unsigned int pgactivate = 0;1090 unsigned int pgactivate = 0;
1091 bool do_demote_pass;1091 bool do_demote_pass;
1092 struct swap_iocb *plug = NULL;1092 struct swap_iocb *plug = NULL;
@@ -1550,8 +1550,9 @@ keep: · 457 unmodified lines
1550 /* 'folio_list' is always empty here */1550 /* 'folio_list' is always empty here */
1551 1551
1552 /* Migrate folios selected for demotion */1552 /* Migrate folios selected for demotion */
1553 stat->nr_demoted = demote_folio_list(&demote_folios, pgdat);1553 nr_demoted = demote_folio_list(&demote_folios, pgdat);
1554 nr_reclaimed += stat->nr_demoted;1554 nr_reclaimed += nr_demoted;
1555 stat->nr_demoted += nr_demoted;
1555 /* Folios that could not be demoted are still in @demote_folios */1556 /* Folios that could not be demoted are still in @demote_folios */
1556 if (!list_empty(&demote_folios)) {1557 if (!list_empty(&demote_folios)) {
1557 /* Folios which weren't demoted go back on @folio_list */1558 /* 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
1692 unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };1693 unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };
1693 unsigned long skipped = 0;1694 unsigned long skipped = 0;
1694 unsigned long scan, total_scan, nr_pages;1695 unsigned long scan, total_scan, nr_pages;
1696 unsigned long max_nr_skipped = 0;
1695 LIST_HEAD(folios_skipped);1697 LIST_HEAD(folios_skipped);
1696 1698
1697 total_scan = 0;1699 total_scan = 0;
@@ -1706,9 +1708,12 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, · 8 unmodified lines
1706 nr_pages = folio_nr_pages(folio);1708 nr_pages = folio_nr_pages(folio);
1707 total_scan += nr_pages;1709 total_scan += nr_pages;
1708 1710
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)) {
1710 nr_skipped[folio_zonenum(folio)] += nr_pages;1714 nr_skipped[folio_zonenum(folio)] += nr_pages;
1711 move_to = &folios_skipped;1715 move_to = &folios_skipped;
1716 max_nr_skipped++;
1712 goto move;1717 goto move;
1713 }1718 }
1714 1719
mm/zsmalloc.c+1−1
@@ -452,7 +452,7 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { · 451 unmodified lines
452 .lock = INIT_LOCAL_LOCK(lock),452 .lock = INIT_LOCAL_LOCK(lock),
453};453};
454 454
455static inline bool is_first_zpdesc(struct zpdesc *zpdesc)455static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc)
456{456{
457 return PagePrivate(zpdesc_page(zpdesc));457 return PagePrivate(zpdesc_page(zpdesc));
458}458}
scripts/gdb/linux/cpus.py+1−1
@@ -167,7 +167,7 @@ def get_current_task(cpu): · 166 unmodified lines
167 var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")167 var_ptr = gdb.parse_and_eval("&pcpu_hot.current_task")
168 return per_cpu(var_ptr, cpu).dereference()168 return per_cpu(var_ptr, cpu).dereference()
169 elif utils.is_target_arch("aarch64"):169 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")
171 if (current_task_addr >> 63) != 0:171 if (current_task_addr >> 63) != 0:
172 current_task = current_task_addr.cast(task_ptr_type)172 current_task = current_task_addr.cast(task_ptr_type)
173 return current_task.dereference()173 return current_task.dereference()