From: Nilay Shroff <nilay@linux.ibm.com>
To: Bart Van Assche <bvanassche@acm.org>,
kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, axboe@kernel.dk,
chaitanyak@nvidia.com
Cc: gjoyce@linux.ibm.com, elver@google.com, linux-nvme@lists.infradead.org
Subject: Re: [PATCH v2 01/22] nvmet: add context annotation for nvmet_ns::bdev
Date: Thu, 19 Nov 2026 19:50:50 +0530 [thread overview]
Message-ID: <6790a3d2-52a8-4baa-95aa-a04073d25e4a@linux.ibm.com> (raw)
In-Reply-To: <23016086-7d09-4a42-94d4-3270caee36e8@acm.org>
On 11/19/26 5:36 AM, Bart Van Assche wrote:
> On 11/17/26 11:34 PM, Nilay Shroff wrote:
>> Some accesses to nvmet_ns::bdev in the I/O hotpath do not require
>> holding nvmet_subsys::lock, as the namespace reference guarantees that
>> the namespace remains valid and the field is not modified while I/O is
>> in flight. However, the clang context analyzer cannot express this
>> access pattern directly. So introduce nvmet_ns_bdev() as an inline
>> helper annotated with __context_unsafe() to allow these accesses
>> without requiring the subsystem lock. Convert the relevant accesses in
>> the I/O hotpath and other request-processing paths to use this helper.
>
> This is not what __context_unsafe() is intended for. Has it been
> considered to introduce a token context lock and to annotate the
> functions called with either the namespace reference held or with the
> nvmet_subsys::lock held?
>
I haven't considered using a token context lock so far, but token context
lock looks interesting and plausible. I'll explore this approach further.
At a high level, I think we would need something along these lines:
/* Declare the context lock */
token_context_lock(nvmet_ns_ref);
/* Annotate fields with this lock */
struct nvmet_ns {
...
struct block_device *bdev
__guarded_by(&subsys->lock, nvmet_ns_ref);
...
};
The namespace lookup and release functions could then be annotated as follows:
u16 nvmet_req_find_ns(struct nvmet_req *req)
__cond_acquires_shared(0, nvmet_ns_ref);
void nvmet_ns_put(struct nvmet_ns *ns)
__releases_shared(nvmet_ns_ref);
These annotations would allow the I/O hotpath to access namespace fields while
holding a namespace reference, without requiring nvmet_subsys::lock.
For the control path, which updates namespace fields while holding
nvmet_subsys::lock, we could introduce wrappers along these lines:
static inline void nvmet_subsys_lock(struct nvmet_subsys *subsys)
__acquires(nvmet_ns_ref)
{
mutex_lock(&subsys->lock);
__acquire(nvmet_ns_ref);
}
static inline void nvmet_subsys_unlock(struct nvmet_subsys *subsys)
__releases(nvmet_ns_ref)
{
__release(nvmet_ns_ref);
mutex_unlock(&subsys->lock);
}
If we can successfully model the namespace reference-counting semantics using token
context locks, that would be a nice improvement. It would also allow us to get rid
of the NVMET_NS_ACCESSOR() macro, which currently expands into helpers marked with
__context_unsafe().
I'll first experiment with modeling the namespace reference-counting logic using
token context locks. If that works out, I'll respin the series accordingly.
>> Also pass subsys as an explicit argument to nvmet_p2pmem_ns_add_p2p()
>> and nvmet_setup_p2p_ns_map(). This allows their __must_hold()
>> annotations and lockdep assertions to reference subsys->lock directly,
>> rather than accessing the same lock through ctrl->subsys->lock.
>
> How many changes does this patch include? Should this patch perhaps be
> split?
> Yes in the next revision, I'll split the changes.
Thanks,
--Nilay
next prev parent reply other threads:[~2026-11-19 14:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:34 [PATCH v2 00/22] nvmet: add context annotation for params in struct nvmet_ns Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 01/22] nvmet: add context annotation for nvmet_ns::bdev Nilay Shroff
2026-11-19 0:06 ` Bart Van Assche
2026-11-19 14:20 ` Nilay Shroff [this message]
2026-11-19 0:25 ` Bart Van Assche
2026-11-19 7:03 ` Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 02/22] nvmet: fix nvmet_ns::bdev access using nvmet_subsys::lock Nilay Shroff
2026-11-19 0:08 ` Bart Van Assche
2026-11-19 9:10 ` Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 03/22] nvmet: add context annotation for nvmet_ns::file Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 04/22] nvmet: add context annotation for nvmet_ns::bdev_file Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 05/22] nvmet: add context annotation for nvmet_ns::readonly Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 06/22] nvmet: add context annotation for nvmet_ns::blksize_shift Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 07/22] nvmet: add context annotation for nvmet_ns::size Nilay Shroff
2026-11-18 7:50 ` sashiko-bot
2026-11-18 7:34 ` [PATCH v2 08/22] nvmet: add context annotation for nvmet_ns::nguid Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 09/22] nvmet: add context annotation for nvmet_ns::uuid Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 10/22] nvmet: fix nvmet_ns::uuid access using nvmet_subsys::lock Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 11/22] nvmet: add context annotation for nvmet_ns::buffered_io Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 12/22] nvmet: fix nvmet_ns::buffered_io access using nvmet_subsys::lock Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 13/22] nvmet: add context annotation for nvmet_ns::enabled Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 14/22] nvmet: fix nvmet_ns::enable access using nvmet_subsys::lock Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 15/22] nvmet: add context annotation for nvmet_ns::device_path Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 16/22] nvmet: fix nvmet_ns::device_path access using nvmet_subsys::lock Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 17/22] nvmet: add context annotation for PCI P2P parameters in struct nvmet_ns Nilay Shroff
2026-11-18 7:34 ` [PATCH v2 18/22] nvmet: fix PCI P2P parameters access using nvmet_subsys::lock Nilay Shroff
2026-11-18 7:55 ` sashiko-bot
2026-11-18 7:35 ` [PATCH v2 19/22] nvmet: add context annotation for integrity params in struct nvmet_ns Nilay Shroff
2026-11-18 7:35 ` [PATCH v2 20/22] nvmet: add context annotation for nvmet_ns::csi Nilay Shroff
2026-11-18 7:35 ` [PATCH v2 21/22] nvmet: fix nvmet_ns::csi access using nvmet_subsys::lock Nilay Shroff
2026-11-18 7:35 ` [PATCH v2 22/22] nvmet: add context annotation for nvmet_ns::debugfs_dir Nilay Shroff
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=6790a3d2-52a8-4baa-95aa-a04073d25e4a@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=chaitanyak@nvidia.com \
--cc=elver@google.com \
--cc=gjoyce@linux.ibm.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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