linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 09/11] block: open code create_task_io_context in set_task_ioprio
Date: Tue, 14 Dec 2021 16:56:22 +0100	[thread overview]
Message-ID: <20211214155622.GJ14044@quack2.suse.cz> (raw)
In-Reply-To: <20211209063131.18537-10-hch@lst.de>

On Thu 09-12-21 07:31:29, Christoph Hellwig wrote:
> The flow in set_task_ioprio can be simplified by simply open coding
> create_task_io_context, which removes a refcount roundtrip on the I/O
> context.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

OK, why not :). Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  block/blk-ioc.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-ioc.c b/block/blk-ioc.c
> index 1ba7cfedca2d9..cff0e3bdae53c 100644
> --- a/block/blk-ioc.c
> +++ b/block/blk-ioc.c
> @@ -291,12 +291,18 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
>  		struct io_context *ioc;
>  
>  		task_unlock(task);
> -		ioc = create_task_io_context(task, GFP_ATOMIC, NUMA_NO_NODE);
> -		if (ioc) {
> -			ioc->ioprio = ioprio;
> -			put_io_context(ioc);
> +
> +		ioc = alloc_io_context(GFP_ATOMIC, NUMA_NO_NODE);
> +		if (!ioc)
> +			return -ENOMEM;
> +
> +		task_lock(task);
> +		if (task->io_context || (task->flags & PF_EXITING)) {
> +			kmem_cache_free(iocontext_cachep, ioc);
> +			ioc = task->io_context;
> +		} else {
> +			task->io_context = ioc;
>  		}
> -		return 0;
>  	}
>  	task->io_context->ioprio = ioprio;
>  	task_unlock(task);
> -- 
> 2.30.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2021-12-14 15:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09  6:31 more I/O context cleanup v2 Christoph Hellwig
2021-12-09  6:31 ` [PATCH 01/11] block: remove the nr_task field from struct io_context Christoph Hellwig
2021-12-09  6:31 ` [PATCH 02/11] block: simplify struct io_context refcounting Christoph Hellwig
2021-12-09  6:31 ` [PATCH 03/11] block: refactor put_iocontext_active Christoph Hellwig
2021-12-09  6:31 ` [PATCH 04/11] block: remove the NULL ioc check in put_io_context Christoph Hellwig
2021-12-09  6:31 ` [PATCH 05/11] block: refactor put_io_context Christoph Hellwig
2021-12-09  6:31 ` [PATCH 06/11] block: cleanup ioc_clear_queue Christoph Hellwig
2021-12-14 15:50   ` Jan Kara
2021-12-09  6:31 ` [PATCH 07/11] block: move set_task_ioprio to blk-ioc.c Christoph Hellwig
2021-12-14 15:52   ` Jan Kara
2021-12-09  6:31 ` [PATCH 08/11] block: fold get_task_io_context into set_task_ioprio Christoph Hellwig
2021-12-14 15:52   ` Jan Kara
2021-12-09  6:31 ` [PATCH 09/11] block: open code create_task_io_context in set_task_ioprio Christoph Hellwig
2021-12-14 15:56   ` Jan Kara [this message]
2021-12-09  6:31 ` [PATCH 10/11] block: fold create_task_io_context into ioc_find_get_icq Christoph Hellwig
2021-12-14 16:01   ` Jan Kara
2021-12-09  6:31 ` [PATCH 11/11] block: only build the icq tracking code when needed Christoph Hellwig
2021-12-16 18:02 ` more I/O context cleanup v2 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=20211214155622.GJ14044@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).