Re: [PATCH v2 1/1] fs/splice: add missing callback for inaccessible pages

From: Dave Hansen
Date: Thu Apr 30 2020 - 18:20:11 EST


One other thing... The gup code will not take references on ref-frozen
pages:

> static inline __must_check bool try_get_page(struct page *page)
> {
> page = compound_head(page);
> if (WARN_ON_ONCE(page_ref_count(page) <= 0))
> return false;
> page_ref_inc(page);
> return true;
> }

*But*, notice that the path that skips taking a ref is also a
WARN_ON_ONCE(). Basically, if you get to try_get_page() on a ref-frozen
page, it's considered buggy. This makes sense because you fundamentally
can't freeze refs on a page that might have more refs taken on it.

I think all the other users do this by ensuring that any PTE that could
be gup'd is set non-present before the refs are frozen and remote TLBs
are flushed which also ensures no GUPs are running. I don't know if the
s390 code has some other way of preventing GUPs, but leaving Present=1
PTEs while you freeze refs would be quite troublesome on x86.