All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Pavel Begunkov <asml.silence@gmail.com>
Cc: io-uring@vger.kernel.org
Subject: Re: [PATCH v2 8/8] io_uring: drain based on allocates reqs
Date: Tue, 13 May 2025 13:37:40 +0300	[thread overview]
Message-ID: <aCMg9J25E_Um-kSg@black.fi.intel.com> (raw)
In-Reply-To: <46ece1e34320b046c06fee2498d6b4cd12a700f2.1746788718.git.asml.silence@gmail.com>

On Fri, May 09, 2025 at 12:12:54PM +0100, Pavel Begunkov wrote:
> Don't rely on CQ sequence numbers for draining, as it has become messy
> and needs cq_extra adjustments. Instead, base it on the number of
> allocated requests and only allow flushing when all requests are in the
> drain list.
> 
> As a result, cq_extra is gone, no overhead for its accounting in aux cqe
> posting, less bloating as it was inlined before, and it's in general
> simpler than trying to track where we should bump it and where it should
> be put back like in cases of overflow. Also, it'll likely help with
> cleaning and unifying some of the CQ posting helpers.

This patch breaks the `make W=1` build. Please, always test your changes with
`make W=1`. See below the details.

...

>  static __cold void io_drain_req(struct io_kiocb *req)
>  	__must_hold(&ctx->uring_lock)
>  {
>  	struct io_ring_ctx *ctx = req->ctx;
>  	bool drain = req->flags & IOSQE_IO_DRAIN;
>  	struct io_defer_entry *de;
> +	struct io_kiocb *tmp;

> +	int nr = 0;

Defined and assigned...

>  
>  	de = kmalloc(sizeof(*de), GFP_KERNEL_ACCOUNT);
>  	if (!de) {
> @@ -1667,17 +1658,17 @@ static __cold void io_drain_req(struct io_kiocb *req)
>  		return;
>  	}
>  
> +	io_for_each_link(tmp, req)
> +		nr++;

...just incremented...

And that seems it. Does the above have any side-effects? Or is it just a dead
code (a.k.a. leftovers from the rebase/upcoming work)?

In any case, please make use of nr or drop it completely.

io_uring/io_uring.c:1649:6: error: variable 'nr' set but not used [-Werror,-Wunused-but-set-variable]
 1649 |         int nr = 0;
      |             ^
1 error generated.

>  	io_prep_async_link(req);
>  	trace_io_uring_defer(req);
>  	de->req = req;
> -	de->seq = io_get_sequence(req);
>  
> -	scoped_guard(spinlock, &ctx->completion_lock) {
> -		list_add_tail(&de->list, &ctx->defer_list);
> -		__io_queue_deferred(ctx);
> -		if (!drain && list_empty(&ctx->defer_list))
> -			ctx->drain_active = false;
> -	}
> +	ctx->nr_drained += io_linked_nr(req);
> +	list_add_tail(&de->list, &ctx->defer_list);
> +	io_queue_deferred(ctx);
> +	if (!drain && list_empty(&ctx->defer_list))
> +		ctx->drain_active = false;
>  }

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-05-13 10:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09 11:12 [PATCH v2 0/8] allocated requests based drain and fixes Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 1/8] io_uring: account drain memory to cgroup Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 2/8] io_uring: fix spurious drain flushing Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 3/8] io_uring: simplify drain ret passing Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 4/8] io_uring: remove drain prealloc checks Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 5/8] io_uring: consolidate drain seq checking Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 6/8] io_uring: open code io_account_cq_overflow() Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 7/8] io_uring: count allocated requests Pavel Begunkov
2025-05-09 11:12 ` [PATCH v2 8/8] io_uring: drain based on allocates reqs Pavel Begunkov
2025-05-13 10:37   ` Andy Shevchenko [this message]
2025-05-13 13:35     ` Pavel Begunkov
2025-05-09 14:02 ` [PATCH v2 0/8] allocated requests based drain and fixes Jens Axboe

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=aCMg9J25E_Um-kSg@black.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    /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.