public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bernd Schubert <bschubert@ddn.com>
To: Joanne Koong <joannelkoong@gmail.com>, bernd@bsbernd.com
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	linux-fsdevel@vger.kernel.org, Luis Henriques <luis@igalia.com>,
	Gang He <dchg2000@gmail.com>
Subject: Re: [PATCH v4 7/8] fuse: Add retry attempts for numa local queues for load distribution
Date: Wed, 29 Apr 2026 18:07:02 +0200	[thread overview]
Message-ID: <6ac13db3-9779-44e9-81c5-a2c6e76dcccf@ddn.com> (raw)
In-Reply-To: <CAJnrk1ZnJ-p4aPCkk8=1v5bMFgo50GzGiixZuom9P=3p-nMTrg@mail.gmail.com>



On 4/29/26 17:03, Joanne Koong wrote:
> On Mon, Apr 13, 2026 at 10:41 AM Bernd Schubert via B4 Relay
> <devnull+bernd.bsbernd.com@kernel.org> wrote:
>>
>> From: Bernd Schubert <bschubert@ddn.com>
>>
>> This is to further improve performance.
>>
>> fio --directory=/tmp/dest --name=iops.\$jobnum --rw=randread \
>> --bs=4k --size=1G --numjobs=1 --iodepth=4 --time_based\
>> --runtime=30s --group_reporting --ioengine=io_uring\
>> --direct=1
>>
>> unpatched
>>    READ: bw=650MiB/s (682MB/s)
>> patched:
>>    READ: bw=995MiB/s (1043MB/s)
>>
>> with --iodepth=8
>>
>> unpatched
>>    READ: bw=641MiB/s (672MB/s)
>> patched
>>    READ: bw=966MiB/s (1012MB/s)
>>
>> Reason is that with --iodepth=x (x > 1) fio submits multiple async
>> requests and a single queue might become CPU limited. I.e. spreading
>> the load helps.
>> ---
>>  fs/fuse/dev_uring.c | 30 ++++++++++++++++++++++++++++--
>>  1 file changed, 28 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
>> index ed061e239b8ed70ff36deb51dd6957fe1704ec87..e06d45b161d5000e24431314b2222b66bdea58aa 100644
>> --- a/fs/fuse/dev_uring.c
>> +++ b/fs/fuse/dev_uring.c
>> @@ -19,6 +19,7 @@ MODULE_PARM_DESC(enable_uring,
>>
>>  #define FUSE_URING_IOV_SEGS 2 /* header and payload */
>>
>> +#define FUSE_URING_Q_THRESHOLD 2
>>
>>  bool fuse_uring_enabled(void)
>>  {
>> @@ -1310,9 +1311,10 @@ static struct fuse_ring_queue *fuse_uring_select_queue(struct fuse_ring *ring,
>>                                                        bool background)
>>  {
>>         unsigned int qid;
>> -       int node;
>> +       int node, retries = 0;
>>         unsigned int nr_queues;
>>         unsigned int cpu = task_cpu(current);
>> +       struct fuse_ring_queue *queue, *primary_queue = NULL;
>>
>>         /*
>>          *  Background requests result in better performance on a different
>> @@ -1321,6 +1323,7 @@ static struct fuse_ring_queue *fuse_uring_select_queue(struct fuse_ring *ring,
>>         if (background)
>>                 cpu++;
>>
>> +retry:
>>         cpu = cpu % ring->max_nr_queues;
>>
>>         /* numa local registered queue bitmap */
>> @@ -1336,12 +1339,35 @@ static struct fuse_ring_queue *fuse_uring_select_queue(struct fuse_ring *ring,
>>                 qid = ring->numa_q_map[node].cpu_to_qid[cpu];
>>                 if (WARN_ON_ONCE(qid >= ring->max_nr_queues))
>>                         return NULL;
>> -               return READ_ONCE(ring->queues[qid]);
>> +               queue = READ_ONCE(ring->queues[qid]);
>> +
>> +               /* Might happen on teardown */
>> +               if (unlikely(!queue))
>> +                       return NULL;
>> +
>> +               if (queue->nr_reqs < FUSE_URING_Q_THRESHOLD)
> 
> Should this use READ_ONCE(queue->nr_reqs) since nr_reqs may be
> concurrently modified under the queue lock by other CPUs while we're
> reading it locklessly here?

Definitely makes sense, hopefully it will not disturb a hot path.

> 
>> +                       return queue;
>> +
>> +               /* Retries help for load balancing */
>> +               if (retries < FUSE_URING_Q_THRESHOLD) {
>> +                       if (!retries)
>> +                               primary_queue = queue;
>> +
>> +                       /* Increase cpu, assuming it will map to a differet qid*/
>> +                       cpu++;
> 
> Here too I think cpu++ can break numa locality. In the reduced-queue
> setup, I think cpu++ may have a solid chance at mapping back to the
> same qid.

It needs the same quirk - read node on function entry.

> 
> If we use the ring->numa_q_map[node].registered_q_mask and the
> cpumask_next_wrap() helper to find the next qid in the numa node, i
> think that will guarantee numa locality, a different qid, avoids
> having to redo the whole cpu_to_node() + nr_queues lookup on each
> retry, and will detect automatically when all queues on the node have
> been tried.
> 
> If you dont have the bandwidth to consider this change for v5, I can
> send a followup patch for it.

I should have the time on Friday, and hopefully I find a bit time to
look into the way how blk-mqueue does it before next week.


Thanks,
Bernd

  reply	other threads:[~2026-04-29 16:40 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  9:41 [PATCH v4 0/8] fuse: {io-uring} Allow to reduce the number of queues and request distribution Bernd Schubert via B4 Relay
2026-04-13  9:41 ` [PATCH v4 1/8] fuse: {io-uring} Add queue length counters Bernd Schubert via B4 Relay
2026-04-13  9:41 ` [PATCH v4 2/8] fuse: {io-uring} Rename ring->nr_queues to max_nr_queues Bernd Schubert via B4 Relay
2026-04-27 15:35   ` Joanne Koong
2026-04-13  9:41 ` [PATCH v4 3/8] fuse: {io-uring} Use bitmaps to track registered queues Bernd Schubert via B4 Relay
2026-04-24 15:04   ` Luis Henriques
2026-04-24 15:33     ` Bernd Schubert
2026-04-27  8:02       ` Luis Henriques
2026-04-27 10:39         ` Bernd Schubert
2026-04-13  9:41 ` [PATCH v4 4/8] fuse: Fetch a queued fuse request on command registration Bernd Schubert via B4 Relay
2026-04-13  9:41 ` [PATCH v4 5/8] fuse: {io-uring} Allow reduced number of ring queues Bernd Schubert via B4 Relay
2026-04-24 15:15   ` Luis Henriques
2026-04-24 18:28   ` Joanne Koong
2026-04-24 22:00     ` Bernd Schubert
2026-04-27 13:10       ` Joanne Koong
2026-04-27 13:49         ` Bernd Schubert
2026-04-27 14:10           ` Joanne Koong
2026-04-27 14:42             ` Bernd Schubert
2026-04-27 15:10               ` Joanne Koong
2026-05-04  8:25         ` Bernd Schubert
2026-04-29 16:10       ` Joanne Koong
2026-04-29 16:24         ` Bernd Schubert
2026-04-29 16:32           ` Joanne Koong
2026-04-30  4:16             ` Darrick J. Wong
2026-04-13  9:41 ` [PATCH v4 6/8] fuse: {io-uring} Queue background requests on a different core Bernd Schubert via B4 Relay
2026-04-24 15:26   ` Luis Henriques
2026-04-27 12:08     ` Bernd Schubert
2026-04-29 14:43   ` Joanne Koong
2026-04-29 16:01     ` Bernd Schubert
2026-04-29 16:56       ` Joanne Koong
2026-04-29 20:19         ` Bernd Schubert
2026-04-13  9:41 ` [PATCH v4 7/8] fuse: Add retry attempts for numa local queues for load distribution Bernd Schubert via B4 Relay
2026-04-24 15:28   ` Luis Henriques
2026-04-29 15:03   ` Joanne Koong
2026-04-29 16:07     ` Bernd Schubert [this message]
2026-04-13  9:41 ` [PATCH v4 8/8] fuse: {io-uring} Prefer the current core over mapping Bernd Schubert via B4 Relay
2026-04-29 15:40   ` Joanne Koong
2026-04-29 16:11     ` Bernd Schubert
2026-04-29 16:15 ` [PATCH v4 0/8] fuse: {io-uring} Allow to reduce the number of queues and request distribution Joanne Koong

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=6ac13db3-9779-44e9-81c5-a2c6e76dcccf@ddn.com \
    --to=bschubert@ddn.com \
    --cc=bernd@bsbernd.com \
    --cc=dchg2000@gmail.com \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=luis@igalia.com \
    --cc=miklos@szeredi.hu \
    /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