On Thu, Dec 09, 2021 at 10:21:22AM +0200, Aharon Landau wrote: > > It feels like pending and (reserved - stored) are really the same > > thing, so maybe just directly limit the number of reserved and test it > > after > The mlx5_ib_dereg_mr is reserving entries as well. Should I limit > create_mkey_cb due to pending deregs? Sure, it is the same concept, deregs are going to refill things just as wass as new creations. > > > @@ -287,39 +318,37 @@ static void remove_cache_mr_locked(struct mlx5_cache_ent *ent) > > > { > > > struct mlx5_ib_mr *mr; > > > - lockdep_assert_held(&ent->lock); > > > - if (list_empty(&ent->head)) > > > + if (!ent->stored) > > > return; > > > - mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list); > > > - list_del(&mr->list); > > > - ent->available_mrs--; > > > + mr = __xa_store(&ent->mkeys, --ent->stored, NULL, GFP_KERNEL); > > > + WARN_ON(mr == NULL || xa_is_err(mr)); > > Add a if (reserved != stored) before the below? > I initiated the xarray using XA_FLAGS_ALLOC, therefore, the __xa_store above > will mark the entry as ZERO_ENTRY. Oh, do not use XA_FLAGS_ALLOC, this is not what is it for Jason