From: Dan Williams <dan.j.williams@intel.com>
To: <alison.schofield@intel.com>, Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Dave Jiang <dave.jiang@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>
Subject: RE: [PATCH] cxl/core: Hold the region rwsem during poison ops
Date: Wed, 22 Nov 2023 17:48:45 -0800 [thread overview]
Message-ID: <655eaf7d73e_b2e82943a@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20231114025342.1123681-1-alison.schofield@intel.com>
alison.schofield@ wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> Commit 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper")
> added a lockdep_assert_held() to make sure all callers hold the
> region state stable while doing work that depends on the number
> of committed decoders.
>
> That lockdep assert triggered in poison list, inject, and clear
> functions highlighting a gap between region attach and decoder
> commit where holding the dpa_rwsem is not enough to assure that
> a DPA is not added to a region. In such a case, if poison is
> found in at that DPA, the trace event omits the region info
> that users expect.
>
> Close the gap by snapshotting an unchangeable region state during
> all poison ops. Hold the region_rwsem in all the places that hold
> the dpa_rwsem rather than in the region specific function only.
>
> Fixes: 7ff6ad107588 ("cxl/memdev: Add trigger_poison_list sysfs attribute")
> Fixes: f0832a586396 ("cxl/region: Provide region info to the cxl_poison trace event")
> Fixes: d2fbc4865802 ("cxl/memdev: Add support for the Inject Poison mailbox command")
> Fixes: 9690b07748d1 ("cxl/memdev: Add support for the Clear Poison mailbox command")
I think this is an indication that the fixes would benefit from being
broken up into at least 2 commits so that the specific side effect of
each can be commented upon.
For example:
- Fix walking committed decoders in cxl_trigger_poison_list()
- Fix walking dpa to region lookups in cxl_{inject,clear}_poison()
...look like 2 separate topics in this combined patch.
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
> drivers/cxl/core/memdev.c | 18 +++++++++---------
> drivers/cxl/core/region.c | 5 -----
> 2 files changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index fc5c2b414793..961da365b097 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -227,9 +227,8 @@ int cxl_trigger_poison_list(struct cxl_memdev *cxlmd)
> if (!port || !is_cxl_endpoint(port))
> return -EINVAL;
>
> - rc = down_read_interruptible(&cxl_dpa_rwsem);
> - if (rc)
> - return rc;
What the rationale for dropping interruptible, it seems appropriate here
since this function is directly servicing a debugfs trigger and maybe
someone gets tired of waiting.
> + down_read(&cxl_region_rwsem);
> + down_read(&cxl_dpa_rwsem);
>
> if (cxl_num_decoders_committed(port) == 0) {
> /* No regions mapped to this memdev */
> @@ -239,6 +238,7 @@ int cxl_trigger_poison_list(struct cxl_memdev *cxlmd)
> rc = cxl_get_poison_by_endpoint(port);
> }
> up_read(&cxl_dpa_rwsem);
> + up_read(&cxl_region_rwsem);
>
> return rc;
> }
> @@ -324,9 +324,8 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
> if (!IS_ENABLED(CONFIG_DEBUG_FS))
> return 0;
>
> - rc = down_read_interruptible(&cxl_dpa_rwsem);
> - if (rc)
> - return rc;
> + down_read(&cxl_region_rwsem);
> + down_read(&cxl_dpa_rwsem);
>
> rc = cxl_validate_poison_dpa(cxlmd, dpa);
> if (rc)
> @@ -355,6 +354,7 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
> trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_INJECT);
> out:
> up_read(&cxl_dpa_rwsem);
> + up_read(&cxl_region_rwsem);
>
> return rc;
> }
> @@ -372,9 +372,8 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
> if (!IS_ENABLED(CONFIG_DEBUG_FS))
> return 0;
>
> - rc = down_read_interruptible(&cxl_dpa_rwsem);
> - if (rc)
> - return rc;
> + down_read(&cxl_region_rwsem);
> + down_read(&cxl_dpa_rwsem);
>
> rc = cxl_validate_poison_dpa(cxlmd, dpa);
> if (rc)
> @@ -412,6 +411,7 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
> trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_CLEAR);
> out:
> up_read(&cxl_dpa_rwsem);
> + up_read(&cxl_region_rwsem);
>
> return rc;
> }
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 56e575c79bb4..3e817a6f94c6 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2467,10 +2467,6 @@ int cxl_get_poison_by_endpoint(struct cxl_port *port)
> struct cxl_poison_context ctx;
> int rc = 0;
>
> - rc = down_read_interruptible(&cxl_region_rwsem);
> - if (rc)
> - return rc;
> -
> ctx = (struct cxl_poison_context) {
> .port = port
> };
> @@ -2480,7 +2476,6 @@ int cxl_get_poison_by_endpoint(struct cxl_port *port)
> rc = cxl_get_poison_unmapped(to_cxl_memdev(port->uport_dev),
> &ctx);
>
> - up_read(&cxl_region_rwsem);
> return rc;
This hunk deserves to be called out that region locking is being
upleveled as part of topic 1, and this reinforces splitting the 2 topics
into 2 patches.
Keep the _interruptible versions throughout, if you want to drop
interruptible that should be a separate follow-on behavior change patch.
The need to keep _interruptible also obviates conversion to cleanup.h
helpers for now.
next prev parent reply other threads:[~2023-11-23 1:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 2:53 [PATCH] cxl/core: Hold the region rwsem during poison ops alison.schofield
2023-11-14 18:20 ` Dave Jiang
2023-11-14 18:25 ` [PATCH] cxl: Convert pioson ops rwsem usages to scope based resource management Dave Jiang
2023-11-15 23:32 ` Alison Schofield
2023-11-15 23:55 ` Dave Jiang
2023-11-16 2:17 ` Alison Schofield
2023-11-16 16:27 ` Dave Jiang
2023-11-23 1:12 ` Dan Williams
2023-11-23 1:33 ` Dan Williams
2023-11-16 22:14 ` [PATCH] cxl/core: Hold the region rwsem during poison ops Davidlohr Bueso
2023-11-20 19:07 ` Alison Schofield
2023-11-23 1:48 ` Dan Williams [this message]
2023-11-27 0:03 ` Alison Schofield
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=655eaf7d73e_b2e82943a@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=vishal.l.verma@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox