aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2023-08-07 23:00:36 +0200
committerVlastimil Babka <vbabka@suse.cz>2024-02-02 22:47:03 +0100
commitd65a9ae79f5d714eb675864357d325145b3c6c87 (patch)
tree41185284f05bc23e59c5ff7539c4f395fe4d9014
parent3ed829ed3d0f53245f5ae4ac86543f9857bb37d0 (diff)
downloadlinux-slub-percpu-caches-v4r2.tar.gz
maple_tree: replace preallocation with slub percpu array prefillslub-percpu-caches-v4r2
With the percpu array we can try not doing the preallocations in maple tree, and instead make sure the percpu array is prefilled, and using GFP_ATOMIC in places that relied on the preallocation (in case we miss or fail trylock on the array), i.e. mas_store_prealloc(). For now simply add __GFP_NOFAIL there as well.
-rw-r--r--lib/maple_tree.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 1591f3917b7e63..b21c53cb085d28 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5428,7 +5428,12 @@ void mas_store_prealloc(struct ma_state *mas, void *entry)
mas_wr_store_setup(&wr_mas);
trace_ma_write(__func__, mas, 0, entry);
+
+retry:
mas_wr_store_entry(&wr_mas);
+ if (unlikely(mas_nomem(mas, GFP_ATOMIC | __GFP_NOFAIL)))
+ goto retry;
+
MAS_WR_BUG_ON(&wr_mas, mas_is_err(mas));
mas_destroy(mas);
}
@@ -5447,8 +5452,6 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
MA_WR_STATE(wr_mas, mas, entry);
unsigned char node_size;
int request = 1;
- int ret;
-
if (unlikely(!mas->index && mas->last == ULONG_MAX))
goto ask_now;
@@ -5499,16 +5502,8 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
/* node store, slot store needs one node */
ask_now:
- mas_node_count_gfp(mas, request, gfp);
- if (likely(!mas_is_err(mas)))
- return 0;
+ return kmem_cache_prefill_percpu_array(maple_node_cache, request, gfp);
- mas_set_alloc_req(mas, 0);
- ret = xa_err(mas->node);
- mas_reset(mas);
- mas_destroy(mas);
- mas_reset(mas);
- return ret;
}
EXPORT_SYMBOL_GPL(mas_preallocate);