Re: [RFC PATCH v2 1/3] mm: Don't pin ZERO_PAGE in pin_user_pages()

From: David Hildenbrand
Date: Fri May 26 2023 - 05:25:27 EST

On 26.05.23 11:15, David Howells wrote:
Lorenzo Stoakes <lstoakes@xxxxxxxxx> wrote:

iov_iter_extract_pages(), on the other hand, is only used in two places
with these patches and the pins are always released with
unpin_user_page*() so it's a lot easier to audit.

Thanks for the clarification. I guess these are the cases where you're
likely to see zero page usage, but since this is changing all PUP*() callers
don't you need to audit all of those too?

I don't think it should be necessary. This only affects pages obtained from
gup with FOLL_PIN - and, so far as I know, those always have to be released
with unpin_user_page*() which is part of the gup API and thus it should be
transparent to the users.

Right, and even code like like 873aefb376bb ("vfio/type1: Unpin zero pages") would handle it transparently, because they also call unpin_user_page().

[we can remove 873aefb376bb even without this change way because it uses FOLL_LONGTERM that shouldn't return the shared zeropage anymore ]


David / dhildenb