From: Dan Williams <dan.j.williams@intel.com>
To: Alison Schofield <alison.schofield@intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ben Widawsky <bwidawsk@kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
<linux-cxl@vger.kernel.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v12 3/6] cxl/memdev: Add trigger_poison_list sysfs attribute
Date: Wed, 12 Apr 2023 12:34:51 -0700 [thread overview]
Message-ID: <643707dbac39b_5f756294c3@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <ZDb5LptUNNnej/cc@aschofie-mobl2>
Alison Schofield wrote:
[..]
> > > + bool trigger;
> > > + ssize_t rc;
> > > +
> > > + if (kstrtobool(buf, &trigger) || !trigger)
> > > + return -EINVAL;
> >
> > Hmm, the caller could to this too...
>
> Why split the work?
>
> It seems having the caller do a little bit of work, and then pass it on,
> hurts readability. ATM, the caller does nothing, and here we do all
> the usual sysfs handling. The division of power is crisp. If it's not
> an efficiency concern, why make it less readable?
Ah interesting, I am coming at it from a Separation of Concerns
perspective.
The core functionality being exported is a method to retrieve poison
records and emit them as trace-events. Whether that is in response to
sysfs stimulus or some other stimulus is not something the core needs to
care about. An export of cxl_get_poison_by_memdev() is an API that can
have multiple users, cxl_trigger_poison_list() is an API that is
purpose-built for one user. The motivation is to have the core API be
potentially useful for multiple contexts.
One thought experiement is write a kernel-doc comment for
cxl_trigger_poison_list(). It would need to say something like "this API
is only for the cxl_mem driver to use for its sysfs attribute", while
the kernel-doc for cxl_get_poison_by_memdev() can remain generic.
So the general ask here is create new CXL core exports that can be read
and understood independent of their callers.
> > ...the below seems to be the bit that the cxl_core cares about handling.
> >
> > > +
> > > + down_read(&cxl_dpa_rwsem);
> >
> > down_read_interruptible() since this is coming from userspace.
>
> Thanks, got it!
>
> >
> > > + rc = cxl_get_poison_by_memdev(cxlmd);
> > > + up_read(&cxl_dpa_rwsem);
> > > +
> > > + return rc ? rc : len;
> >
> > The caller can do this conversion.
> >
> > > +}
> > > +EXPORT_SYMBOL_NS_GPL(cxl_trigger_poison_list, CXL);
> > > +
> > > static struct attribute *cxl_memdev_attributes[] = {
> > > &dev_attr_serial.attr,
> > > &dev_attr_firmware_version.attr,
> > > @@ -130,6 +177,7 @@ static umode_t cxl_memdev_visible(struct kobject *kobj, struct attribute *a,
> > > {
> > > if (!IS_ENABLED(CONFIG_NUMA) && a == &dev_attr_numa_node.attr)
> > > return 0;
> > > +
> >
> > I am surprised that Jonathan let this slide :).
>
> He caught it, so did DaveJ. It just won't go away.
I feel your pain, these things are sneaky.
next prev parent reply other threads:[~2023-04-12 19:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 20:55 [PATCH v12 0/6] CXL Poison List Retrieval & Tracing alison.schofield
2023-04-10 20:55 ` [PATCH v12 1/6] cxl/mbox: Add GET_POISON_LIST mailbox command alison.schofield
2023-04-12 1:47 ` Dan Williams
2023-04-12 4:45 ` Alison Schofield
2023-04-12 5:18 ` Dan Williams
2023-04-12 18:01 ` Alison Schofield
2023-04-12 19:16 ` Dan Williams
2023-04-12 18:06 ` Alison Schofield
2023-04-13 16:48 ` Alison Schofield
2023-04-13 18:34 ` Dan Williams
2023-04-17 16:32 ` Alison Schofield
2023-04-17 19:39 ` Dan Williams
2023-04-10 20:55 ` [PATCH v12 2/6] cxl/trace: Add TRACE support for CXL media-error records alison.schofield
2023-04-10 20:55 ` [PATCH v12 3/6] cxl/memdev: Add trigger_poison_list sysfs attribute alison.schofield
2023-04-12 5:37 ` Dan Williams
2023-04-12 18:32 ` Alison Schofield
2023-04-12 19:34 ` Dan Williams [this message]
2023-04-10 20:55 ` [PATCH v12 4/6] cxl/region: Provide region info to the cxl_poison trace event alison.schofield
2023-04-12 5:55 ` Dan Williams
2023-04-12 18:39 ` Alison Schofield
2023-04-12 22:09 ` Dan Williams
2023-04-10 20:55 ` [PATCH v12 5/6] cxl/trace: Add an HPA to cxl_poison trace events alison.schofield
2023-04-10 20:55 ` [PATCH v12 6/6] tools/testing/cxl: Mock support for Get Poison List 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=643707dbac39b_5f756294c3@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=rostedt@goodmis.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