[PATCH 4/4] mm: convert make_page_accessed to use compount_page_t()

From: Kirill A. Shutemov
Date: Sun Mar 27 2016 - 15:47:57 EST


Just for example, convert one function to just created interface.

This way we cut size of the function by third:

function old new delta
mark_page_accessed 310 203 -107

Not-yet-signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
---
mm/swap.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/swap.c b/mm/swap.c
index 09fe5e97714a..1fe072ae6ee1 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -360,9 +360,10 @@ static void __lru_cache_activate_page(struct page *page)
*/
void mark_page_accessed(struct page *page)
{
- page = compound_head(page);
- if (!PageActive(page) && !PageUnevictable(page) &&
- PageReferenced(page)) {
+ struct head_page *head = compound_head_t(page);
+ page = &head->page;
+ if (!PageActive(head) && !PageUnevictable(head) &&
+ PageReferenced(head)) {

/*
* If the page is on the LRU, queue it for activation via
@@ -370,15 +371,15 @@ void mark_page_accessed(struct page *page)
* pagevec, mark it active and it'll be moved to the active
* LRU on the next drain.
*/
- if (PageLRU(page))
+ if (PageLRU(head))
activate_page(page);
else
__lru_cache_activate_page(page);
- ClearPageReferenced(page);
+ ClearPageReferenced(head);
if (page_is_file_cache(page))
workingset_activation(page);
- } else if (!PageReferenced(page)) {
- SetPageReferenced(page);
+ } else if (!PageReferenced(head)) {
+ SetPageReferenced(head);
}
if (page_is_idle(page))
clear_page_idle(page);
--
2.8.0.rc3