All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Henriques <luis@igalia.com>
To: Bernd Schubert via B4 Relay <devnull+bernd.bsbernd.com@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	 bernd@bsbernd.com,  Joanne Koong <joannelkoong@gmail.com>,
	 linux-fsdevel@vger.kernel.org,  Gang He <dchg2000@gmail.com>,
	 Bernd Schubert <bschubert@ddn.com>
Subject: Re: [PATCH v4 7/8] fuse: Add retry attempts for numa local queues for load distribution
Date: Fri, 24 Apr 2026 16:28:05 +0100	[thread overview]
Message-ID: <87tst0ml8a.fsf@igalia.com> (raw)
In-Reply-To: <20260413-reduced-nr-ring-queues_3-v4-7-982b6414b723@bsbernd.com> (Bernd Schubert via's message of "Mon, 13 Apr 2026 11:41:30 +0200")

On Mon, Apr 13 2026, Bernd Schubert via B4 Relay 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)
> +			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*/

nit: "different"

> +			cpu++;
> +			retries++;
> +			goto retry;
> +		}
>  	}
>  
> +	/* Retries exceeded, take the primary target queue */
> +	if (primary_queue)
> +		return primary_queue;
> +
>  	/* global registered queue bitmap */
>  	qid = ring->q_map.cpu_to_qid[cpu];
>  	if (WARN_ON_ONCE(qid >= ring->max_nr_queues))
> +	/* Might happen on teardown */

This comment should probably be in the line above the 'if' statement.

Cheers,
-- 
Luís

>  		return NULL;
>  	return READ_ONCE(ring->queues[qid]);
>  }
>
> -- 
> 2.43.0
>
>


  reply	other threads:[~2026-04-24 15:28 UTC|newest]

Thread overview: 48+ 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
2026-04-13  9:41 ` Bernd Schubert via B4 Relay
2026-04-13  9:41 ` [PATCH v4 1/8] fuse: {io-uring} Add queue length counters Bernd Schubert
2026-04-13  9:41   ` 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
2026-04-13  9:41   ` 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
2026-04-13  9:41   ` 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
2026-04-13  9:41   ` 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
2026-04-13  9:41   ` 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
2026-04-13  9:41   ` 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
2026-04-13  9:41   ` Bernd Schubert via B4 Relay
2026-04-24 15:28   ` Luis Henriques [this message]
2026-04-29 15:03   ` Joanne Koong
2026-04-29 16:07     ` Bernd Schubert
2026-04-13  9:41 ` [PATCH v4 8/8] fuse: {io-uring} Prefer the current core over mapping Bernd Schubert
2026-04-13  9:41   ` 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=87tst0ml8a.fsf@igalia.com \
    --to=luis@igalia.com \
    --cc=bernd@bsbernd.com \
    --cc=bschubert@ddn.com \
    --cc=dchg2000@gmail.com \
    --cc=devnull+bernd.bsbernd.com@kernel.org \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.