[lkml]   [2017]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[GIT PULL] libnvdimm fixes for 4.11-rc7
Hi Linus, please pull from:

git:// libnvdimm-fixes receive:

A small crop of lockdep, sleeping while atomic, and other fixes /
band-aids in advance of the full-blown reworks targeting the next
merge window. The largest change here is "libnvdimm: fix blk free
space accounting" which deletes a pile of buggy code that better
testing would have caught before merging. The next change that is
borderline too big for a late rc is switching the device-dax locking
from rcu to srcu, I couldn't think of a smaller way to make that fix.

The __copy_user_nocache fix will have a full replacement in 4.12 to
move those pmem special case considerations into the pmem driver. The
"libnvdimm: band aid btt vs clear poison locking" commit admits that
our error clearing support for btt went in broken, so we just disable
it in 4.11 and -stable. A replacement / full fix is in the pipeline
for 4.12

Some of these would have been caught earlier had
CONFIG_DEBUG_ATOMIC_SLEEP been enabled on my development station. I
wonder if we should have:


...since I mistakenly thought I got both with CONFIG_PROVE_LOCKING=y.

These have received a build success notification from the 0day robot,
and some have appeared in a -next release with no reported issues.


The following changes since commit c02ed2e75ef4c74e41e421acb4ef1494671585e8:

Linux 4.11-rc4 (2017-03-26 14:15:16 -0700)

are available in the git repository at:

git:// libnvdimm-fixes

for you to fetch changes up to 11e63f6d920d6f2dfd3cd421e939a4aec9a58dcd:

x86, pmem: fix broken __copy_user_nocache cache-bypass assumptions
(2017-04-12 13:45:18 -0700)

Dan Williams (6):
acpi, nfit, libnvdimm: fix interleave set cookie calculation
(64-bit comparison)
libnvdimm: fix blk free space accounting
libnvdimm: fix reconfig_mutex, mmap_sem, and jbd2_handle lockdep splat
libnvdimm: band aid btt vs clear poison locking
device-dax: switch to srcu, fix rcu_read_lock() vs pte allocation
x86, pmem: fix broken __copy_user_nocache cache-bypass assumptions

arch/x86/include/asm/pmem.h | 42 ++++++++++++++++++-------
drivers/acpi/nfit/core.c | 6 +++-
drivers/dax/Kconfig | 1 +
drivers/dax/dax.c | 13 ++++----
drivers/nvdimm/bus.c | 6 ++++
drivers/nvdimm/claim.c | 10 +++++-
drivers/nvdimm/dimm_devs.c | 77 +++++++--------------------------------------
7 files changed, 70 insertions(+), 85 deletions(-)

commit b03b99a329a14b7302f37c3ea6da3848db41c8c5
Author: Dan Williams <>
Date: Mon Mar 27 21:53:38 2017 -0700

acpi, nfit, libnvdimm: fix interleave set cookie calculation
(64-bit comparison)

While reviewing the -stable patch for commit 86ef58a4e35e "nfit,
libnvdimm: fix interleave set cookie calculation" Ben noted:

"This is returning an int, thus it's effectively doing a 32-bit
comparison and not the 64-bit comparison you say is needed."

Update the compare operation to be immune to this integer demotion problem.

