From: Ming Lei <ming.lei@redhat.com>
To: Nilay Shroff <nilay@linux.ibm.com>
Cc: linux-block@vger.kernel.org, hch@lst.de, axboe@kernel.dk,
sth@linux.ibm.com, gjoyce@ibm.com
Subject: Re: [PATCH] block: fix lock dependency between percpu alloc lock and elevator lock
Date: Wed, 21 May 2025 12:08:02 +0800 [thread overview]
Message-ID: <aC1Ropdb5x05WCIc@fedora> (raw)
In-Reply-To: <20250520103425.1259712-1-nilay@linux.ibm.com>
Hi Nilay,
On Tue, May 20, 2025 at 04:03:49PM +0530, Nilay Shroff wrote:
> Recent lockdep reports [1] have indicated a potential deadlock arising
> from the dependency between the percpu allocator lock and the elevaor
> lock. This issue can be mitigated by ensuring that elevator/sched tags
> allocation and release occur outside the eleavtor lock. Moreover, we also
> don't require queue remains frozen while we allocate/release sched tags.
> So this patch addresses this problem by moving the allocation and de-
> allocation of elevator sched tags outside the elevator switch path that
> is protected by the ->freeze_lock and ->elevator_lock. Specifically, new
> elevator sched tags are now allocated before switching the elevator and
> outside the freeze section and elevator lock section. The old elevator's
> sched tags are then freed after the elevator lock is released and queue
> is unfrozen.
>
> To support this, the elv_change_ctx structure is extended to hold relevant
> data needed for allocation and deferred release of sched tags during
> elevator switching. With these changes, all sched tag allocations and
> releases are performed outside both ->freeze_lock and ->elevator_lock,
> preventing the lock ordering issue when elv_iosched_store is triggered
> via sysfs.
Not dig into this implementation, will look into later.
I guess it should work by extending elv_change_ctx.
However we have other elevator_queue lifetime issue, that is why
->elevator_lock is used almost everywhere.
Another solution is to move all `sched_data` into 'struct elevator_queue':
I feel it may be simpler in concept:
- sched data and elevator queue share same lifetime
- kobject_put(&eq->kobj) is already called without holding ->elevator_lock &
queue isn't freezed
- replace unnecessary ->elevator_lock by blk_get_elevator()/blk_put_elevator()
But it needs some cleanup/refactor on scheduler interface.
What do you think about the above way?
Thanks,
Ming
next prev parent reply other threads:[~2025-05-21 4:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 10:33 [PATCH] block: fix lock dependency between percpu alloc lock and elevator lock Nilay Shroff
2025-05-21 4:08 ` Ming Lei [this message]
2025-05-21 6:03 ` Christoph Hellwig
2025-05-21 7:40 ` Nilay Shroff
-- strict thread matches above, loose matches on Subject: below --
2025-05-21 3:34 kernel test robot
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=aC1Ropdb5x05WCIc@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=gjoyce@ibm.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--cc=sth@linux.ibm.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 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.