Commit 7ae12c80 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

fs: inode: count invalidated shadow pages in pginodesteal

pginodesteal is supposed to capture the impact that inode reclaim has on
the page cache state.  Currently, it doesn't consider shadow pages that
get dropped this way, even though this can have a significant impact on
paging behavior, memory pressure calculations etc.

To improve visibility into these effects, make sure shadow pages get
counted when they get dropped through inode reclaim.

This changes the return value semantics of invalidate_mapping_pages()
semantics slightly, but the only two users are the inode shrinker itsel
and a usb driver that logs it for debugging purposes.

Link: https://lkml.kernel.org/r/20210614211904.14420-3-hannes@cmpxchg.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 16e2df2a
...@@ -768,7 +768,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item, ...@@ -768,7 +768,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
return LRU_ROTATE; return LRU_ROTATE;
} }
if (inode_has_buffers(inode) || inode->i_data.nrpages) { if (inode_has_buffers(inode) || !mapping_empty(&inode->i_data)) {
__iget(inode); __iget(inode);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
spin_unlock(lru_lock); spin_unlock(lru_lock);
......
...@@ -483,7 +483,8 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping, ...@@ -483,7 +483,8 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
index = indices[i]; index = indices[i];
if (xa_is_value(page)) { if (xa_is_value(page)) {
invalidate_exceptional_entry(mapping, index, count += invalidate_exceptional_entry(mapping,
index,
page); page);
continue; continue;
} }
...@@ -512,19 +513,18 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping, ...@@ -512,19 +513,18 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
} }
/** /**
* invalidate_mapping_pages - Invalidate all the unlocked pages of one inode * invalidate_mapping_pages - Invalidate all clean, unlocked cache of one inode
* @mapping: the address_space which holds the pages to invalidate * @mapping: the address_space which holds the cache to invalidate
* @start: the offset 'from' which to invalidate * @start: the offset 'from' which to invalidate
* @end: the offset 'to' which to invalidate (inclusive) * @end: the offset 'to' which to invalidate (inclusive)
* *
* This function only removes the unlocked pages, if you want to * This function removes pages that are clean, unmapped and unlocked,
* remove all the pages of one inode, you must call truncate_inode_pages. * as well as shadow entries. It will not block on IO activity.
* *
* invalidate_mapping_pages() will not block on IO activity. It will not * If you want to remove all the pages of one inode, regardless of
* invalidate pages which are dirty, locked, under writeback or mapped into * their use and writeback state, use truncate_inode_pages().
* pagetables.
* *
* Return: the number of the pages that were invalidated * Return: the number of the cache entries that were invalidated
*/ */
unsigned long invalidate_mapping_pages(struct address_space *mapping, unsigned long invalidate_mapping_pages(struct address_space *mapping,
pgoff_t start, pgoff_t end) pgoff_t start, pgoff_t end)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment