Skip to content

Commit

Permalink
mm: implement WasActive page flag (for improving cleancache)
Browse files Browse the repository at this point in the history
(Feedback welcome if there is a different/better way to do this
without using a page flag!)

Since about 2.6.27, the page replacement algorithm maintains
an "active" bit to help decide which pages are most eligible
to reclaim, see http://linux-mm.org/PageReplacementDesign

This "active' information is also useful to cleancache but is lost
by the time that cleancache has the opportunity to preserve the
pageful of data.  This patch adds a new page flag "WasActive" to
retain the state.  The flag may possibly be useful elsewhere.

It is up to each cleancache backend to utilize the bit as
it desires.  The matching patch for zcache is included here
for clarification/discussion purposes, though it will need to
go through GregKH and the staging tree.

The patch resolves issues reported with cleancache which occur
especially during streaming workloads on older processors,
see https://lkml.org/lkml/2011/8/17/351

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
  • Loading branch information
neobuddy89 committed Apr 12, 2013
1 parent 39e25de commit 03082a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/page-flags.h
Expand Up @@ -107,6 +107,9 @@ enum pageflags {
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
PG_compound_lock,
#endif
#ifdef CONFIG_CLEANCACHE
PG_was_active,
#endif
__NR_PAGEFLAGS,

/* Filesystems */
Expand Down Expand Up @@ -264,6 +267,9 @@ __PAGEFLAG(SlobFree, slob_free)

__PAGEFLAG(SlubFrozen, slub_frozen)

#ifdef CONFIG_CLEANCACHE
PAGEFLAG(WasActive, was_active)
#endif
/*
* Private page markings that may be used by the filesystem that owns the page
* for its own purposes.
Expand Down
4 changes: 4 additions & 0 deletions mm/vmscan.c
Expand Up @@ -581,6 +581,8 @@ void putback_lru_page(struct page *page)
int was_unevictable = PageUnevictable(page);

VM_BUG_ON(PageLRU(page));
if (active)
SetPageWasActive(page);

redo:
ClearPageUnevictable(page);
Expand Down Expand Up @@ -1210,6 +1212,7 @@ unsigned long clear_active_flags(struct list_head *page_list,
if (PageActive(page)) {
lru += LRU_ACTIVE;
ClearPageActive(page);
SetPageWasActive(page);
nr_active += numpages;
}
if (count)
Expand Down Expand Up @@ -1692,6 +1695,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
}

ClearPageActive(page); /* we are de-activating */
SetPageWasActive(page);
list_add(&page->lru, &l_inactive);
}

Expand Down

0 comments on commit 03082a5

Please sign in to comment.