]> git.ipfire.org Git - thirdparty/linux.git/commit - lib/Kconfig
x86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass operations
authorDan Williams <dan.j.williams@intel.com>
Mon, 29 May 2017 19:22:50 +0000 (12:22 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 9 Jun 2017 16:09:56 +0000 (09:09 -0700)
commit0aed55af88345b5d673240f90e671d79662fb01e
treeb4ebcb7d95e47a7fef48558daafc0e527c1e60ca
parent3c2993b8c6143d8a5793746a54eba8f86f95240f
x86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass operations

The pmem driver has a need to transfer data with a persistent memory
destination and be able to rely on the fact that the destination writes are not
cached. It is sufficient for the writes to be flushed to a cpu-store-buffer
(non-temporal / "movnt" in x86 terms), as we expect userspace to call fsync()
to ensure data-writes have reached a power-fail-safe zone in the platform. The
fsync() triggers a REQ_FUA or REQ_FLUSH to the pmem driver which will turn
around and fence previous writes with an "sfence".

Implement a __copy_from_user_inatomic_flushcache, memcpy_page_flushcache, and
memcpy_flushcache, that guarantee that the destination buffer is not dirty in
the cpu cache on completion. The new copy_from_iter_flushcache and sub-routines
will be used to replace the "pmem api" (include/linux/pmem.h +
arch/x86/include/asm/pmem.h). The availability of copy_from_iter_flushcache()
and memcpy_flushcache() are gated by the CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
config symbol, and fallback to copy_from_iter_nocache() and plain memcpy()
otherwise.

This is meant to satisfy the concern from Linus that if a driver wants to do
something beyond the normal nocache semantics it should be something private to
that driver [1], and Al's concern that anything uaccess related belongs with
the rest of the uaccess code [2].

The first consumer of this interface is a new 'copy_from_iter' dax operation so
that pmem can inject cache maintenance operations without imposing this
overhead on other dax-capable drivers.

[1]: https://lists.01.org/pipermail/linux-nvdimm/2017-January/008364.html
[2]: https://lists.01.org/pipermail/linux-nvdimm/2017-April/009942.html

Cc: <x86@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Toshi Kani <toshi.kani@hpe.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 files changed:
arch/x86/Kconfig
arch/x86/include/asm/string_64.h
arch/x86/include/asm/uaccess_64.h
arch/x86/lib/usercopy_64.c
drivers/acpi/nfit/core.c
drivers/nvdimm/claim.c
drivers/nvdimm/pmem.c
drivers/nvdimm/region_devs.c
include/linux/dax.h
include/linux/string.h
include/linux/uio.h
lib/Kconfig
lib/iov_iter.c