Linux block layer
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Jooyung Han <jooyung@google.com>,
	Mike Snitzer <snitzer@kernel.org>,
	zkabelac@redhat.com, dm-devel@lists.linux.dev,
	Alasdair Kergon <agk@redhat.com>
Subject: Re: [PATCH V2 5/5] loop: add hint for handling aio via IOCB_NOWAIT
Date: Thu, 20 Mar 2025 08:22:47 +0100	[thread overview]
Message-ID: <20250320072247.GD14337@lst.de> (raw)
In-Reply-To: <20250314021148.3081954-6-ming.lei@redhat.com>

On Fri, Mar 14, 2025 at 10:11:45AM +0800, Ming Lei wrote:
> Add hint for using IOCB_NOWAIT to handle loop aio command for avoiding
> to cause write(especially randwrite) perf regression on sparse file.
> 
> Try IOCB_NOWAIT in the following situations:
> 
> - backing file is block device

Why limit yourself to block devices?

> - READ aio command
> - there isn't queued aio non-NOWAIT WRITE, since retry of NOWAIT won't
> cause contention on WRITE and non-NOWAIT WRITE often implies exclusive
> lock.

This reads really odd because to me the list implies that you only
support reads, but the code also supports writes.  Maybe try to
explain this more clearly.

> With this simple policy, perf regression of randwrte/write on sparse
> backing file is fixed. Meantime this way addresses perf problem[1] in
> case of stable FS block mapping via NOWAIT.

This needs to go in with the patch implementing the logic.

> @@ -70,6 +70,7 @@ struct loop_device {
>  	struct rb_root          worker_tree;
>  	struct timer_list       timer;
>  	bool			sysfs_inited;
> +	unsigned 		queued_wait_write;

lo_nr_blocking_writes?

What serializes access to this variable?

> +static inline bool lo_aio_need_try_nowait(struct loop_device *lo,
> +		struct loop_cmd *cmd)

Drop the need_ in the name, it not only is superfluous, but also
makes it really hard to read the function name.

Also the inline looks spurious.

> +LOOP_ATTR_RO(nr_wait_write);

nr_blocking_writes?

> +static inline void loop_inc_wait_write(struct loop_device *lo, struct loop_cmd *cmd)

Overly long line.

> +	if (cmd->use_aio){

missing whitespace.

> +		struct request *rq = blk_mq_rq_from_pdu(cmd);
> +
> +		if (req_op(rq) == REQ_OP_WRITE)
> +			lo->queued_wait_write += 1;


	if (cmd->use_aio && req_op(blk_mq_rq_from_pdu(cmd)) == REQ_OP_WRITE)
			lo->queued_wait_write++;

> +	}
> +}
> +
> +static inline void loop_dec_wait_write(struct loop_device *lo, struct loop_cmd *cmd)
> +{
> +	lockdep_assert_held(&lo->lo_mutex);
> +
> +	if (cmd->use_aio){
> +		struct request *rq = blk_mq_rq_from_pdu(cmd);
> +
> +		if (req_op(rq) == REQ_OP_WRITE)
> +			lo->queued_wait_write -= 1;
> +	}
> +}

All the things above apply here as well.


  reply	other threads:[~2025-03-20  7:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14  2:11 [PATCH V2 0/5] loop: improve loop aio perf by IOCB_NOWAIT Ming Lei
2025-03-14  2:11 ` [PATCH V2 1/5] loop: simplify do_req_filebacked() Ming Lei
2025-03-20  7:10   ` Christoph Hellwig
2025-03-14  2:11 ` [PATCH V2 2/5] loop: cleanup lo_rw_aio() Ming Lei
2025-03-20  7:11   ` Christoph Hellwig
2025-03-14  2:11 ` [PATCH V2 3/5] loop: move command blkcg/memcg initialization into loop_queue_work Ming Lei
2025-03-20  7:14   ` Christoph Hellwig
2025-03-14  2:11 ` [PATCH V2 4/5] loop: try to handle loop aio command via NOWAIT IO first Ming Lei
2025-03-14  2:11 ` [PATCH V2 5/5] loop: add hint for handling aio via IOCB_NOWAIT Ming Lei
2025-03-20  7:22   ` Christoph Hellwig [this message]
2025-03-20  7:38     ` Ming Lei
2025-03-14  2:16 ` [PATCH V2 0/5] loop: improve loop aio perf by IOCB_NOWAIT Ming Lei

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=20250320072247.GD14337@lst.de \
    --to=hch@lst.de \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=jooyung@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=zkabelac@redhat.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