remarkable-linux/drivers/nvdimm
Dave Jiang b3b454f694 libnvdimm: fix clear poison locking with spinlock and GFP_NOWAIT allocation
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 kernel/locking/mutex.
c:747
in_atomic(): 1, irqs_disabled(): 0, pid: 17159, name: dd
[..]
Call Trace:
dump_stack+0x85/0xc8
___might_sleep+0x184/0x250
__might_sleep+0x4a/0x90
__mutex_lock+0x58/0x9b0
? 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
mutex_lock_nested+0x1b/0x20
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
generic_make_request+0x118/0x3b0

A spinlock is introduced to protect the poison list. This allows us to not
having to acquire the reconfig_mutex for touching the poison list. The
add_poison() function has been broken out into two helper functions. One to
allocate the poison entry and the other to apppend the entry. This allows us
to unlock the poison_lock in non-I/O path and continue to be able to allocate
the poison entry with GFP_KERNEL. We will use GFP_NOWAIT in the I/O path in
order to satisfy being in atomic context.

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2017-04-13 14:23:51 -07:00
..
blk.c libnvdimm for 4.8 2016-07-28 17:38:16 -07:00
btt.c nvdimm, btt: add a size attribute for BTTs 2016-08-08 09:26:14 -07:00
btt.h
btt_devs.c nvdimm, btt: add a size attribute for BTTs 2016-08-08 09:26:14 -07:00
bus.c libnvdimm: fix clear poison locking with spinlock and GFP_NOWAIT allocation 2017-04-13 14:23:51 -07:00
claim.c libnvdimm: band aid btt vs clear poison locking 2017-04-10 17:21:45 -07:00
core.c libnvdimm: fix clear poison locking with spinlock and GFP_NOWAIT allocation 2017-04-13 14:23:51 -07:00
dax_devs.c libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
dimm.c libnvdimm: allow a platform to force enable label support 2016-10-19 08:57:33 -07:00
dimm_devs.c libnvdimm: fix blk free space accounting 2017-04-04 15:08:36 -07:00
e820.c libnvdimm, e820: use module_platform_driver 2016-12-05 08:52:21 -08:00
Kconfig Linux 4.9-rc4 2016-11-18 16:13:41 -07:00
label.c nvdimm: use the right length of "pmem" 2016-11-11 20:37:42 -08:00
label.h
Makefile libnvdimm, dax: introduce device-dax infrastructure 2016-05-09 15:35:42 -07:00
namespace_devs.c nfit, libnvdimm: fix interleave set cookie calculation 2017-03-01 00:49:42 -08:00
nd-core.h libnvdimm: fix clear poison locking with spinlock and GFP_NOWAIT allocation 2017-04-13 14:23:51 -07:00
nd.h libnvdimm: add mechanism to publish badblocks at the region level 2017-04-12 21:56:42 -07:00
pfn.h libnvdimm, dax: autodetect support 2016-05-20 22:02:57 -07:00
pfn_devs.c libnvdimm, pfn: fix memmap reservation size versus 4K alignment 2017-02-04 14:47:31 -08:00
pmem.c pmem: return EIO on read_pmem() failure 2017-01-12 16:40:29 -08:00
pmem.h pmem: kill __pmem address space 2016-07-12 19:25:38 -07:00
region.c libnvdimm: add support for clear poison list and badblocks for device dax 2017-04-12 21:56:43 -07:00
region_devs.c libnvdimm: Add 'resource' sysfs attribute to regions 2017-04-12 21:56:42 -07:00