Skip to content

Commit f67e3fb

Browse files
committed
Merge tag 'devdax-for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull device-dax updates from Dan Williams: "New device-dax infrastructure to allow persistent memory and other "reserved" / performance differentiated memories, to be assigned to the core-mm as "System RAM". Some users want to use persistent memory as additional volatile memory. They are willing to cope with potential performance differences, for example between DRAM and 3D Xpoint, and want to use typical Linux memory management apis rather than a userspace memory allocator layered over an mmap() of a dax file. The administration model is to decide how much Persistent Memory (pmem) to use as System RAM, create a device-dax-mode namespace of that size, and then assign it to the core-mm. The rationale for device-dax is that it is a generic memory-mapping driver that can be layered over any "special purpose" memory, not just pmem. On subsequent boots udev rules can be used to restore the memory assignment. One implication of using pmem as RAM is that mlock() no longer keeps data off persistent media. For this reason it is recommended to enable NVDIMM Security (previously merged for 5.0) to encrypt pmem contents at rest. We considered making this recommendation an actively enforced requirement, but in the end decided to leave it as a distribution / administrator policy to allow for emulation and test environments that lack security capable NVDIMMs. Summary: - Replace the /sys/class/dax device model with /sys/bus/dax, and include a compat driver so distributions can opt-in to the new ABI. - Allow for an alternative driver for the device-dax address-range - Introduce the 'kmem' driver to hotplug / assign a device-dax address-range to the core-mm. - Arrange for the device-dax target-node to be onlined so that the newly added memory range can be uniquely referenced by numa apis" NOTE! I'm not entirely happy with the whole "PMEM as RAM" model because we currently have special - and very annoying rules in the kernel about accessing PMEM only with the "MC safe" accessors, because machine checks inside the regular repeat string copy functions can be fatal in some (not described) circumstances. And apparently the PMEM modules can cause that a lot more than regular RAM. The argument is that this happens because PMEM doesn't necessarily get scrubbed at boot like RAM does, but that is planned to be added for the user space tooling. Quoting Dan from another email: "The exposure can be reduced in the volatile-RAM case by scanning for and clearing errors before it is onlined as RAM. The userspace tooling for that can be in place before v5.1-final. There's also runtime notifications of errors via acpi_nfit_uc_error_notify() from background scrubbers on the DIMM devices. With that mechanism the kernel could proactively clear newly discovered poison in the volatile case, but that would be additional development more suitable for v5.2. I understand the concern, and the need to highlight this issue by tapping the brakes on feature development, but I don't see PMEM as RAM making the situation worse when the exposure is also there via DAX in the PMEM case. Volatile-RAM is arguably a safer use case since it's possible to repair pages where the persistent case needs active application coordination" * tag 'devdax-for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: device-dax: "Hotplug" persistent memory for use like normal RAM mm/resource: Let walk_system_ram_range() search child resources mm/memory-hotplug: Allow memory resources to be children mm/resource: Move HMM pr_debug() deeper into resource code mm/resource: Return real error codes from walk failures device-dax: Add a 'modalias' attribute to DAX 'bus' devices device-dax: Add a 'target_node' attribute device-dax: Auto-bind device after successful new_id acpi/nfit, device-dax: Identify differentiated memory with a unique numa-node device-dax: Add /sys/class/dax backwards compatibility device-dax: Add support for a dax override driver device-dax: Move resource pinning+mapping into the common driver device-dax: Introduce bus + driver model device-dax: Start defining a dax bus model device-dax: Remove multi-resource infrastructure device-dax: Kill dax_region base device-dax: Kill dax_region ida
2 parents 477558d + c221c0b commit f67e3fb

File tree

30 files changed

+1111
-537
lines changed

30 files changed

