mm/filemap: Convert mapping_get_entry to return a folio
The pagecache only contains folios, so indicate that this is definitely not a tail page. Shrinks mapping_get_entry() by 56 bytes, but grows pagecache_get_page() by 21 bytes as gcc makes slightly different hot/cold code decisions. A net reduction of 35 bytes of text. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Howells <dhowells@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz>
This commit is contained in:
parent
9dd3d06940
commit
bca65eeab1
35
mm/filemap.c
35
mm/filemap.c
@ -1810,49 +1810,42 @@ EXPORT_SYMBOL(page_cache_prev_miss);
|
|||||||
* @mapping: the address_space to search
|
* @mapping: the address_space to search
|
||||||
* @index: The page cache index.
|
* @index: The page cache index.
|
||||||
*
|
*
|
||||||
* Looks up the page cache slot at @mapping & @index. If there is a
|
* Looks up the page cache entry at @mapping & @index. If it is a folio,
|
||||||
* page cache page, the head page is returned with an increased refcount.
|
* it is returned with an increased refcount. If it is a shadow entry
|
||||||
|
* of a previously evicted folio, or a swap entry from shmem/tmpfs,
|
||||||
|
* it is returned without further action.
|
||||||
*
|
*
|
||||||
* If the slot holds a shadow entry of a previously evicted page, or a
|
* Return: The folio, swap or shadow entry, %NULL if nothing is found.
|
||||||
* swap entry from shmem/tmpfs, it is returned.
|
|
||||||
*
|
|
||||||
* Return: The head page or shadow entry, %NULL if nothing is found.
|
|
||||||
*/
|
*/
|
||||||
static struct page *mapping_get_entry(struct address_space *mapping,
|
static void *mapping_get_entry(struct address_space *mapping, pgoff_t index)
|
||||||
pgoff_t index)
|
|
||||||
{
|
{
|
||||||
XA_STATE(xas, &mapping->i_pages, index);
|
XA_STATE(xas, &mapping->i_pages, index);
|
||||||
struct page *page;
|
struct folio *folio;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
repeat:
|
repeat:
|
||||||
xas_reset(&xas);
|
xas_reset(&xas);
|
||||||
page = xas_load(&xas);
|
folio = xas_load(&xas);
|
||||||
if (xas_retry(&xas, page))
|
if (xas_retry(&xas, folio))
|
||||||
goto repeat;
|
goto repeat;
|
||||||
/*
|
/*
|
||||||
* A shadow entry of a recently evicted page, or a swap entry from
|
* A shadow entry of a recently evicted page, or a swap entry from
|
||||||
* shmem/tmpfs. Return it without attempting to raise page count.
|
* shmem/tmpfs. Return it without attempting to raise page count.
|
||||||
*/
|
*/
|
||||||
if (!page || xa_is_value(page))
|
if (!folio || xa_is_value(folio))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!page_cache_get_speculative(page))
|
if (!folio_try_get_rcu(folio))
|
||||||
goto repeat;
|
goto repeat;
|
||||||
|
|
||||||
/*
|
if (unlikely(folio != xas_reload(&xas))) {
|
||||||
* Has the page moved or been split?
|
folio_put(folio);
|
||||||
* This is part of the lockless pagecache protocol. See
|
|
||||||
* include/linux/pagemap.h for details.
|
|
||||||
*/
|
|
||||||
if (unlikely(page != xas_reload(&xas))) {
|
|
||||||
put_page(page);
|
|
||||||
goto repeat;
|
goto repeat;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
return page;
|
return folio;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user