]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Don't run shrinkers without GFP_KERNEL
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 11 Oct 2022 04:39:06 +0000 (00:39 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 11 Oct 2022 04:39:06 +0000 (00:39 -0400)
This would correspond to GFP_RECLAIM in the kernel - but we don't
distinguish between different types of reclaim here.

This solves a deadlock in the btree node memory allocation path - we
allocate with the btree node cache lock held but without GFP_KERNEL set.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
include/linux/types.h
linux/shrinker.c

index f0efcd2e437fdab46fb54caa545b8e39b4152f37..7144f17fe000c07b671d510b37f4c07a00428b31 100644 (file)
@@ -25,7 +25,7 @@ typedef unsigned short                umode_t;
 
 typedef unsigned gfp_t;
 
-#define GFP_KERNEL     0
+#define GFP_KERNEL     1
 #define GFP_ATOMIC     0
 #define GFP_NOFS       0
 #define GFP_NOIO       0
index 25cdfbb64a2c7d9031eec07ac1873b8c150f1860..0f73620bc6e71f8262e0c92c2e434cf927fff276 100644 (file)
@@ -88,6 +88,9 @@ void run_shrinkers(gfp_t gfp_mask, bool allocation_failed)
        struct sysinfo info;
        s64 want_shrink;
 
+       if (!(gfp_mask & GFP_KERNEL))
+               return;
+
        /* Fast out if there are no shrinkers to run. */
        if (list_empty(&shrinker_list))
                return;