Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

Pull libnvdimm fixes from Dan Williams:
"A 4.16 regression fix, three fixes for -stable, and a cleanup fix:

- During the merge window support for the new ACPI NVDIMM Platform
Capabilities structure disabled support for "deep flush", a
force-unit- access like mechanism for persistent memory. Restore
that mechanism.

- VFIO like RDMA is yet one more memory registration / pinning
interface that is incompatible with Filesystem-DAX. Disable long
term pins of Filesystem-DAX mappings via VFIO.

- The Filesystem-DAX detection to prevent long terms pins mistakenly
also disabled Device-DAX pins which are not subject to the same
block- map collision concerns.

- Similar to the setup path, softlockup warnings can trigger in the
shutdown path for large persistent memory namespaces. Teach
for_each_device_pfn() to perform cond_resched() in all cases.

- Boaz noticed that the might_sleep() in dax_direct_access() is stale
as of the v4.15 kernel.

These have received a build success notification from the 0day robot,
and the longterm pin fixes have appeared in -next. However, I recently
rebased the tree to remove some other fixes that need to be reworked
after review feedback.

* 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
memremap: fix softlockup reports at teardown
libnvdimm: re-enable deep flush for pmem devices via fsync()
vfio: disable filesystem-dax page pinning
dax: fix vma_is_fsdax() helper
dax: ->direct_access does not sleep anymore

+27 -17
-6
drivers/dax/super.c
··· 246 246 { 247 247 long avail; 248 248 249 - /* 250 - * The device driver is allowed to sleep, in order to make the 251 - * memory directly accessible. 252 - */ 253 - might_sleep(); 254 - 255 249 if (!dax_dev) 256 250 return -EOPNOTSUPP; 257 251
+1 -2
drivers/nvdimm/pmem.c
··· 335 335 dev_warn(dev, "unable to guarantee persistence of writes\n"); 336 336 fua = 0; 337 337 } 338 - wbc = nvdimm_has_cache(nd_region) && 339 - !test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags); 338 + wbc = nvdimm_has_cache(nd_region); 340 339 341 340 if (!devm_request_mem_region(dev, res->start, resource_size(res), 342 341 dev_name(&ndns->dev))) {
+15 -3
drivers/vfio/vfio_iommu_type1.c
··· 338 338 { 339 339 struct page *page[1]; 340 340 struct vm_area_struct *vma; 341 + struct vm_area_struct *vmas[1]; 341 342 int ret; 342 343 343 344 if (mm == current->mm) { 344 - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), 345 - page); 345 + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), 346 + page, vmas); 346 347 } else { 347 348 unsigned int flags = 0; 348 349 ··· 352 351 353 352 down_read(&mm->mmap_sem); 354 353 ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, 355 - NULL, NULL); 354 + vmas, NULL); 355 + /* 356 + * The lifetime of a vaddr_get_pfn() page pin is 357 + * userspace-controlled. In the fs-dax case this could 358 + * lead to indefinite stalls in filesystem operations. 359 + * Disallow attempts to pin fs-dax pages via this 360 + * interface. 361 + */ 362 + if (ret > 0 && vma_is_fsdax(vmas[0])) { 363 + ret = -EOPNOTSUPP; 364 + put_page(page[0]); 365 + } 356 366 up_read(&mm->mmap_sem); 357 367 } 358 368
+1 -1
include/linux/fs.h
··· 3198 3198 if (!vma_is_dax(vma)) 3199 3199 return false; 3200 3200 inode = file_inode(vma->vm_file); 3201 - if (inode->i_mode == S_IFCHR) 3201 + if (S_ISCHR(inode->i_mode)) 3202 3202 return false; /* device-dax */ 3203 3203 return true; 3204 3204 }
+10 -5
kernel/memremap.c
··· 275 275 return (res->start + resource_size(res)) >> PAGE_SHIFT; 276 276 } 277 277 278 + static unsigned long pfn_next(unsigned long pfn) 279 + { 280 + if (pfn % 1024 == 0) 281 + cond_resched(); 282 + return pfn + 1; 283 + } 284 + 278 285 #define for_each_device_pfn(pfn, map) \ 279 - for (pfn = pfn_first(map); pfn < pfn_end(map); pfn++) 286 + for (pfn = pfn_first(map); pfn < pfn_end(map); pfn = pfn_next(pfn)) 280 287 281 288 static void devm_memremap_pages_release(void *data) 282 289 { ··· 344 337 resource_size_t align_start, align_size, align_end; 345 338 struct vmem_altmap *altmap = pgmap->altmap_valid ? 346 339 &pgmap->altmap : NULL; 340 + struct resource *res = &pgmap->res; 347 341 unsigned long pfn, pgoff, order; 348 342 pgprot_t pgprot = PAGE_KERNEL; 349 - int error, nid, is_ram, i = 0; 350 - struct resource *res = &pgmap->res; 343 + int error, nid, is_ram; 351 344 352 345 align_start = res->start & ~(SECTION_SIZE - 1); 353 346 align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) ··· 416 409 list_del(&page->lru); 417 410 page->pgmap = pgmap; 418 411 percpu_ref_get(pgmap->ref); 419 - if (!(++i % 1024)) 420 - cond_resched(); 421 412 } 422 413 423 414 devm_add_action(dev, devm_memremap_pages_release, pgmap);