@@ -5530,7 +5530,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);
}
@@ -5545,19 +5550,12 @@ EXPORT_SYMBOL_GPL(mas_store_prealloc);
*/
int mas_preallocate(struct ma_state *mas, gfp_t gfp)
{
- int ret;
+ int count = 1 + mas_mt_height(mas) * 3;
- mas_node_count_gfp(mas, 1 + mas_mt_height(mas) * 3, gfp);
- mas->mas_flags |= MA_STATE_PREALLOC;
- if (likely(!mas_is_err(mas)))
- return 0;
+ // TODO: should probably indicate if it failed the prefill?
+ kmem_cache_prefill_percpu_array(maple_node_cache, count, gfp);
- mas_set_alloc_req(mas, 0);
- ret = xa_err(mas->node);
- mas_reset(mas);
- mas_destroy(mas);
- mas_reset(mas);
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(mas_preallocate);