+1111
-537
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
What: /sys/class/dax/
2+
Date: May, 2016
3+
KernelVersion: v4.7
4+
Contact: linux-nvdimm@lists.01.org
5+
Description: Device DAX is the device-centric analogue of Filesystem
6+
DAX (CONFIG_FS_DAX). It allows memory ranges to be
7+
allocated and mapped without need of an intervening file
8+
system. Device DAX is strict, precise and predictable.
9+
Specifically this interface:
10+
11+
1/ Guarantees fault granularity with respect to a given
12+
page size (pte, pmd, or pud) set at configuration time.
13+
14+
2/ Enforces deterministic behavior by being strict about
15+
what fault scenarios are supported.
16+
17+
The /sys/class/dax/ interface enumerates all the
18+
device-dax instances in the system. The ABI is
19+
deprecated and will be removed after 2020. It is
20+
replaced with the DAX bus interface /sys/bus/dax/ where
21+
device-dax instances can be found under
22+
/sys/bus/dax/devices/

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
239239
memset(&ndr_desc, 0, sizeof(ndr_desc));
240240
ndr_desc.attr_groups = region_attr_groups;
241241
ndr_desc.numa_node = dev_to_node(&p->pdev->dev);
242+
ndr_desc.target_node = ndr_desc.numa_node;
242243
ndr_desc.res = &p->res;
243244
ndr_desc.of_node = p->dn;
244245
ndr_desc.provider_data = p;

drivers/acpi/nfit/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,11 +2956,15 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
29562956
ndr_desc->res = &res;
29572957
ndr_desc->provider_data = nfit_spa;
29582958
ndr_desc->attr_groups = acpi_nfit_region_attribute_groups;
2959-
if (spa->flags & ACPI_NFIT_PROXIMITY_VALID)
2959+
if (spa->flags & ACPI_NFIT_PROXIMITY_VALID) {
29602960
ndr_desc->numa_node = acpi_map_pxm_to_online_node(
29612961
spa->proximity_domain);
2962-
else
2962+
ndr_desc->target_node = acpi_map_pxm_to_node(
2963+
spa->proximity_domain);
2964+
} else {
29632965
ndr_desc->numa_node = NUMA_NO_NODE;
2966+
ndr_desc->target_node = NUMA_NO_NODE;
2967+
}
29642968

29652969
/*
29662970
* Persistence domain bits are hierarchical, if

drivers/acpi/numa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ int acpi_map_pxm_to_node(int pxm)
8484

8585
return node;
8686
}
87+
EXPORT_SYMBOL(acpi_map_pxm_to_node);
8788

8889
/**
8990
* acpi_map_pxm_to_online_node - Map proximity ID to online node

drivers/base/memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ unsigned long __weak memory_block_size_bytes(void)
8888
{
8989
return MIN_MEMORY_BLOCK_SIZE;
9090
}
91+
EXPORT_SYMBOL_GPL(memory_block_size_bytes);
9192

9293
static unsigned long get_memory_block_size(void)
9394
{

drivers/dax/Kconfig

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,38 @@ config DEV_DAX
2323
config DEV_DAX_PMEM
2424
tristate "PMEM DAX: direct access to persistent memory"
2525
depends on LIBNVDIMM && NVDIMM_DAX && DEV_DAX
26+
depends on m # until we can kill DEV_DAX_PMEM_COMPAT
2627
default DEV_DAX
2728
help
2829
Support raw access to persistent memory. Note that this
2930
driver consumes memory ranges allocated and exported by the
3031
libnvdimm sub-system.
3132

32-
Say Y if unsure
33+
Say M if unsure
34+
35+
config DEV_DAX_KMEM
36+
tristate "KMEM DAX: volatile-use of persistent memory"
37+
default DEV_DAX
38+
depends on DEV_DAX
39+
depends on MEMORY_HOTPLUG # for add_memory() and friends
40+
help
41+
Support access to persistent memory as if it were RAM. This
42+
allows easier use of persistent memory by unmodified
43+
applications.
44+
45+
To use this feature, a DAX device must be unbound from the
46+
device_dax driver (PMEM DAX) and bound to this kmem driver
47+
on each boot.
48+
49+
Say N if unsure.
50+
51+
config DEV_DAX_PMEM_COMPAT
52+
tristate "PMEM DAX: support the deprecated /sys/class/dax interface"
53+
depends on DEV_DAX_PMEM
54+
default DEV_DAX_PMEM
55+
help
56+
Older versions of the libdaxctl library expect to find all
57+
device-dax instances under /sys/class/dax. If libdaxctl in
58+
your distribution is older than v58 say M, otherwise say N.
3359

3460
endif

drivers/dax/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_DAX) += dax.o
33
obj-$(CONFIG_DEV_DAX) += device_dax.o
4-
obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o
4+
obj-$(CONFIG_DEV_DAX_KMEM) += kmem.o
55

66
dax-y := super.o
7-
dax_pmem-y := pmem.o
7+
dax-y += bus.o
88
device_dax-y := device.o
9+
10+
obj-y += pmem/

0 commit comments

Comments
 (0)