Re: [PATCH 0/2] dm thin: stop waiting for grace periods when activating and removing thins

From: Benjamin Marzinski

Date: Thu Nov 19 2026 - 00:24:40 EST


On Mon, Nov 16, 2026 at 12:12:02AM -0500, Qiliang Yuan wrote:
> Activating a thin device waits for an RCU grace period in thin_ctr(),
> and removing one waits for another in thin_dtr(). Tools that create and
> remove thin snapshots for every container, such as the containerd
> devmapper snapshotter, pay for both each time.
>
> Patch 1 drops the grace period from thin_ctr(), which isn't needed.
> Patch 2 lets the active_thins walkers skip thins whose last reference is
> gone, so that thin_dtr() can free the thin with kfree_rcu() instead of
> waiting. Activating a thin device gets 51% faster and removing one 15%.
>
> Signed-off-by: Qiliang Yuan <qiliang.yuan@xxxxxxxxx>

I posted an alternate version of your [PATCH 2/2] that fixes the issue
I mentioned. Can you verify that it works for you?

I squashed it with your patch, since it your original patch did most of
the work of fixing the issue, and it seemed easier to just have one
patch to backport to fix it. I could refactor it into two patches: one
the fixes the bug, and a second that just swaps the synchronize_rcu()
for kfree_rcu(), if people would rather not mix the bug fix and feature.

-Ben

> ---
> Qiliang Yuan (2):
> dm thin: drop the grace period from thin_ctr()
> dm thin: free thins with kfree_rcu() instead of waiting in thin_dtr()
>
> drivers/md/dm-thin.c | 37 ++++++++++++++++++-------------------
> 1 file changed, 18 insertions(+), 19 deletions(-)
> ---
> base-commit: 23c62304dde29abe92013d85910d03a77dada35d
> change-id: 20261114-bug-dm-thin-rcu-gp-d29d4b74a0b8
>
> Best regards,
> --
> Qiliang Yuan <qiliang.yuan@xxxxxxxxx>
>