linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon/tests/vaddr-kunit: don't use mas_lock for MM_MT_FLAGS-initialized maple tree
@ 2024-09-04  0:45 SeongJae Park
  2024-09-04  0:48 ` Liam R. Howlett
  0 siblings, 1 reply; 17+ messages in thread
From: SeongJae Park @ 2024-09-04  0:45 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Matthew Wilcox (Oracle), Liam R. Howlett,
	David Hildenbrand, Brendan Higgins, David Gow, damon, linux-mm,
	kunit-dev, linux-kselftest, linux-kernel, Guenter Roeck

damon_test_three_regions_in_vmas() initializes a maple tree with
MM_MT_FLAGS.  The flags contains MT_FLAGS_LOCK_EXTERN, which means
mt_lock of the maple tree will not be used.  And therefore the maple
tree initialization code skips initialization of the mt_lock.  However,
__link_vmas(), which adds vmas for test to the maple tree, uses the
mt_lock.  In other words, the uninitialized spinlock is used.  The
problem becomes celar when spinlock debugging is turned on, since it
reports spinlock bad magic bug.  Fix the issue by not using the mt_lock
as promised.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Closes: https://lore.kernel.org/1453b2b2-6119-4082-ad9e-f3c5239bf87e@roeck-us.net
Fixes: d0cf3dd47f0d ("damon: convert __damon_va_three_regions to use the VMA iterator")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/tests/vaddr-kunit.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
index 83626483f82b..c6c7e0e0ab07 100644
--- a/mm/damon/tests/vaddr-kunit.h
+++ b/mm/damon/tests/vaddr-kunit.h
@@ -17,23 +17,19 @@
 static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,
 			ssize_t nr_vmas)
 {
-	int i, ret = -ENOMEM;
+	int i;
 	MA_STATE(mas, mt, 0, 0);
 
 	if (!nr_vmas)
 		return 0;
 
-	mas_lock(&mas);
 	for (i = 0; i < nr_vmas; i++) {
 		mas_set_range(&mas, vmas[i].vm_start, vmas[i].vm_end - 1);
 		if (mas_store_gfp(&mas, &vmas[i], GFP_KERNEL))
-			goto failed;
+			return -ENOMEM;
 	}
 
-	ret = 0;
-failed:
-	mas_unlock(&mas);
-	return ret;
+	return 0;
 }
 
 /*
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-09-05  0:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04  0:45 [PATCH] mm/damon/tests/vaddr-kunit: don't use mas_lock for MM_MT_FLAGS-initialized maple tree SeongJae Park
2024-09-04  0:48 ` Liam R. Howlett
2024-09-04  0:58   ` SeongJae Park
2024-09-04  1:18     ` SeongJae Park
2024-09-04  1:54       ` Guenter Roeck
2024-09-04  2:43         ` Liam R. Howlett
2024-09-04 17:36           ` SeongJae Park
2024-09-04  2:31       ` Liam R. Howlett
2024-09-04  2:38         ` Guenter Roeck
2024-09-04  2:46           ` Liam R. Howlett
2024-09-04  3:36           ` Liam R. Howlett
2024-09-04  4:27             ` Guenter Roeck
2024-09-04 19:26               ` Liam R. Howlett
2024-09-04 19:56                 ` Guenter Roeck
2024-09-05  0:19                   ` SeongJae Park
2024-09-04 16:58             ` Guenter Roeck
2024-09-04  1:28     ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).