From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Oscar Salvador" <osalvador@suse.de>,
<linux-kernel@vger.kernel.org>, <nvdimm@lists.linux.dev>,
<linux-cxl@vger.kernel.org>, David Hildenbrand <david@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Huang Ying <ying.huang@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-mm@kvack.org>, Joao Martins <joao.m.martins@oracle.com>
Subject: Re: [PATCH v6 2/4] dax/bus: Use guard(device) in sysfs attribute helpers
Date: Tue, 19 Dec 2023 15:27:26 +0000 [thread overview]
Message-ID: <20231219152726.0000228f@Huawei.com> (raw)
In-Reply-To: <20231214-vv-dax_abi-v6-2-ad900d698438@intel.com>
On Thu, 14 Dec 2023 22:25:27 -0700
Vishal Verma <vishal.l.verma@intel.com> wrote:
> Use the guard(device) macro to lock a 'struct device', and unlock it
> automatically when going out of scope using Scope Based Resource
> Management semantics. A lot of the sysfs attribute writes in
> drivers/dax/bus.c benefit from a cleanup using these, so change these
> where applicable.
>
> Cc: Joao Martins <joao.m.martins@oracle.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Hi Vishal,
A few really minor suggestions inline if you happen to be doing a v7.
Either way
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> @@ -481,12 +466,9 @@ static int __free_dev_dax_id(struct dev_dax *dev_dax)
> static int free_dev_dax_id(struct dev_dax *dev_dax)
> {
> struct device *dev = &dev_dax->dev;
> - int rc;
>
> - device_lock(dev);
> - rc = __free_dev_dax_id(dev_dax);
> - device_unlock(dev);
> - return rc;
> + guard(device)(dev);
guard(device)(&dev_dax->dev); /* Only one user now */
> + return __free_dev_dax_id(dev_dax);
> }
>
> static int alloc_dev_dax_id(struct dev_dax *dev_dax)
> @@ -908,9 +890,8 @@ static ssize_t size_show(struct device *dev,
> struct dev_dax *dev_dax = to_dev_dax(dev);
> unsigned long long size;
>
> - device_lock(dev);
> + guard(device)(dev);
> size = dev_dax_size(dev_dax);
> - device_unlock(dev);
>
> return sprintf(buf, "%llu\n", size);
Might as well make this
guard(device)(dev);
return sprintf(buf, "%llu\n", dev_dax_size(to_dev_dax(dev));
> }
next prev parent reply other threads:[~2023-12-19 15:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 5:25 [PATCH v6 0/4] Add DAX ABI for memmap_on_memory Vishal Verma
2023-12-15 5:25 ` [PATCH v6 1/4] Documentatiion/ABI: Add ABI documentation for sys-bus-dax Vishal Verma
2023-12-15 5:25 ` [PATCH v6 2/4] dax/bus: Use guard(device) in sysfs attribute helpers Vishal Verma
2023-12-15 5:56 ` Matthew Wilcox
2023-12-15 6:33 ` Verma, Vishal L
2023-12-15 16:14 ` gregkh
2023-12-15 7:27 ` Greg Kroah-Hartman
2023-12-15 17:15 ` Dan Williams
2023-12-15 17:32 ` Verma, Vishal L
2023-12-15 17:53 ` gregkh
2023-12-19 15:27 ` Jonathan Cameron [this message]
2023-12-15 5:25 ` [PATCH v6 3/4] mm/memory_hotplug: export mhp_supports_memmap_on_memory() Vishal Verma
2023-12-15 5:25 ` [PATCH v6 4/4] dax: add a sysfs knob to control memmap_on_memory behavior Vishal Verma
2023-12-15 7:53 ` Huang, Ying
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=20231219152726.0000228f@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=david@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=joao.m.martins@oracle.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).