public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Ying Huang <ying.huang@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Alison Schofield <alison.schofield@intel.com>,
	"Vishal Verma" <vishal.l.verma@intel.com>,
	<linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] cxl/region: Remove lock from memory notifier callback
Date: Mon, 16 Sep 2024 10:36:42 +0100	[thread overview]
Message-ID: <20240916103642.00007c8a@Huawei.com> (raw)
In-Reply-To: <66e48742afe0f_e45da29448@iweiny-mobl.notmuch>

On Fri, 13 Sep 2024 13:41:06 -0500
Ira Weiny <ira.weiny@intel.com> wrote:

> Jonathan Cameron wrote:
> > On Wed, 04 Sep 2024 09:47:54 -0500
> > Ira Weiny <ira.weiny@intel.com> wrote:
> >   
> 
> [snip]
> 
> > > 
> > > Link: https://lore.kernel.org/all/66b4cf539a79b_a36e829416@iweiny-mobl.notmuch/ [0]
> > > Cc: Ying Huang <ying.huang@intel.com>
> > > Suggested-by: Dan Williams <dan.j.williams@intel.com>
> > > Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
> > > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > Reviewed-by: Ying Huang <ying.huang@intel.com>
> > > Signed-off-by: Ira Weiny <ira.weiny@intel.com>  
> > A few comments on looking at this again, but all things that apply equally to old
> > code so maybe things for another day.  
> 
> Yea this was solely a move of existing code to fix the locking issue.  I
> did not evaluate the original code.  However...
> 
> [snip]
> 
> > >  }
> > >  
> > > +static void shutdown_notifiers(void *_cxlr)
> > > +{
> > > +	struct cxl_region *cxlr = _cxlr;
> > > +
> > > +	unregister_memory_notifier(&cxlr->memory_notifier);
> > > +	unregister_mt_adistance_algorithm(&cxlr->adist_notifier);  
> > Flip order.
> > 
> > Makes zero real difference, but if we later end up with more to do
> > here for some reason there may be ordering requirements that will
> > care that this doesn't tear down in reverse of setup.  
> 
> Generally I agree with you however, the memory and adist notifiers are
> unrelated.  So failing to unwind in reverse order is a matter of taste and
> is not required even if some other logic was introduced between the
> registrations I don't see how this backwards order would be an issue.

Not an issue as such, but if it requires a tiny bit of thinking
that we've engaged in here then it was worth the obviously correct
ordering. Not worth churn of a patch though.

> 
> > 
> > Mind you, see below.
> >   
> > > +}
> > > +
> > >  static int cxl_region_probe(struct device *dev)
> > >  {
> > >  	struct cxl_region *cxlr = to_cxl_region(dev);
> > > @@ -3418,6 +3412,18 @@ static int cxl_region_probe(struct device *dev)
> > >  out:
> > >  	up_read(&cxl_region_rwsem);
> > >  
> > > +	if (rc)
> > > +		return rc;
> > > +
> > > +	cxlr->memory_notifier.notifier_call = cxl_region_perf_attrs_callback;
> > > +	cxlr->memory_notifier.priority = CXL_CALLBACK_PRI;
> > > +	register_memory_notifier(&cxlr->memory_notifier);  
> > Can in theory fail.  Today that is EEXIST only but who knows in future.
> > I think we should handle that and do two devm_add_action_or_reset() perhaps?
> >   
> 
> First we should not fail the probe if this fails.
> 
> Second, nothing bad happens in unregister if the registration failed.
> Therefore, register failing is benign and I don't see a need for the extra
> action callback.

It's probably a case of print a warning only I guess.
Might be useful to know it's going wrong even though impact is not huge.
Personally I'd argue in favor of always failing to probe on a 'software issue'
like this where we don't expect to fail.  Things get less clear if we
fail on an optional hardware related part where carrying on may be
the reasonable thing to do.

Jonathan

> 
> Ira
> 
> [snip]
> 


      reply	other threads:[~2024-09-16  9:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 14:47 [PATCH v3] cxl/region: Remove lock from memory notifier callback Ira Weiny
2024-09-13 13:13 ` Jonathan Cameron
2024-09-13 18:41   ` Ira Weiny
2024-09-16  9:36     ` Jonathan Cameron [this message]

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=20240916103642.00007c8a@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=ying.huang@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