* [davidhildenbrand:device_private 17/22] mm/rmap.c:2461:9: error: 'ret' undeclared; did you mean 'net'?
@ 2025-02-08 20:54 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-02-08 20:54 UTC (permalink / raw)
To: David Hildenbrand; +Cc: oe-kbuild-all
tree: https://github.com/davidhildenbrand/linux device_private
head: ddc42f5fd72394838fc2d280ff2486ccb7178b9a
commit: 9c7678e94573361a0a89e3e79bf8311006d6b55d [17/22] mm/rmap: avoid -EBUSY from make_device_exclusive()
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20250209/202502090401.fJTxeZim-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250209/202502090401.fJTxeZim-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502090401.fJTxeZim-lkp@intel.com/
All errors (new ones prefixed by >>):
mm/rmap.c: In function 'make_device_exclusive':
>> mm/rmap.c:2461:9: error: 'ret' undeclared (first use in this function); did you mean 'net'?
2461 | ret = folio_lock_killable(folio);
| ^~~
| net
mm/rmap.c:2461:9: note: each undeclared identifier is reported only once for each function it appears in
vim +2461 mm/rmap.c
2385
2386 #ifdef CONFIG_DEVICE_PRIVATE
2387 /**
2388 * make_device_exclusive() - Mark a page for exclusive use by a device
2389 * @mm: mm_struct of associated target process
2390 * @addr: the virtual address to mark for exclusive device access
2391 * @owner: passed to MMU_NOTIFY_EXCLUSIVE range notifier to allow filtering
2392 * @foliop: folio pointer will be stored here on success.
2393 *
2394 * This function looks up the page mapped at the given address, grabs a
2395 * folio reference, locks the folio and replaces the PTE with special
2396 * device-exclusive PFN swap entry, preventing access through the process
2397 * page tables. The function will return with the folio locked and referenced.
2398 *
2399 * On fault, the device-exclusive entries are replaced with the original PTE
2400 * under folio lock, after calling MMU notifiers.
2401 *
2402 * Only anonymous non-hugetlb folios are supported and the VMA must have
2403 * write permissions such that we can fault in the anonymous page writable
2404 * in order to mark it exclusive. The caller must hold the mmap_lock in read
2405 * mode.
2406 *
2407 * A driver using this to program access from a device must use a mmu notifier
2408 * critical section to hold a device specific lock during programming. Once
2409 * programming is complete it should drop the folio lock and reference after
2410 * which point CPU access to the page will revoke the exclusive access.
2411 *
2412 * Notes:
2413 * #. This function always operates on individual PTEs mapping individual
2414 * pages. PMD-sized THPs are first remapped to be mapped by PTEs before
2415 * the conversion happens on a single PTE corresponding to @addr.
2416 * #. While concurrent access through the process page tables is prevented,
2417 * concurrent access through other page references (e.g., earlier GUP
2418 * invocation) is not handled and not supported.
2419 * #. device-exclusive entries are considered "clean" and "old" by core-mm.
2420 * Device drivers must update the folio state when informed by MMU
2421 * notifiers.
2422 *
2423 * Returns: pointer to mapped page on success, otherwise a negative error.
2424 */
2425 struct page *make_device_exclusive(struct mm_struct *mm, unsigned long addr,
2426 void *owner, struct folio **foliop)
2427 {
2428 struct mmu_notifier_range range;
2429 struct folio *folio, *fw_folio;
2430 struct vm_area_struct *vma;
2431 struct folio_walk fw;
2432 struct page *page;
2433 swp_entry_t entry;
2434 pte_t swp_pte;
2435
2436 mmap_assert_locked(mm);
2437 addr = PAGE_ALIGN_DOWN(addr);
2438
2439 /*
2440 * Fault in the page writable and try to lock it; note that if the
2441 * address would already be marked for exclusive use by a device,
2442 * the GUP call would undo that first by triggering a fault.
2443 *
2444 * If any other device would already map this page exclusively, the
2445 * fault will trigger a conversion to an ordinary
2446 * (non-device-exclusive) PTE and issue a MMU_NOTIFY_EXCLUSIVE.
2447 */
2448 retry:
2449 page = get_user_page_vma_remote(mm, addr,
2450 FOLL_GET | FOLL_WRITE | FOLL_SPLIT_PMD,
2451 &vma);
2452 if (IS_ERR(page))
2453 return page;
2454 folio = page_folio(page);
2455
2456 if (!folio_test_anon(folio) || folio_test_hugetlb(folio)) {
2457 folio_put(folio);
2458 return ERR_PTR(-EOPNOTSUPP);
2459 }
2460
> 2461 ret = folio_lock_killable(folio);
2462 if (ret) {
2463 folio_put(folio);
2464 return ERR_PTR(ret);
2465 }
2466
2467 /*
2468 * Inform secondary MMUs that we are going to convert this PTE to
2469 * device-exclusive, such that they unmap it now. Note that the
2470 * caller must filter this event out to prevent livelocks.
2471 */
2472 mmu_notifier_range_init_owner(&range, MMU_NOTIFY_EXCLUSIVE, 0,
2473 mm, addr, addr + PAGE_SIZE, owner);
2474 mmu_notifier_invalidate_range_start(&range);
2475
2476 /*
2477 * Let's do a second walk and make sure we still find the same page
2478 * mapped writable. Note that a page of an anonymous folio can
2479 * only be mapped writable using exactly one page table mapping
2480 * ("exclusive"), so there cannot be other mappings.
2481 */
2482 fw_folio = folio_walk_start(&fw, vma, addr, 0);
2483 if (fw_folio != folio || fw.page != page ||
2484 fw.level != FW_LEVEL_PTE || !pte_write(fw.pte)) {
2485 if (fw_folio)
2486 folio_walk_end(&fw, vma);
2487 mmu_notifier_invalidate_range_end(&range);
2488 folio_unlock(folio);
2489 folio_put(folio);
2490 goto retry;
2491 }
2492
2493 /* Nuke the page table entry so we get the uptodate dirty bit. */
2494 flush_cache_page(vma, addr, page_to_pfn(page));
2495 fw.pte = ptep_clear_flush(vma, addr, fw.ptep);
2496
2497 /* Set the dirty flag on the folio now the PTE is gone. */
2498 if (pte_dirty(fw.pte))
2499 folio_mark_dirty(folio);
2500
2501 /*
2502 * Store the pfn of the page in a special device-exclusive PFN swap PTE.
2503 * do_swap_page() will trigger the conversion back while holding the
2504 * folio lock.
2505 */
2506 entry = make_device_exclusive_entry(page_to_pfn(page));
2507 swp_pte = swp_entry_to_pte(entry);
2508 if (pte_soft_dirty(fw.pte))
2509 swp_pte = pte_swp_mksoft_dirty(swp_pte);
2510 /* The pte is writable, uffd-wp does not apply. */
2511 set_pte_at(mm, addr, fw.ptep, swp_pte);
2512
2513 folio_walk_end(&fw, vma);
2514 mmu_notifier_invalidate_range_end(&range);
2515 *foliop = folio;
2516 return page;
2517 }
2518 EXPORT_SYMBOL_GPL(make_device_exclusive);
2519 #endif
2520
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-02-08 20:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-08 20:54 [davidhildenbrand:device_private 17/22] mm/rmap.c:2461:9: error: 'ret' undeclared; did you mean 'net'? kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.