Linux CXL
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Dan Williams <dan.j.williams@intel.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Dave Jiang <dave.jiang@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <dan.j.williams@intel.com>,
	<ira.weiny@intel.com>, <vishal.l.verma@intel.com>,
	<alison.schofield@intel.com>, <Jonathan.Cameron@huawei.com>,
	<peterz@infradead.org>
Subject: Re: [PATCH v3] cxl: Add cxl_region_rwsem around commit_end write during decoder enumeration
Date: Wed, 22 Nov 2023 17:02:18 -0800	[thread overview]
Message-ID: <655ea49a7ce96_b2e8294c7@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <655e75e929fc0_b2e829478@dwillia2-xfh.jf.intel.com.notmuch>

Dan Williams wrote:
> Davidlohr Bueso wrote:
> > On Fri, 17 Nov 2023, Dave Jiang wrote:
> > 
> > >init_hdm_decoder() modifies port->commit_end without taking the
> > >cxl_region_rwsem. An assert splat emitted by cxl_num_decoders_committed().
> > >However looking at the code, it looks like the write version of the rwsem
> > >needs to be taken due to the modification of commit_end. Wrap the write
> > >version of the rwsem around reading and writing of commit_end.
> > >
> > >Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware")
> > >Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> > 
> > Uhmm but do we expect concurrency during the switch/port probing phase?
> 
> I answered that that detail here in response to Fan:
> 
> http://lore.kernel.org/r/654eb8ed72ced_46f0294c@dwillia2-mobl3.amr.corp.intel.com.notmuch
> 
> The takeaway is:
> 
> "I am in favor of adding the locking rather than depend on a subtle
> side-effect of how CXL operates, and to avoid adding an unlocked version
> of cxl_num_decoders_committed()"
> 
> I will add a note to the changelog to that effect, and drop Fixes: since
> the lock is not strictly required for correctness in this path.

I rewrote the changelog to this:

Author: Dave Jiang <dave.jiang@intel.com>
Date:   Fri Nov 17 13:18:48 2023 -0700

    cxl/hdm: Fix a benign lockdep splat
    
    The new helper "cxl_num_decoders_committed()" added a lockdep assertion
    to validate that port->commit_end is protected against modification.
    That assertion fires in init_hdm_decoder() where it is initializing
    port->commit_end. Given that it is both accessing and writing that
    property it obstensibly needs the lock.
    
    In practice, CXL decoder commit rules (must commit in order) and the
    in-order discovery of device decoders makes the manipulation of
    ->commit_end in init_hdm_decoder() safe. However, rather than rely on
    the subtle rules of CXL hardware, just make the implementation obviously
    correct from a software perspective.
    
    The Fixes: tag is only for cleaning up a lockdep splat, there is no
    functional issue addressed by this fix.
    
    Fixes: 458ba8189cb4 ("cxl: Add cxl_decoders_committed() helper")

  reply	other threads:[~2023-11-23  1:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 20:18 [PATCH v3] cxl: Add cxl_region_rwsem around commit_end write during decoder enumeration Dave Jiang
2023-11-20 16:04 ` Davidlohr Bueso
2023-11-20 17:04   ` Dave Jiang
2023-11-22 21:43   ` Dan Williams
2023-11-23  1:02     ` Dan Williams [this message]
2023-11-27 17:09       ` Dave Jiang
2023-11-27 17:39       ` Davidlohr Bueso
2023-11-30  1:01         ` Dan Williams
2023-11-30 16:15           ` Davidlohr Bueso

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=655ea49a7ce96_b2e8294c7@dwillia2-xfh.jf.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=peterz@infradead.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