| .. | .. |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | #include <linux/huge_mm.h> |
|---|
| 6 | 6 | #include <linux/swap.h> |
|---|
| 7 | +#ifndef __GENKSYMS__ |
|---|
| 8 | +#define PROTECT_TRACE_INCLUDE_PATH |
|---|
| 9 | +#include <trace/hooks/mm.h> |
|---|
| 10 | +#endif |
|---|
| 7 | 11 | |
|---|
| 8 | 12 | /** |
|---|
| 9 | | - * page_is_file_cache - should the page be on a file LRU or anon LRU? |
|---|
| 13 | + * page_is_file_lru - should the page be on a file LRU or anon LRU? |
|---|
| 10 | 14 | * @page: the page to test |
|---|
| 11 | 15 | * |
|---|
| 12 | | - * Returns 1 if @page is page cache page backed by a regular filesystem, |
|---|
| 13 | | - * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed. |
|---|
| 14 | | - * Used by functions that manipulate the LRU lists, to sort a page |
|---|
| 15 | | - * onto the right LRU list. |
|---|
| 16 | + * Returns 1 if @page is a regular filesystem backed page cache page or a lazily |
|---|
| 17 | + * freed anonymous page (e.g. via MADV_FREE). Returns 0 if @page is a normal |
|---|
| 18 | + * anonymous page, a tmpfs page or otherwise ram or swap backed page. Used by |
|---|
| 19 | + * functions that manipulate the LRU lists, to sort a page onto the right LRU |
|---|
| 20 | + * list. |
|---|
| 16 | 21 | * |
|---|
| 17 | 22 | * We would like to get this info without a page flag, but the state |
|---|
| 18 | 23 | * needs to survive until the page is last deleted from the LRU, which |
|---|
| 19 | 24 | * could be as far down as __page_cache_release. |
|---|
| 20 | 25 | */ |
|---|
| 21 | | -static inline int page_is_file_cache(struct page *page) |
|---|
| 26 | +static inline int page_is_file_lru(struct page *page) |
|---|
| 22 | 27 | { |
|---|
| 23 | 28 | return !PageSwapBacked(page); |
|---|
| 24 | 29 | } |
|---|
| .. | .. |
|---|
| 29 | 34 | { |
|---|
| 30 | 35 | struct pglist_data *pgdat = lruvec_pgdat(lruvec); |
|---|
| 31 | 36 | |
|---|
| 32 | | - __mod_node_page_state(pgdat, NR_LRU_BASE + lru, nr_pages); |
|---|
| 37 | + __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages); |
|---|
| 33 | 38 | __mod_zone_page_state(&pgdat->node_zones[zid], |
|---|
| 34 | 39 | NR_ZONE_LRU_BASE + lru, nr_pages); |
|---|
| 35 | 40 | } |
|---|
| .. | .. |
|---|
| 47 | 52 | static __always_inline void add_page_to_lru_list(struct page *page, |
|---|
| 48 | 53 | struct lruvec *lruvec, enum lru_list lru) |
|---|
| 49 | 54 | { |
|---|
| 50 | | - update_lru_size(lruvec, lru, page_zonenum(page), hpage_nr_pages(page)); |
|---|
| 55 | + trace_android_vh_add_page_to_lrulist(page, false, lru); |
|---|
| 56 | + update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page)); |
|---|
| 51 | 57 | list_add(&page->lru, &lruvec->lists[lru]); |
|---|
| 52 | 58 | } |
|---|
| 53 | 59 | |
|---|
| 54 | 60 | static __always_inline void add_page_to_lru_list_tail(struct page *page, |
|---|
| 55 | 61 | struct lruvec *lruvec, enum lru_list lru) |
|---|
| 56 | 62 | { |
|---|
| 57 | | - update_lru_size(lruvec, lru, page_zonenum(page), hpage_nr_pages(page)); |
|---|
| 63 | + trace_android_vh_add_page_to_lrulist(page, false, lru); |
|---|
| 64 | + update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page)); |
|---|
| 58 | 65 | list_add_tail(&page->lru, &lruvec->lists[lru]); |
|---|
| 59 | 66 | } |
|---|
| 60 | 67 | |
|---|
| 61 | 68 | static __always_inline void del_page_from_lru_list(struct page *page, |
|---|
| 62 | 69 | struct lruvec *lruvec, enum lru_list lru) |
|---|
| 63 | 70 | { |
|---|
| 71 | + trace_android_vh_del_page_from_lrulist(page, false, lru); |
|---|
| 64 | 72 | list_del(&page->lru); |
|---|
| 65 | | - update_lru_size(lruvec, lru, page_zonenum(page), -hpage_nr_pages(page)); |
|---|
| 73 | + update_lru_size(lruvec, lru, page_zonenum(page), -thp_nr_pages(page)); |
|---|
| 66 | 74 | } |
|---|
| 67 | 75 | |
|---|
| 68 | 76 | /** |
|---|
| .. | .. |
|---|
| 75 | 83 | */ |
|---|
| 76 | 84 | static inline enum lru_list page_lru_base_type(struct page *page) |
|---|
| 77 | 85 | { |
|---|
| 78 | | - if (page_is_file_cache(page)) |
|---|
| 86 | + if (page_is_file_lru(page)) |
|---|
| 79 | 87 | return LRU_INACTIVE_FILE; |
|---|
| 80 | 88 | return LRU_INACTIVE_ANON; |
|---|
| 81 | 89 | } |
|---|
| .. | .. |
|---|
| 124 | 132 | } |
|---|
| 125 | 133 | return lru; |
|---|
| 126 | 134 | } |
|---|
| 127 | | - |
|---|
| 128 | | -#define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) |
|---|
| 129 | | - |
|---|
| 130 | 135 | #endif |
|---|