Re: [PATCH v11 2/8] iov_iter: Add a function to extract a page list from an iterator

From: David Hildenbrand
Date: Thu Jan 26 2023 - 19:11:37 EST


On 27.01.23 00:56, David Howells wrote:
Al says that pinning a page (ie. FOLL_PIN) could cause a deadlock if a page is
vmspliced into a pipe with the pipe holding a pin on it because pinned pages
are removed from all page tables. Is this actually the case? I can't see
offhand where in mm/gup.c it does this.

Pinning a page is mostly taking a "special" reference on the page, indicating to the system that the page maybe pinned. For an ordinary order-0 page, this is increasing the refcount by 1024 instead of 1.

In addition, we'll do some COW-unsharing magic depending on the page type (e.g., anon vs. fike-backed), and FOLL_LONGTERM. So if the page is mapped R/O only and we want to pin it R/O (!FOLL_WRITE), we might replace it in the page table by a different page via a fault (FAULT_FLAG_UNSHARE).

Last but not least, with FOLL_LONGTERM we will make sure to migrate the target page off of MIGRATE_MOVABLE/CMA memory where the unmovable page (while pinned) could otherwise cause trouble (e.g., blocking memory hotunplug). So again, we'd replace it in the page tale by a different page via a fault.

In all cases, the page won't be unmapped from the page table.

--
Thanks,

David / dhildenb