Cc: <>
Cc: Nicholas Moulin <>
Fixes: 86ef58a4e35e ("nfit, libnvdimm: fix interleave set cookie
Reported-by: Ben Hutchings <>
Signed-off-by: Dan Williams <>

commit fe514739d8538783749d3ce72f78e5a999ea5668
Author: Dan Williams <>
Date: Tue Apr 4 15:08:36 2017 -0700

libnvdimm: fix blk free space accounting

Commit a1f3e4d6a0c3 "libnvdimm, region: update nd_region_available_dpa()
for multi-pmem support" reworked blk dpa (DIMM Physical Address)
accounting to comprehend multiple pmem namespace allocations aliasing
with a given blk-dpa range.

The following call trace is a result of failing to account for allocated
blk capacity.

WARNING: CPU: 1 PID: 2433 at
4 size_store+0x6f3/0x930 [libnvdimm]
nd_region region5: allocation underrun: 0x0 of 0x1000000 bytes
Call Trace:
size_store+0x6f3/0x930 [libnvdimm]

If a given blk-dpa allocation does not alias with any pmem ranges then
the full allocation should be accounted as busy space, not the size of
the current pmem contribution to the region.

The thinkos that led to this confusion was not realizing that the struct
resource management is already guaranteeing no collisions between pmem
allocations and blk allocations on the same dimm. Also, we do not try to
support blk allocations in aliased pmem holes.

This patch also fixes a case where the available blk goes negative.

Cc: <>
Fixes: a1f3e4d6a0c3 ("libnvdimm, region: update
nd_region_available_dpa() for multi-pmem support").
Reported-by: Dariusz Dokupil <>
Reported-by: Dave Jiang <>
Reported-by: Vishal Verma <>
Tested-by: Dave Jiang <>
Tested-by: Vishal Verma <>
Signed-off-by: Dan Williams <>

commit 0beb2012a1722633515c8aaa263c73449636c893
Author: Dan Williams <>
Date: Fri Apr 7 09:47:24 2017 -0700

libnvdimm: fix reconfig_mutex, mmap_sem, and jbd2_handle lockdep splat

Holding the reconfig_mutex over a potential userspace fault sets up a
lockdep dependency chain between filesystem-DAX and the libnvdimm ioctl
path. Move the user access outside of the lock.

[ INFO: possible circular locking dependency detected ]
4.11.0-rc3+ #13 Tainted: G W O
fallocate/16656 is trying to acquire lock:
(&nvdimm_bus->reconfig_mutex){+.+.+.}, at:
[<ffffffffa00080b1>] nvdimm_bus_lock+0x21/0x30 [libnvdimm]
but task is already holding lock:
(jbd2_handle){++++..}, at: [<ffffffff813b4944>]

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #2 (jbd2_handle){++++..}:

-> #1 (&mm->mmap_sem){++++++}:
__nd_ioctl+0x683/0x720 [libnvdimm]
nvdimm_ioctl+0x8b/0xe0 [libnvdimm]

-> #0 (&nvdimm_bus->reconfig_mutex){+.+.+.}:
nvdimm_bus_lock+0x21/0x30 [libnvdimm]
nvdimm_forget_poison+0x25/0x50 [libnvdimm]
nvdimm_clear_poison+0x106/0x140 [libnvdimm]
pmem_do_bvec+0x1c2/0x2b0 [nd_pmem]
pmem_make_request+0xf9/0x270 [nd_pmem]

Cc: <>
Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for
nvdimm_bus and nvdimm devices")
Cc: Dave Jiang <>
Reported-by: Vishal Verma <>
Signed-off-by: Dan Williams <>

commit 4aa5615e080a9855e607accc75b07ab79b252dde
Author: Dan Williams <>
Date: Fri Apr 7 12:25:52 2017 -0700

libnvdimm: band aid btt vs clear poison locking

The following warning results from holding a lane spinlock,
preempt_disable(), or the btt map spinlock and then trying to take the
reconfig_mutex to walk the poison list and potentially add new entries.

BUG: sleeping function called from invalid context at
in_atomic(): 1, irqs_disabled(): 0, pid: 17159, name: dd
Call Trace:
? nvdimm_bus_lock+0x21/0x30 [libnvdimm]
? __nvdimm_bus_badblocks_clear+0x2f/0x60 [libnvdimm]
? acpi_nfit_forget_poison+0x79/0x80 [nfit]
? _raw_spin_unlock+0x27/0x40
nvdimm_bus_lock+0x21/0x30 [libnvdimm]
nvdimm_forget_poison+0x25/0x50 [libnvdimm]
nvdimm_clear_poison+0x106/0x140 [libnvdimm]
nsio_rw_bytes+0x164/0x270 [libnvdimm]
btt_write_pg+0x1de/0x3e0 [nd_btt]
? blk_queue_enter+0x30/0x290
btt_make_request+0x11a/0x310 [nd_btt]
? blk_queue_enter+0xb7/0x290
? blk_queue_enter+0x30/0x290

As a minimal fix, disable error clearing when the BTT is enabled for the
namespace. For the final fix a larger rework of the poison list locking
is needed.

Note that this is not a problem in the blk case since that path never
calls nvdimm_clear_poison().

Cc: <>
Fixes: 82bf1037f2ca ("libnvdimm: check and clear poison before
writing to pmem")
Cc: Dave Jiang <>
[jeff: dynamically disable error clearing in the btt case]
Suggested-by: Jeff Moyer <>
Reviewed-by: Jeff Moyer <>
Reported-by: Vishal Verma <>
Signed-off-by: Dan Williams <>

commit 956a4cd2c957acf638ff29951aabaa9d8e92bbc2
Author: Dan Williams <>
Date: Fri Apr 7 16:42:08 2017 -0700

device-dax: switch to srcu, fix rcu_read_lock() vs pte allocation

The following warning triggers with a new unit test that stresses the
device-dax interface.

[ ERR: suspicious RCU usage. ]
4.11.0-rc4+ #1049 Tainted: G O
./include/linux/rcupdate.h:521 Illegal context switch in RCU
read-side critical section!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 0
2 locks held by fio/9070:
#0: (&mm->mmap_sem){++++++}, at: [<ffffffff8d0739d7>]
#1: (rcu_read_lock){......}, at: [<ffffffffc03fbd02>]
dax_dev_huge_fault+0x32/0x620 [dax]

Call Trace:
? lookup_memtype+0xa6/0xd0
dax_dev_huge_fault+0x520/0x620 [dax]
? dax_dev_huge_fault+0x32/0x620 [dax]
dax_dev_fault+0x10/0x20 [dax]
? handle_mm_fault+0x47/0x370

Inserting a page table entry may trigger an allocation while we are
holding a read lock to keep the device instance alive for the duration
of the fault. Use srcu for this keep-alive protection.

Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap")
Cc: <>
Signed-off-by: Dan Williams <>

commit 11e63f6d920d6f2dfd3cd421e939a4aec9a58dcd
Author: Dan Williams <>
Date: Thu Apr 6 09:04:31 2017 -0700

x86, pmem: fix broken __copy_user_nocache cache-bypass assumptions

Before we rework the "pmem api" to stop abusing __copy_user_nocache()
for memcpy_to_pmem() we need to fix cases where we may strand dirty data
in the cpu cache. The problem occurs when copy_from_iter_pmem() is used
for arbitrary data transfers from userspace. There is no guarantee that
these transfers, performed by dax_iomap_actor(), will have aligned
destinations or aligned transfer lengths. Backstop the usage
__copy_user_nocache() with explicit cache management in these unaligned

Yes, copy_from_iter_pmem() is now too big for an inline, but addressing
that is saved for a later patch that moves the entirety of the "pmem
api" into the pmem driver directly.

Fixes: 5de490daec8b ("pmem: add copy_from_iter_pmem() and clear_pmem()")
Cc: <>
Cc: <>
Cc: Jan Kara <>
Cc: Jeff Moyer <>
Cc: Ingo Molnar <>
Cc: Christoph Hellwig <>
Cc: "H. Peter Anvin" <>
Cc: Al Viro <>
Cc: Thomas Gleixner <>
Cc: Matthew Wilcox <>
Reviewed-by: Ross Zwisler <>
Signed-off-by: Toshi Kani <>
Signed-off-by: Dan Williams <>

 \ /
  Last update: 2017-04-15 19:13    [W:0.024 / U:21.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site