forked from luck/tmp_suning_uos_patched
894bc31041
When the system contains lots of mlocked or otherwise unevictable pages, the pageout code (kswapd) can spend lots of time scanning over these pages. Worse still, the presence of lots of unevictable pages can confuse kswapd into thinking that more aggressive pageout modes are required, resulting in all kinds of bad behaviour. Infrastructure to manage pages excluded from reclaim--i.e., hidden from vmscan. Based on a patch by Larry Woodman of Red Hat. Reworked to maintain "unevictable" pages on a separate per-zone LRU list, to "hide" them from vmscan. Kosaki Motohiro added the support for the memory controller unevictable lru list. Pages on the unevictable list have both PG_unevictable and PG_lru set. Thus, PG_unevictable is analogous to and mutually exclusive with PG_active--it specifies which LRU list the page is on. The unevictable infrastructure is enabled by a new mm Kconfig option [CONFIG_]UNEVICTABLE_LRU. A new function 'page_evictable(page, vma)' in vmscan.c tests whether or not a page may be evictable. Subsequent patches will add the various !evictable tests. We'll want to keep these tests light-weight for use in shrink_active_list() and, possibly, the fault path. To avoid races between tasks putting pages [back] onto an LRU list and tasks that might be moving the page from non-evictable to evictable state, the new function 'putback_lru_page()' -- inverse to 'isolate_lru_page()' -- tests the "evictability" of a page after placing it on the LRU, before dropping the reference. If the page has become unevictable, putback_lru_page() will redo the 'putback', thus moving the page to the unevictable list. This way, we avoid "stranding" evictable pages on the unevictable list. [akpm@linux-foundation.org: fix fallout from out-of-order merge] [riel@redhat.com: fix UNEVICTABLE_LRU and !PROC_PAGE_MONITOR build] [nishimura@mxp.nes.nec.co.jp: remove redundant mapping check] [kosaki.motohiro@jp.fujitsu.com: unevictable-lru-infrastructure: putback_lru_page()/unevictable page handling rework] [kosaki.motohiro@jp.fujitsu.com: kill unnecessary lock_page() in vmscan.c] [kosaki.motohiro@jp.fujitsu.com: revert migration change of unevictable lru infrastructure] [kosaki.motohiro@jp.fujitsu.com: revert to unevictable-lru-infrastructure-kconfig-fix.patch] [kosaki.motohiro@jp.fujitsu.com: restore patch failure of vmstat-unevictable-and-mlocked-pages-vm-events.patch] Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Debugged-by: Benjamin Kidwell <benjkidwell@yahoo.com> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
117 lines
2.6 KiB
C
117 lines
2.6 KiB
C
/*
|
|
* include/linux/pagevec.h
|
|
*
|
|
* In many places it is efficient to batch an operation up against multiple
|
|
* pages. A pagevec is a multipage container which is used for that.
|
|
*/
|
|
|
|
#ifndef _LINUX_PAGEVEC_H
|
|
#define _LINUX_PAGEVEC_H
|
|
|
|
/* 14 pointers + two long's align the pagevec structure to a power of two */
|
|
#define PAGEVEC_SIZE 14
|
|
|
|
struct page;
|
|
struct address_space;
|
|
|
|
struct pagevec {
|
|
unsigned long nr;
|
|
unsigned long cold;
|
|
struct page *pages[PAGEVEC_SIZE];
|
|
};
|
|
|
|
void __pagevec_release(struct pagevec *pvec);
|
|
void __pagevec_release_nonlru(struct pagevec *pvec);
|
|
void __pagevec_free(struct pagevec *pvec);
|
|
void ____pagevec_lru_add(struct pagevec *pvec, enum lru_list lru);
|
|
void pagevec_strip(struct pagevec *pvec);
|
|
void pagevec_swap_free(struct pagevec *pvec);
|
|
unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
|
|
pgoff_t start, unsigned nr_pages);
|
|
unsigned pagevec_lookup_tag(struct pagevec *pvec,
|
|
struct address_space *mapping, pgoff_t *index, int tag,
|
|
unsigned nr_pages);
|
|
|
|
static inline void pagevec_init(struct pagevec *pvec, int cold)
|
|
{
|
|
pvec->nr = 0;
|
|
pvec->cold = cold;
|
|
}
|
|
|
|
static inline void pagevec_reinit(struct pagevec *pvec)
|
|
{
|
|
pvec->nr = 0;
|
|
}
|
|
|
|
static inline unsigned pagevec_count(struct pagevec *pvec)
|
|
{
|
|
return pvec->nr;
|
|
}
|
|
|
|
static inline unsigned pagevec_space(struct pagevec *pvec)
|
|
{
|
|
return PAGEVEC_SIZE - pvec->nr;
|
|
}
|
|
|
|
/*
|
|
* Add a page to a pagevec. Returns the number of slots still available.
|
|
*/
|
|
static inline unsigned pagevec_add(struct pagevec *pvec, struct page *page)
|
|
{
|
|
pvec->pages[pvec->nr++] = page;
|
|
return pagevec_space(pvec);
|
|
}
|
|
|
|
|
|
static inline void pagevec_release(struct pagevec *pvec)
|
|
{
|
|
if (pagevec_count(pvec))
|
|
__pagevec_release(pvec);
|
|
}
|
|
|
|
static inline void pagevec_release_nonlru(struct pagevec *pvec)
|
|
{
|
|
if (pagevec_count(pvec))
|
|
__pagevec_release_nonlru(pvec);
|
|
}
|
|
|
|
static inline void pagevec_free(struct pagevec *pvec)
|
|
{
|
|
if (pagevec_count(pvec))
|
|
__pagevec_free(pvec);
|
|
}
|
|
|
|
static inline void __pagevec_lru_add_anon(struct pagevec *pvec)
|
|
{
|
|
____pagevec_lru_add(pvec, LRU_INACTIVE_ANON);
|
|
}
|
|
|
|
static inline void __pagevec_lru_add_active_anon(struct pagevec *pvec)
|
|
{
|
|
____pagevec_lru_add(pvec, LRU_ACTIVE_ANON);
|
|
}
|
|
|
|
static inline void __pagevec_lru_add_file(struct pagevec *pvec)
|
|
{
|
|
____pagevec_lru_add(pvec, LRU_INACTIVE_FILE);
|
|
}
|
|
|
|
static inline void __pagevec_lru_add_active_file(struct pagevec *pvec)
|
|
{
|
|
____pagevec_lru_add(pvec, LRU_ACTIVE_FILE);
|
|
}
|
|
|
|
static inline void pagevec_lru_add_file(struct pagevec *pvec)
|
|
{
|
|
if (pagevec_count(pvec))
|
|
__pagevec_lru_add_file(pvec);
|
|
}
|
|
|
|
static inline void pagevec_lru_add_anon(struct pagevec *pvec)
|
|
{
|
|
if (pagevec_count(pvec))
|
|
__pagevec_lru_add_anon(pvec);
|
|
}
|
|
|
|
#endif /* _LINUX_PAGEVEC_H */
|