From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
Paolo Valente <paolo.valente@linaro.org>, Jan Kara <jack@suse.cz>,
linux-block@vger.kernel.org
Subject: Re: [PATCH 6/7] block: cleanup ioc_clear_queue
Date: Tue, 30 Nov 2021 18:26:13 +0100 [thread overview]
Message-ID: <20211130172613.GL7174@quack2.suse.cz> (raw)
In-Reply-To: <20211130124636.2505904-7-hch@lst.de>
On Tue 30-11-21 13:46:35, Christoph Hellwig wrote:
> Fold __ioc_clear_queue into ioc_clear_queue, remove the spurious RCU
> criticial section and unify the irq locking style.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-ioc.c | 31 +++++++++----------------------
> 1 file changed, 9 insertions(+), 22 deletions(-)
>
> diff --git a/block/blk-ioc.c b/block/blk-ioc.c
> index 902bca2b273ba..32ae006e1b3e8 100644
> --- a/block/blk-ioc.c
> +++ b/block/blk-ioc.c
> @@ -192,27 +192,6 @@ void exit_io_context(struct task_struct *task)
> }
> }
>
> -static void __ioc_clear_queue(struct list_head *icq_list)
> -{
> - unsigned long flags;
> -
> - rcu_read_lock();
> - while (!list_empty(icq_list)) {
> - struct io_cq *icq = list_entry(icq_list->next,
> - struct io_cq, q_node);
> - struct io_context *ioc = icq->ioc;
> -
> - spin_lock_irqsave(&ioc->lock, flags);
> - if (icq->flags & ICQ_DESTROYED) {
> - spin_unlock_irqrestore(&ioc->lock, flags);
> - continue;
> - }
> - ioc_destroy_icq(icq);
> - spin_unlock_irqrestore(&ioc->lock, flags);
> - }
> - rcu_read_unlock();
> -}
> -
> /**
> * ioc_clear_queue - break any ioc association with the specified queue
> * @q: request_queue being cleared
> @@ -227,7 +206,15 @@ void ioc_clear_queue(struct request_queue *q)
> list_splice_init(&q->icq_list, &icq_list);
> spin_unlock_irq(&q->queue_lock);
>
> - __ioc_clear_queue(&icq_list);
> + while (!list_empty(&icq_list)) {
> + struct io_cq *icq =
> + list_entry(icq_list.next, struct io_cq, q_node);
I'm not quite sure about dropping the rcu protection here. This function
generally runs without any protection so what guards us against icq being
freed just after we've got its pointer from the list?
Honza
> +
> + spin_lock_irq(&icq->ioc->lock);
> + if (!(icq->flags & ICQ_DESTROYED))
> + ioc_destroy_icq(icq);
> + spin_unlock_irq(&icq->ioc->lock);
> + }
> }
>
> static struct io_context *alloc_io_context(gfp_t gfp_flags, int node)
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2021-11-30 17:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 12:46 more I/O context cleanup Christoph Hellwig
2021-11-30 12:46 ` [PATCH 1/7] block: remove the nr_task field from struct io_context Christoph Hellwig
2021-11-30 15:43 ` Jan Kara
2021-11-30 12:46 ` [PATCH 2/7] block: simplify struct io_context refcounting Christoph Hellwig
2021-11-30 15:02 ` Jan Kara
2021-11-30 12:46 ` [PATCH 3/7] block: refactor put_iocontext_active Christoph Hellwig
2021-11-30 15:01 ` Jan Kara
2021-11-30 12:46 ` [PATCH 4/7] block: remove the NULL ioc check in put_io_context Christoph Hellwig
2021-11-30 14:59 ` Jan Kara
2021-11-30 12:46 ` [PATCH 5/7] block: refactor put_io_context Christoph Hellwig
2021-11-30 14:58 ` Jan Kara
2021-11-30 12:46 ` [PATCH 6/7] block: cleanup ioc_clear_queue Christoph Hellwig
2021-11-30 17:26 ` Jan Kara [this message]
2021-12-01 7:27 ` Christoph Hellwig
2021-12-01 14:33 ` Jan Kara
2021-11-30 12:46 ` [PATCH 7/7] block: only build the icq tracking code when needed Christoph Hellwig
2021-11-30 17:27 ` Jan Kara
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=20211130172613.GL7174@quack2.suse.cz \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=paolo.valente@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).