From: Christoph Hellwig <hch@infradead.org>
To: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
darklight2357@icloud.com, Josef Bacik <josef@toxicpanda.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
cgroups@vger.kernel.org
Subject: Re: [PATCH 1/2 block/for-6.2] blk-iolatency: Fix memory leak on add_disk() failures
Date: Mon, 12 Dec 2022 00:47:57 -0800 [thread overview]
Message-ID: <Y5bqvWdDa5MW7w3v@infradead.org> (raw)
In-Reply-To: <Y5TQ5gm3O4HXrXR3@slm.duckdns.org>
On Sat, Dec 10, 2022 at 08:33:10AM -1000, Tejun Heo wrote:
> When a gendisk is successfully initialized but add_disk() fails such as when
> a loop device has invalid number of minor device numbers specified,
> blkcg_init_disk() is called during init and then blkcg_exit_disk() during
> error handling. Unfortunately, iolatency gets initialized in the former but
> doesn't get cleaned up in the latter.
>
> This is because, in non-error cases, the cleanup is performed by
> del_gendisk() calling rq_qos_exit(), the assumption being that rq_qos
> policies, iolatency being one of them, can only be activated once the disk
> is fully registered and visible. That assumption is true for wbt and iocost,
> but not so for iolatency as it gets initialized before add_disk() is called.
>
> It is desirable to lazy-init rq_qos policies because they are optional
> features and add to hot path overhead once initialized - each IO has to walk
> all the registered rq_qos policies. So, we want to switch iolatency to lazy
> init too. However, that's a bigger change. As a fix for the immediate
> problem, let's just add an extra call to rq_qos_exit() in blkcg_exit_disk().
> This is safe because duplicate calls to rq_qos_exit() become noop's.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: darklight2357@icloud.com
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
next prev parent reply other threads:[~2022-12-12 8:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-10 18:33 [PATCH 1/2 block/for-6.2] blk-iolatency: Fix memory leak on add_disk() failures Tejun Heo
2022-12-10 18:34 ` [PATCH 2/2 block/for-6.2] blk-iolatency: Make initialization lazy Tejun Heo
2022-12-12 8:53 ` Christoph Hellwig
2022-12-12 22:44 ` Tejun Heo
2022-12-10 18:54 ` [PATCH 1/2 block/for-6.2] blk-iolatency: Fix memory leak on add_disk() failures Linus Torvalds
2022-12-12 8:47 ` Christoph Hellwig [this message]
2022-12-14 19:43 ` (subset) " 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=Y5bqvWdDa5MW7w3v@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=darklight2357@icloud.com \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.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).