Skip to content

Commit

Permalink
mm/swap.c: export activate_page()
Browse files Browse the repository at this point in the history
activate_page() is needed to activate pages that are already on lru or
queued in lru_pvecs.lru_add. The exported function is a merger between
the existing activate_page() and __lru_cache_activate_page().

Signed-off-by: Yu Zhao <yuzhao@google.com>
  • Loading branch information
yuzhaogoogle authored and xanmod committed May 2, 2021
1 parent da3fe2a commit 4b28077
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ extern void lru_add_drain_cpu(int cpu);
extern void lru_add_drain_cpu_zone(struct zone *zone);
extern void lru_add_drain_all(void);
extern void rotate_reclaimable_page(struct page *page);
extern void activate_page(struct page *page);
extern void deactivate_file_page(struct page *page);
extern void deactivate_page(struct page *page);
extern void mark_page_lazyfree(struct page *page);
Expand Down
28 changes: 15 additions & 13 deletions mm/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static bool need_activate_page_drain(int cpu)
return pagevec_count(&per_cpu(lru_pvecs.activate_page, cpu)) != 0;
}

static void activate_page(struct page *page)
static void activate_page_on_lru(struct page *page)
{
page = compound_head(page);
if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
Expand All @@ -354,7 +354,7 @@ static inline void activate_page_drain(int cpu)
{
}

static void activate_page(struct page *page)
static void activate_page_on_lru(struct page *page)
{
struct lruvec *lruvec;

Expand All @@ -368,11 +368,22 @@ static void activate_page(struct page *page)
}
#endif

static void __lru_cache_activate_page(struct page *page)
/*
* If the page is on the LRU, queue it for activation via
* lru_pvecs.activate_page. Otherwise, assume the page is on a
* pagevec, mark it active and it'll be moved to the active
* LRU on the next drain.
*/
void activate_page(struct page *page)
{
struct pagevec *pvec;
int i;

if (PageLRU(page)) {
activate_page_on_lru(page);
return;
}

local_lock(&lru_pvecs.lock);
pvec = this_cpu_ptr(&lru_pvecs.lru_add);

Expand Down Expand Up @@ -421,16 +432,7 @@ void mark_page_accessed(struct page *page)
* evictable page accessed has no effect.
*/
} else if (!PageActive(page)) {
/*
* If the page is on the LRU, queue it for activation via
* lru_pvecs.activate_page. Otherwise, assume the page is on a
* pagevec, mark it active and it'll be moved to the active
* LRU on the next drain.
*/
if (PageLRU(page))
activate_page(page);
else
__lru_cache_activate_page(page);
activate_page(page);
ClearPageReferenced(page);
workingset_activation(page);
}
Expand Down

0 comments on commit 4b28077

Please sign in to comment.