Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: remove del_page_from_lru, add page_off_lru

del_page_from_lru() repeats del_page_from_lru_list(), also working out
which LRU the page was on, clearing the relevant bits. Decouple those
functions: remove del_page_from_lru() and add page_off_lru().

Signed-off-by: Hugh Dickins <hughd@google.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
1c1c53d4 4111304d

+11 -8
+9 -6
include/linux/mm_inline.h
··· 54 54 return LRU_INACTIVE_ANON; 55 55 } 56 56 57 - static inline void 58 - del_page_from_lru(struct zone *zone, struct page *page) 57 + /** 58 + * page_off_lru - which LRU list was page on? clearing its lru flags. 59 + * @page: the page to test 60 + * 61 + * Returns the LRU list a page was on, as an index into the array of LRU 62 + * lists; and clears its Unevictable or Active flags, ready for freeing. 63 + */ 64 + static inline enum lru_list page_off_lru(struct page *page) 59 65 { 60 66 enum lru_list lru; 61 67 ··· 75 69 lru += LRU_ACTIVE; 76 70 } 77 71 } 78 - mem_cgroup_lru_del_list(page, lru); 79 - list_del(&page->lru); 80 - __mod_zone_page_state(zone, NR_LRU_BASE + lru, -hpage_nr_pages(page)); 72 + return lru; 81 73 } 82 74 83 75 /** ··· 96 92 if (PageActive(page)) 97 93 lru += LRU_ACTIVE; 98 94 } 99 - 100 95 return lru; 101 96 } 102 97
+2 -2
mm/swap.c
··· 53 53 spin_lock_irqsave(&zone->lru_lock, flags); 54 54 VM_BUG_ON(!PageLRU(page)); 55 55 __ClearPageLRU(page); 56 - del_page_from_lru(zone, page); 56 + del_page_from_lru_list(zone, page, page_off_lru(page)); 57 57 spin_unlock_irqrestore(&zone->lru_lock, flags); 58 58 } 59 59 } ··· 617 617 } 618 618 VM_BUG_ON(!PageLRU(page)); 619 619 __ClearPageLRU(page); 620 - del_page_from_lru(zone, page); 620 + del_page_from_lru_list(zone, page, page_off_lru(page)); 621 621 } 622 622 623 623 list_add(&page->lru, &pages_to_free);