Re: [Intel-gfx] [PATCH 3/3] locking/selftests: Add testcases for fs_reclaim

2020-11-20 Thread Peter Zijlstra
On Fri, Nov 20, 2020 at 10:54:44AM +0100, Daniel Vetter wrote:
> Since I butchered this I figured better to make sure we have testcases
> for this now. Since we only have a locking context for __GFP_FS that's
> the only thing we're testing right now.
> 
> Cc: linux-fsde...@vger.kernel.org
> Cc: Dave Chinner 
> Cc: Qian Cai 
> Cc: linux-...@vger.kernel.org
> Cc: Thomas Hellström (Intel) 
> Cc: Andrew Morton 
> Cc: Jason Gunthorpe 
> Cc: linux...@kvack.org
> Cc: linux-r...@vger.kernel.org
> Cc: Maarten Lankhorst 
> Cc: Christian König 
> Cc: "Matthew Wilcox (Oracle)" 
> Signed-off-by: Daniel Vetter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Will Deacon 
> Cc: linux-ker...@vger.kernel.org
> ---
>  lib/locking-selftest.c | 47 ++
>  1 file changed, 47 insertions(+)

I have a few changes pending for this file, I don't think the conflicts
will be bad, but..

In any case:

Acked-by: Peter Zijlstra (Intel) 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 3/3] locking/selftests: Add testcases for fs_reclaim

2020-11-20 Thread Daniel Vetter
Since I butchered this I figured better to make sure we have testcases
for this now. Since we only have a locking context for __GFP_FS that's
the only thing we're testing right now.

Cc: linux-fsde...@vger.kernel.org
Cc: Dave Chinner 
Cc: Qian Cai 
Cc: linux-...@vger.kernel.org
Cc: Thomas Hellström (Intel) 
Cc: Andrew Morton 
Cc: Jason Gunthorpe 
Cc: linux...@kvack.org
Cc: linux-r...@vger.kernel.org
Cc: Maarten Lankhorst 
Cc: Christian König 
Cc: "Matthew Wilcox (Oracle)" 
Signed-off-by: Daniel Vetter 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Will Deacon 
Cc: linux-ker...@vger.kernel.org
---
 lib/locking-selftest.c | 47 ++
 1 file changed, 47 insertions(+)

diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index a899b3f0e2e5..ad47c3358e30 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2357,6 +2358,50 @@ static void queued_read_lock_tests(void)
pr_cont("\n");
 }
 
+static void fs_reclaim_correct_nesting(void)
+{
+   fs_reclaim_acquire(GFP_KERNEL);
+   might_alloc(GFP_NOFS);
+   fs_reclaim_release(GFP_KERNEL);
+}
+
+static void fs_reclaim_wrong_nesting(void)
+{
+   fs_reclaim_acquire(GFP_KERNEL);
+   might_alloc(GFP_KERNEL);
+   fs_reclaim_release(GFP_KERNEL);
+}
+
+static void fs_reclaim_protected_nesting(void)
+{
+   unsigned int flags;
+
+   fs_reclaim_acquire(GFP_KERNEL);
+   flags = memalloc_nofs_save();
+   might_alloc(GFP_KERNEL);
+   memalloc_nofs_restore(flags);
+   fs_reclaim_release(GFP_KERNEL);
+}
+
+static void fs_reclaim_tests(void)
+{
+   printk("  \n");
+   printk("  | fs_reclaim tests |\n");
+   printk("  \n");
+
+   print_testname("correct nesting");
+   dotest(fs_reclaim_correct_nesting, SUCCESS, 0);
+   pr_cont("\n");
+
+   print_testname("wrong nesting");
+   dotest(fs_reclaim_wrong_nesting, FAILURE, 0);
+   pr_cont("\n");
+
+   print_testname("protected nesting");
+   dotest(fs_reclaim_protected_nesting, SUCCESS, 0);
+   pr_cont("\n");
+}
+
 void locking_selftest(void)
 {
/*
@@ -2478,6 +2523,8 @@ void locking_selftest(void)
if (IS_ENABLED(CONFIG_QUEUED_RWLOCKS))
queued_read_lock_tests();
 
+   fs_reclaim_tests();
+
if (unexpected_testcase_failures) {

printk("-\n");
debug_locks = 0;
-- 
2.29.2

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx