[PATCH v3 6/6] libnvdimm/namespace: Fix visibility of namespace resource attribute

2021-01-12 Thread Dan Williams
Legacy pmem namespaces lost support for the "resource" attribute when the code was cleaned up to put the permission visibility in the declaration. Restore this by listing 'resource' in the default attributes. A new ndctl regression test for pfn_to_online_page() corner cases builds on this fix.

[PATCH v3 5/6] mm: Fix memory_failure() handling of dax-namespace metadata

2021-01-12 Thread Dan Williams
Given 'struct dev_pagemap' spans both data pages and metadata pages be careful to consult the altmap if present to delineate metadata. In fact the pfn_first() helper already identifies the first valid data pfn, so export that helper for other code paths via pgmap_pfn_valid(). Other usage of

[PATCH v3 4/6] mm: Fix page reference leak in soft_offline_page()

2021-01-12 Thread Dan Williams
The conversion to move pfn_to_online_page() internal to soft_offline_page() missed that the get_user_pages() reference taken by the madvise() path needs to be dropped when pfn_to_online_page() fails. Note the direct sysfs-path to soft_offline_page() does not perform a get_user_pages() lookup.

[PATCH v3 3/6] mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions

2021-01-12 Thread Dan Williams
While pfn_to_online_page() is able to determine pfn_valid() at subsection granularity it is not able to reliably determine if a given pfn is also online if the section is mixes ZONE_{NORMAL,MOVABLE} with ZONE_DEVICE. This means that pfn_to_online_page() may return invalid @page objects. For

[PATCH v3 2/6] mm: Teach pfn_to_online_page() to consider subsection validity

2021-01-12 Thread Dan Williams
pfn_section_valid() determines pfn validity on subsection granularity where pfn_valid() may be limited to coarse section granularity. Explicitly validate subsections after pfn_valid() succeeds. Fixes: b13bc35193d9 ("mm/hotplug: invalid PFNs from pfn_to_online_page()") Cc: Qian Cai Cc: Michal

[PATCH v3 0/6] mm: Fix pfn_to_online_page() with respect to ZONE_DEVICE

2021-01-12 Thread Dan Williams
Changes since v2 [1]: - Collect some reviewed-by's from David and Oscar - Rework subsection validity to include pfn_valid() gated by CONFIG_HAVE_ARCH_PFN_VALID (David, Oscar) - Introduce pgmap_pfn_valid() to validate metadata vs data in a pgmap (David) ! Kill put_ref_page(): the extra "if

[PATCH v3 1/6] mm: Move pfn_to_online_page() out of line

2021-01-12 Thread Dan Williams
pfn_to_online_page() is already too large to be a macro or an inline function. In anticipation of further logic changes / growth, move it out of line. No functional change, just code movement. Reported-by: Michal Hocko Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by:

[ndctl PATCH 4/4] ndctl/test: Exercise soft_offline_page() corner cases

2021-01-12 Thread Dan Williams
Test soft-offline injection into PMEM namespace metadata and user mapped space. Both attempts should fail on kernels with a pfn_to_online_page() implementation that considers subsection ZONE_DEVICE ranges. Signed-off-by: Dan Williams --- test/dax-poison.c | 19 +++

[ndctl PATCH 3/4] ndctl/test: Fix device-dax mremap() test

