Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af936a16 authored by Lee Schermerhorn's avatar Lee Schermerhorn Committed by Linus Torvalds
Browse files

vmscan: unevictable LRU scan sysctl



This patch adds a function to scan individual or all zones' unevictable
lists and move any pages that have become evictable onto the respective
zone's inactive list, where shrink_inactive_list() will deal with them.

Adds sysctl to scan all nodes, and per node attributes to individual
nodes' zones.

Kosaki: If evictable page found in unevictable lru when write
/proc/sys/vm/scan_unevictable_pages, print filename and file offset of
these pages.

[akpm@linux-foundation.org: fix one CONFIG_MMU=n build error]
[kosaki.motohiro@jp.fujitsu.com: adapt vmscan-unevictable-lru-scan-sysctl.patch to new sysfs API]
Signed-off-by: default avatarLee Schermerhorn <lee.schermerhorn@hp.com>
Signed-off-by: default avatarRik van Riel <riel@redhat.com>
Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 64d6519d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <linux/nodemask.h>
#include <linux/cpu.h>
#include <linux/device.h>
#include <linux/swap.h>

static struct sysdev_class node_class = {
	.name = "node",
@@ -191,6 +192,8 @@ int register_node(struct node *node, int num, struct node *parent)
		sysdev_create_file(&node->sysdev, &attr_meminfo);
		sysdev_create_file(&node->sysdev, &attr_numastat);
		sysdev_create_file(&node->sysdev, &attr_distance);

		scan_unevictable_register_node(node);
	}
	return error;
}
@@ -210,6 +213,8 @@ void unregister_node(struct node *node)
	sysdev_remove_file(&node->sysdev, &attr_numastat);
	sysdev_remove_file(&node->sysdev, &attr_distance);

	scan_unevictable_unregister_node(node);

	sysdev_unregister(&node->sysdev);
}

+3 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ void anon_vma_unlink(struct vm_area_struct *);
void anon_vma_link(struct vm_area_struct *);
void __anon_vma_link(struct vm_area_struct *);

extern struct anon_vma *page_lock_anon_vma(struct page *page);
extern void page_unlock_anon_vma(struct anon_vma *anon_vma);

/*
 * rmap interfaces called when adding or removing pte of page
 */
+15 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include <linux/list.h>
#include <linux/memcontrol.h>
#include <linux/sched.h>
#include <linux/node.h>

#include <asm/atomic.h>
#include <asm/page.h>
@@ -235,15 +236,29 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
#ifdef CONFIG_UNEVICTABLE_LRU
extern int page_evictable(struct page *page, struct vm_area_struct *vma);
extern void scan_mapping_unevictable_pages(struct address_space *);

extern unsigned long scan_unevictable_pages;
extern int scan_unevictable_handler(struct ctl_table *, int, struct file *,
					void __user *, size_t *, loff_t *);
extern int scan_unevictable_register_node(struct node *node);
extern void scan_unevictable_unregister_node(struct node *node);
#else
static inline int page_evictable(struct page *page,
						struct vm_area_struct *vma)
{
	return 1;
}

static inline void scan_mapping_unevictable_pages(struct address_space *mapping)
{
}

static inline int scan_unevictable_register_node(struct node *node)
{
	return 0;
}

static inline void scan_unevictable_unregister_node(struct node *node) { }
#endif

extern int kswapd_run(int nid);
+10 −0
Original line number Diff line number Diff line
@@ -833,6 +833,16 @@ static struct ctl_table kern_table[] = {
		.proc_handler   = &proc_dointvec,
	},
#endif
#ifdef CONFIG_UNEVICTABLE_LRU
	{
		.ctl_name	= CTL_UNNUMBERED,
		.procname	= "scan_unevictable_pages",
		.data		= &scan_unevictable_pages,
		.maxlen		= sizeof(scan_unevictable_pages),
		.mode		= 0644,
		.proc_handler	= &scan_unevictable_handler,
	},
#endif
/*
 * NOTE: do not add new entries to this table unless you have read
 * Documentation/sysctl/ctl_unnumbered.txt
+2 −2
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ void __init anon_vma_init(void)
 * Getting a lock on a stable anon_vma from a page off the LRU is
 * tricky: page_lock_anon_vma rely on RCU to guard against the races.
 */
static struct anon_vma *page_lock_anon_vma(struct page *page)
struct anon_vma *page_lock_anon_vma(struct page *page)
{
	struct anon_vma *anon_vma;
	unsigned long anon_mapping;
@@ -201,7 +201,7 @@ static struct anon_vma *page_lock_anon_vma(struct page *page)
	return NULL;
}

static void page_unlock_anon_vma(struct anon_vma *anon_vma)
void page_unlock_anon_vma(struct anon_vma *anon_vma)
{
	spin_unlock(&anon_vma->lock);
	rcu_read_unlock();
Loading