linux-stable/drivers/nvdimm
Tomas Glozar b27751fb1f nd_btt: Make BTT lanes preemptible
[ Upstream commit 36c75ce3bd ]

nd_region_acquire_lane uses get_cpu, which disables preemption. This is
an issue on PREEMPT_RT kernels, since btt_write_pg and also
nd_region_acquire_lane itself take a spin lock, resulting in BUG:
sleeping function called from invalid context.

Fix the issue by replacing get_cpu with smp_process_id and
migrate_disable when needed. This makes BTT operations preemptible, thus
permitting the use of spin_lock.

BUG example occurring when running ndctl tests on PREEMPT_RT kernel:

BUG: sleeping function called from invalid context at
kernel/locking/spinlock_rt.c:48
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 4903, name:
libndctl
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:
[<ffffffffc1313db5>] nd_region_acquire_lane+0x15/0x90 [libnvdimm]
Call Trace:
 <TASK>
 dump_stack_lvl+0x8e/0xb0
 __might_resched+0x19b/0x250
 rt_spin_lock+0x4c/0x100
 ? btt_write_pg+0x2d7/0x500 [nd_btt]
 btt_write_pg+0x2d7/0x500 [nd_btt]
 ? local_clock_noinstr+0x9/0xc0
 btt_submit_bio+0x16d/0x270 [nd_btt]
 __submit_bio+0x48/0x80
 __submit_bio_noacct+0x7e/0x1e0
 submit_bio_wait+0x58/0xb0
 __blkdev_direct_IO_simple+0x107/0x240
 ? inode_set_ctime_current+0x51/0x110
 ? __pfx_submit_bio_wait_endio+0x10/0x10
 blkdev_write_iter+0x1d8/0x290
 vfs_write+0x237/0x330
 ...
 </TASK>

Fixes: 5212e11fde ("nd_btt: atomic sector updates")
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:57:08 +01:00
..
Kconfig nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE 2023-01-28 15:32:36 -08:00
Makefile
badrange.c
btt.c block: remove ->rw_page 2023-02-02 22:33:34 -08:00
btt.h
btt_devs.c
bus.c nvdimm: make nd_class variable static 2023-06-23 14:55:58 -06:00
claim.c
core.c
dax_devs.c driver core: make struct bus_type.uevent() take a const * 2023-01-27 13:45:52 +01:00
dimm.c
dimm_devs.c nvdimm: make security_show static 2023-06-23 15:08:24 -06:00
e820.c
label.c
label.h
namespace_devs.c
nd-core.h cxl for v6.3 2023-02-25 09:19:23 -08:00
nd.h Driver core changes for 6.3-rc1 2023-02-24 12:58:55 -08:00
nd_perf.c nvdimm: Fix dereference after free in register_nvdimm_pmu() 2023-09-13 09:53:31 +02:00
nd_virtio.c virtio_pmem: add the missing REQ_OP_WRITE for flush bio 2023-09-13 09:53:50 +02:00
of_pmem.c libnvdimm/of_pmem: Use devm_kstrdup instead of kstrdup and check its return value 2023-11-20 11:57:08 +01:00
pfn.h
pfn_devs.c nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE 2023-01-28 15:32:36 -08:00
pmem.c dax: enable dax fault handler to report VM_FAULT_HWPOISON 2023-06-26 07:54:23 -06:00
pmem.h
region.c nvdimm/region: Move cache management to the region driver 2022-12-02 23:52:32 -08:00
region_devs.c nd_btt: Make BTT lanes preemptible 2023-11-20 11:57:08 +01:00
security.c nvdimm/region: Move cache management to the region driver 2022-12-02 23:52:32 -08:00
virtio_pmem.c virtio_pmem: populate numa information 2023-02-15 06:46:22 -05:00
virtio_pmem.h