summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-10-11 00:39:06 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2022-10-11 00:39:06 -0400
commit81aef3395759058186d847421353c50e1e79ba06 (patch)
tree05a98327efaf3ba2415d2c1fd166a3d54bfe4312
parent72add8822c47e5801d4ac6d42af8c5d9d7b4d3c9 (diff)
Don't run shrinkers without GFP_KERNEL
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>
-rw-r--r--include/linux/types.h2
-rw-r--r--linux/shrinker.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/types.h b/include/linux/types.h
index f0efcd2e..7144f17f 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -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
diff --git a/linux/shrinker.c b/linux/shrinker.c
index 25cdfbb6..0f73620b 100644
--- a/linux/shrinker.c
+++ b/linux/shrinker.c
@@ -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;