mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Egor Shalashnov <shalasheg@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, dennis@kernel.org, tj@kernel.org,
	cl@gentwo.org, zhengqi.arch@bytedance.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] percpu_ref: make percpu_ref_switch_lock per percpu_ref
Date: Thu, 26 Nov 2026 00:46:33 +0300	[thread overview]
Message-ID: <edfb1d04-0d55-47ed-b1cb-dcd8c5df75ce@gmail.com> (raw)
In-Reply-To: <20261125113537.bdb168bfe8962ef1aefc097b@linux-foundation.org>



On 25/11/2026 22:35, Andrew Morton wrote:
> Well, an unpublished module isn't very useful for us.
> 
> And an intense microbenchmark isn't as interesting as a real-world
> workload.  So can you please provide more details about what "our
> workload" is doing and some measurements on how much this patch
> improves that workload?

The workload is a full-volume discard on an out-of-tree storage
block device backed by NVMe drives. The test machine has 128 logical CPUs.

The device maintains a percpu_ref for each independently managed
logical region of a thin volume. Normal I/O holds a reference while accessing 
that region. To process a discard, we kill the affected references and
wait for outstanding I/O to drain before removing the mappings.
After the metadata updates complete, we reinitialize the references
so the regions can accept I/O again.

A large discard repeats this lifecycle for many regions, with
different regions processed concurrently on multiple CPUs. Although
the regions are independent, their kill and reinit operations
contend on the global percpu_ref_switch_lock.

We measured the elapsed time of blkdiscard over the entire volume,
refilling the volume before each run.

Volume    Global lock    Per-reference lock    Speedup
 1 TB       3.424 s            1.218 s            2.81x
 8 TB      27.943 s            6.133 s            4.56x
16 TB      56.021 s            8.591 s            6.52x

> Alternatively, this looks like somewhere where a hashed spinlock will
> work well.  A static array of 32(?) cacheline_aligned spinlocks, hash
> the percpu_ref* onto one of those.  That'll get 90% of the benefit
> without growing percpu_ref.

This might be a better approach. I'll compare it with the global-lock
and per-reference-lock variants and report the results.

      reply	other threads:[~2026-11-25 21:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <01612865-faa0-4fe5-8184-a177f104843f@gmail.com>
2026-11-25 15:55 ` Egor Shalashnov
2026-11-25 19:35   ` Andrew Morton
2026-11-25 21:46     ` Egor Shalashnov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=edfb1d04-0d55-47ed-b1cb-dcd8c5df75ce@gmail.com \
    --to=shalasheg@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=dennis@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    --cc=zhengqi.arch@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®