Re: [PATCH 1/1] mm: page_cache_add_speculative(): refactor out some code duplication

From: Andrew Morton
Date: Fri Feb 08 2019 - 00:49:23 EST


On Wed, 6 Feb 2019 15:10:16 -0800 john.hubbard@xxxxxxxxx wrote:

> From: John Hubbard <jhubbard@xxxxxxxxxx>
>
> This combines the common elements of these routines:
>
> page_cache_get_speculative()
> page_cache_add_speculative()
>
> This was anticipated by the original author, as shown by the comment
> in commit ce0ad7f095258 ("powerpc/mm: Lockless get_user_pages_fast()
> for 64-bit (v3)"):
>
> "Same as above, but add instead of inc (could just be merged)"
>
> There is no intention to introduce any behavioral change, but there is a
> small risk of that, due to slightly differing ways of expressing the
> TINY_RCU and related configurations.
>
> This also removes the VM_BUG_ON(in_interrupt()) that was in
> page_cache_add_speculative(), but not in page_cache_get_speculative(). This
> provides slightly less detection of such bugs, but it given that it was
> only there on the "add" path anyway, we can likely do without it just fine.

It removes the
VM_BUG_ON_PAGE(PageCompound(page) && page != compound_head(page), page);
also.

We'll live ;)