From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Davidlohr Bueso <dave@stgolabs.net>, <x86@kernel.org>,
<nvdimm@lists.linux.dev>, <linux-cxl@vger.kernel.org>,
<peterz@infradead.org>, <bp@alien8.de>, <dave.jiang@intel.com>,
<vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
<a.manzanares@samsung.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] memregion: Add arch_flush_memregion() interface
Date: Fri, 9 Sep 2022 12:43:26 +0100 [thread overview]
Message-ID: <20220909124326.00002c85@huawei.com> (raw)
In-Reply-To: <631a7932c6eb5_166f2945d@dwillia2-xfh.jf.intel.com.notmuch>
On Thu, 8 Sep 2022 16:22:26 -0700
Dan Williams <dan.j.williams@intel.com> wrote:
> Andrew Morton wrote:
> > On Thu, 8 Sep 2022 15:51:50 -0700 Dan Williams <dan.j.williams@intel.com> wrote:
> >
> > > Jonathan Cameron wrote:
> > > > On Wed, 7 Sep 2022 18:07:31 -0700
> > > > Dan Williams <dan.j.williams@intel.com> wrote:
> > > >
> > > > > Andrew Morton wrote:
> > > > > > I really dislike the term "flush". Sometimes it means writeback,
> > > > > > sometimes it means invalidate. Perhaps at other times it means
> > > > > > both.
> > > > > >
> > > > > > Can we please be very clear in comments and changelogs about exactly
> > > > > > what this "flush" does. With bonus points for being more specific in the
> > > > > > function naming?
> > > > > >
> > > > >
> > > > > That's a good point, "flush" has been cargo-culted along in Linux's
> > > > > cache management APIs to mean write-back-and-invalidate. In this case I
> > > > > think this API is purely about invalidate. It just so happens that x86
> > > > > has not historically had a global invalidate instruction readily
> > > > > available which leads to the overuse of wbinvd.
> > > > >
> > > > > It would be nice to make clear that this API is purely about
> > > > > invalidating any data cached for a physical address impacted by address
> > > > > space management event (secure erase / new region provision). Write-back
> > > > > is an unnecessary side-effect.
> > > > >
> > > > > So how about:
> > > > >
> > > > > s/arch_flush_memregion/cpu_cache_invalidate_memregion/?
> > > >
> > > > Want to indicate it 'might' write back perhaps?
> > > > So could be invalidate or clean and invalidate (using arm ARM terms just to add
> > > > to the confusion ;)
> > > >
> > > > Feels like there will be potential race conditions where that matters as we might
> > > > force stale data to be written back.
> > > >
> > > > Perhaps a comment is enough for that. Anyone have the "famous last words" feeling?
> > >
> > > Is "invalidate" not clear that write-back is optional? Maybe not.
> >
> > Yes, I'd say that "invalidate" means "dirty stuff may of may not have
> > been written back". Ditto for invalidate_inode_pages2().
> >
> > > Also, I realized that we tried to include the address range to allow for
> > > the possibility of flushing by virtual address range, but that
> > > overcomplicates the use. I.e. if someone issue secure erase and the
> > > region association is not established does that mean that mean that the
> > > cache invalidation is not needed? It could be the case that someone
> > > disables a device, does the secure erase, and then reattaches to the
> > > same region. The cache invalidation is needed, but at the time of the
> > > secure erase the HPA was unknown.
> > >
> > > All this to say that I feel the bikeshedding will need to continue until
> > > morale improves.
> > >
> > > I notice that the DMA API uses 'sync' to indicate, "make this memory
> > > consistent/coherent for the CPU or the device", so how about an API like
> > >
> > > memregion_sync_for_cpu(int res_desc)
> > >
> > > ...where the @res_desc would be IORES_DESC_CXL for all CXL and
> > > IORES_DESC_PERSISTENT_MEMORY for the current nvdimm use case.
> >
> > "sync" is another of my pet peeves ;) In filesystem land, at least.
> > Does it mean "start writeback and return" or does it mean "start
> > writeback, wait for its completion then return".
>
> Ok, no "sync" :).
>
> /**
> * cpu_cache_invalidate_memregion - drop any CPU cached data for
> * memregions described by @res_des
> * @res_desc: one of the IORES_DESC_* types
> *
> * Perform cache maintenance after a memory event / operation that
> * changes the contents of physical memory in a cache-incoherent manner.
> * For example, memory-device secure erase, or provisioning new CXL
> * regions. This routine may or may not write back any dirty contents
> * while performing the invalidation.
> *
> * Returns 0 on success or negative error code on a failure to perform
> * the cache maintenance.
> */
> int cpu_cache_invalidate_memregion(int res_desc)
lgtm
>
> ??
next prev parent reply other threads:[~2022-09-09 11:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 21:29 [PATCH -next] memregion: Add arch_flush_memregion() interface Davidlohr Bueso
2022-08-29 23:02 ` Dan Williams
2022-09-07 14:36 ` Davidlohr Bueso
2022-09-07 16:46 ` Dan Williams
2022-09-07 16:05 ` Borislav Petkov
2022-09-07 16:22 ` Davidlohr Bueso
2022-09-07 16:52 ` Dan Williams
2022-09-07 17:24 ` Davidlohr Bueso
2022-09-08 4:35 ` Borislav Petkov
2022-09-08 6:53 ` Dan Williams
2022-09-08 13:00 ` Jonathan Cameron
2022-09-08 4:31 ` Borislav Petkov
2022-09-07 22:30 ` Andrew Morton
2022-09-08 1:07 ` Dan Williams
2022-09-08 13:13 ` Jonathan Cameron
2022-09-08 22:51 ` Dan Williams
2022-09-08 23:00 ` Andrew Morton
2022-09-08 23:22 ` Dan Williams
2022-09-09 11:43 ` Jonathan Cameron [this message]
2022-09-13 15:56 ` 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=20220909124326.00002c85@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=a.manzanares@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--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=nvdimm@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=vishal.l.verma@intel.com \
--cc=x86@kernel.org \
/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 NNTP newsgroup(s).