2021-01-12 Thread Dan Williams
The test_dax_remap() test is a regression check for mishandling of mremap() in the presence of pmd_devmap(). My understanding is that it was a fuzzing condition not something an application would want to do in practice. On recent kernels with commit 73d5e0629919 ("mremap: check if it's possible

[ndctl PATCH 2/4] ndctl/test: Cleanup unnecessary out label

2021-01-12 Thread Dan Williams
There are no cleanup actions to take in test_dax_remap(), and it is already inconsistent for having a single return point, so remove the out label. Signed-off-by: Dan Williams --- test/dax-pmd.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/dax-pmd.c

[ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning

2021-01-12 Thread Dan Williams
../test/libndctl.c:989:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 989 | unsigned long long expect_table[][2] = { | ^~~~ ...just move the declaration a few lines up. Signed-off-by: Dan Williams --- test/libndctl.c | 12 ++--

[ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups

2021-01-12 Thread Dan Williams
Vishal, Here's a collection of test updates. It adds support for regression testing pfn_to_online_page() which suffered from a lack of precision in mixed zone memory-sections. Updates the mremap() regression to accept failure as an option (the behavior in v5.11-rc1+). Fixes a warning, and ditches

Re: [PATCH 1/1] msft: Add xlat_firmware_status for JEDEC Byte Addressable Energy Backed DSM

2021-01-12 Thread Dan Williams
[ notify Vishal ] On Sat, Jan 9, 2021 at 9:37 AM redhairer wrote: > > From: Redhairer Li > > Translate the status codes of the result of JEDEC Byte Addressable Energy > Backed > DSM to generic errno style error codes. > > Signed-off-by: Li Redhairer Looks good to me: Reviewed-by: Dan

Re: [PATCH 1/1] ndctl/namespace: Fix disable-namespace accounting relative to seed devices

2021-01-12 Thread Dan Williams
Hi Redhairer, sorry for the long delay circling back to this... On Mon, Apr 27, 2020 at 6:10 PM Li, Redhairer wrote: > > If make this return 0 in the case when size is zero, then seed device will be > counted in due to > case ACTION_DISABLE: > rc = ndctl_namespace_disable_safe(ndns); > if (rc

Re: [PATCH v2 2/5] mm: Teach pfn_to_online_page() to consider subsection validity

2021-01-12 Thread Dan Williams
On Tue, Jan 12, 2021 at 1:53 AM David Hildenbrand wrote: > > On 12.01.21 10:34, Dan Williams wrote: > > pfn_section_valid() determines pfn validity on subsection granularity. > > > > pfn_valid_within() internally uses pfn_section_valid(), but gates it > > with early_section() to preserve the

Re: [PATCH v2 4/5] mm: Fix page reference leak in soft_offline_page()

2021-01-12 Thread Dan Williams
On Tue, Jan 12, 2021 at 1:54 AM Oscar Salvador wrote: > > On Tue, Jan 12, 2021 at 01:34:58AM -0800, Dan Williams wrote: > > The conversion to move pfn_to_online_page() internal to > > soft_offline_page() missed that the get_user_pages() reference needs to > > be dropped when pfn_to_online_page()

RE: Expense of read_iter

2021-01-12 Thread David Laight
From: Zhongwei Cai > Sent: 12 January 2021 13:45 .. > The overhead mainly consists of two parts. The first is constructing > struct iov_iter and iterating it (i.e., new_sync, _copy_mc_to_iter and > iov_iter_init). The second is the dax io mechanism provided by VFS (i.e., > dax_iomap_rw,

[PATCH AUTOSEL 4.4 4/8] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap [ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ] fs/dax.c uses copy_user_page() but ARC does not provide that interface, resulting in a build error. Provide copy_user_page() in . ../fs/dax.c: In function 'copy_cow_page_dax': ../fs/dax.c:702:2: error: implicit

[PATCH AUTOSEL 4.9 4/8] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap [ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ] fs/dax.c uses copy_user_page() but ARC does not provide that interface, resulting in a build error. Provide copy_user_page() in . ../fs/dax.c: In function 'copy_cow_page_dax': ../fs/dax.c:702:2: error: implicit

[PATCH AUTOSEL 4.14 09/13] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap [ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ] fs/dax.c uses copy_user_page() but ARC does not provide that interface, resulting in a build error. Provide copy_user_page() in . ../fs/dax.c: In function 'copy_cow_page_dax': ../fs/dax.c:702:2: error: implicit

[PATCH AUTOSEL 4.19 11/16] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap [ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ] fs/dax.c uses copy_user_page() but ARC does not provide that interface, resulting in a build error. Provide copy_user_page() in . ../fs/dax.c: In function 'copy_cow_page_dax': ../fs/dax.c:702:2: error: implicit

[PATCH AUTOSEL 5.4 18/28] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap [ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ] fs/dax.c uses copy_user_page() but ARC does not provide that interface, resulting in a build error. Provide copy_user_page() in . ../fs/dax.c: In function 'copy_cow_page_dax': ../fs/dax.c:702:2: error: implicit

[PATCH AUTOSEL 5.10 34/51] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-12 Thread Sasha Levin
From: Randy Dunlap [ Upstream commit 8a48c0a3360bf2bf4f40c980d0ec216e770e58ee ] fs/dax.c uses copy_user_page() but ARC does not provide that interface, resulting in a build error. Provide copy_user_page() in . ../fs/dax.c: In function 'copy_cow_page_dax': ../fs/dax.c:702:2: error: implicit

Re: [PATCH 08/10] md: Implement ->corrupted_range()

2021-01-12 Thread Ruan Shiyang
On 2021/1/7 上午1:14, Jan Kara wrote: On Thu 31-12-20 00:55:59, Shiyang Ruan wrote: With the support of ->rmap(), it is possible to obtain the superblock on a mapped device. If a pmem device is used as one target of mapped device, we cannot obtain its superblock directly. With the help of

Re: [PATCH v2 3/5] mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions

2021-01-12 Thread Oscar Salvador
On Tue, Jan 12, 2021 at 01:34:53AM -0800, Dan Williams wrote: > While pfn_to_online_page() is able to determine pfn_valid() at > subsection granularity it is not able to reliably determine if a given > pfn is also online if the section is mixes ZONE_{NORMAL,MOVABLE} with > ZONE_DEVICE. This means

Re: [PATCH v2 2/5] mm: Teach pfn_to_online_page() to consider subsection validity

2021-01-12 Thread Oscar Salvador
On Tue, Jan 12, 2021 at 10:53:17AM +0100, David Hildenbrand wrote: > That's not sufficient for alternative implementations of pfn_valid(). > > You still need some kind of pfn_valid(pfn) for alternative versions of > pfn_valid(). Consider arm64 memory holes in the memmap. See their > current (yet

Re: [PATCH v2 1/5] mm: Move pfn_to_online_page() out of line

2021-01-12 Thread Oscar Salvador
On Tue, Jan 12, 2021 at 01:34:42AM -0800, Dan Williams wrote: > pfn_to_online_page() is already too large to be a macro or an inline > function. In anticipation of further logic changes / growth, move it out > of line. > > No functional change, just code movement. > > Cc: David Hildenbrand >

Re: [PATCH v2 4/5] mm: Fix page reference leak in soft_offline_page()

2021-01-12 Thread David Hildenbrand
On 12.01.21 10:34, Dan Williams wrote: > The conversion to move pfn_to_online_page() internal to > soft_offline_page() missed that the get_user_pages() reference needs to > be dropped when pfn_to_online_page() fails. > > When soft_offline_page() is handed a pfn_valid() && > !pfn_to_online_page()

Re: [PATCH v2 3/5] mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions

2021-01-12 Thread David Hildenbrand
On 12.01.21 10:34, Dan Williams wrote: > While pfn_to_online_page() is able to determine pfn_valid() at > subsection granularity it is not able to reliably determine if a given > pfn is also online if the section is mixes ZONE_{NORMAL,MOVABLE} with > ZONE_DEVICE. This means that

Re: [PATCH v2 4/5] mm: Fix page reference leak in soft_offline_page()

2021-01-12 Thread Oscar Salvador
On Tue, Jan 12, 2021 at 01:34:58AM -0800, Dan Williams wrote: > The conversion to move pfn_to_online_page() internal to > soft_offline_page() missed that the get_user_pages() reference needs to > be dropped when pfn_to_online_page() fails. I would be more specific here wrt. get_user_pages

Re: [PATCH v2 2/5] mm: Teach pfn_to_online_page() to consider subsection validity

2021-01-12 Thread David Hildenbrand
On 12.01.21 10:34, Dan Williams wrote: > pfn_section_valid() determines pfn validity on subsection granularity. > > pfn_valid_within() internally uses pfn_section_valid(), but gates it > with early_section() to preserve the traditional behavior of pfn_valid() > before subsection support was

Re: [PATCH v2 1/5] mm: Move pfn_to_online_page() out of line

2021-01-12 Thread David Hildenbrand
On 12.01.21 10:34, Dan Williams wrote: > pfn_to_online_page() is already too large to be a macro or an inline > function. In anticipation of further logic changes / growth, move it out > of line. > > No functional change, just code movement. > > Cc: David Hildenbrand > Reported-by: Michal Hocko

[PATCH v2 5/5] libnvdimm/namespace: Fix visibility of namespace resource attribute

2021-01-12 Thread Dan Williams
Legacy pmem namespaces lost support for the "resource" attribute when the code was cleaned up to put the permission visibility in the declaration. Restore this by listing 'resource' in the default attributes. A new ndctl regression test for pfn_to_online_page() corner cases builds on this fix.

[PATCH v2 4/5] mm: Fix page reference leak in soft_offline_page()

2021-01-12 Thread Dan Williams
The conversion to move pfn_to_online_page() internal to soft_offline_page() missed that the get_user_pages() reference needs to be dropped when pfn_to_online_page() fails. When soft_offline_page() is handed a pfn_valid() && !pfn_to_online_page() pfn the kernel hangs at dax-device shutdown due to

[PATCH v2 3/5] mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions

2021-01-12 Thread Dan Williams
While pfn_to_online_page() is able to determine pfn_valid() at subsection granularity it is not able to reliably determine if a given pfn is also online if the section is mixes ZONE_{NORMAL,MOVABLE} with ZONE_DEVICE. This means that pfn_to_online_page() may return invalid @page objects. For

[PATCH v2 2/5] mm: Teach pfn_to_online_page() to consider subsection validity

2021-01-12 Thread Dan Williams
pfn_section_valid() determines pfn validity on subsection granularity. pfn_valid_within() internally uses pfn_section_valid(), but gates it with early_section() to preserve the traditional behavior of pfn_valid() before subsection support was added. pfn_to_online_page() wants the explicit

[PATCH v2 1/5] mm: Move pfn_to_online_page() out of line

2021-01-12 Thread Dan Williams
pfn_to_online_page() is already too large to be a macro or an inline function. In anticipation of further logic changes / growth, move it out of line. No functional change, just code movement. Cc: David Hildenbrand Reported-by: Michal Hocko Signed-off-by: Dan Williams ---

[PATCH v2 0/5] mm: Fix pfn_to_online_page() with respect to ZONE_DEVICE

2021-01-12 Thread Dan Williams
Changes since v1 [1]: - Clarify the failing condition in patch 3 (Michal) - Clarify how subsection collisions manifest in shipping systems (Michal) - Use zone_idx() (Michal) - Move section_taint_zone_device() conditions to move_pfn_range_to_zone() (Michal) - Fix pfn_to_online_page() to account