Commit 5344b7e6 authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds
Browse files

vmstat: mlocked pages statistics



Add NR_MLOCK zone page state, which provides a (conservative) count of
mlocked pages (actually, the number of mlocked pages moved off the LRU).

Reworked by lts to fit in with the modified mlock page support in the
Reclaim Scalability series.

[kosaki.motohiro@jp.fujitsu.com: fix incorrect Mlocked field of /proc/meminfo]
[lee.schermerhorn@hp.com: mlocked-pages: add event counting with statistics]
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
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 avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ba470de4
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
		       "Node %d Active(file):   %8lu kB\n"
		       "Node %d Active(file):   %8lu kB\n"
		       "Node %d Inactive(file): %8lu kB\n"
		       "Node %d Inactive(file): %8lu kB\n"
#ifdef CONFIG_UNEVICTABLE_LRU
#ifdef CONFIG_UNEVICTABLE_LRU
		       "Node %d Noreclaim:      %8lu kB\n"
		       "Node %d Unevictable:    %8lu kB\n"
		       "Node %d Mlocked:        %8lu kB\n"
#endif
#endif
#ifdef CONFIG_HIGHMEM
#ifdef CONFIG_HIGHMEM
		       "Node %d HighTotal:      %8lu kB\n"
		       "Node %d HighTotal:      %8lu kB\n"
@@ -104,6 +105,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
#ifdef CONFIG_UNEVICTABLE_LRU
#ifdef CONFIG_UNEVICTABLE_LRU
		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
		       nid, K(node_page_state(nid, NR_MLOCK)),
#endif
#endif
#ifdef CONFIG_HIGHMEM
#ifdef CONFIG_HIGHMEM
		       nid, K(i.totalhigh),
		       nid, K(i.totalhigh),
+2 −0
Original line number Original line Diff line number Diff line
@@ -176,6 +176,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
		"Inactive(file): %8lu kB\n"
		"Inactive(file): %8lu kB\n"
#ifdef CONFIG_UNEVICTABLE_LRU
#ifdef CONFIG_UNEVICTABLE_LRU
		"Unevictable:    %8lu kB\n"
		"Unevictable:    %8lu kB\n"
		"Mlocked:        %8lu kB\n"
#endif
#endif
#ifdef CONFIG_HIGHMEM
#ifdef CONFIG_HIGHMEM
		"HighTotal:      %8lu kB\n"
		"HighTotal:      %8lu kB\n"
@@ -217,6 +218,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
		K(pages[LRU_INACTIVE_FILE]),
		K(pages[LRU_INACTIVE_FILE]),
#ifdef CONFIG_UNEVICTABLE_LRU
#ifdef CONFIG_UNEVICTABLE_LRU
		K(pages[LRU_UNEVICTABLE]),
		K(pages[LRU_UNEVICTABLE]),
		K(global_page_state(NR_MLOCK)),
#endif
#endif
#ifdef CONFIG_HIGHMEM
#ifdef CONFIG_HIGHMEM
		K(i.totalhigh),
		K(i.totalhigh),
+2 −0
Original line number Original line Diff line number Diff line
@@ -88,8 +88,10 @@ enum zone_stat_item {
	NR_ACTIVE_FILE,		/*  "     "     "   "       "         */
	NR_ACTIVE_FILE,		/*  "     "     "   "       "         */
#ifdef CONFIG_UNEVICTABLE_LRU
#ifdef CONFIG_UNEVICTABLE_LRU
	NR_UNEVICTABLE,		/*  "     "     "   "       "         */
	NR_UNEVICTABLE,		/*  "     "     "   "       "         */
	NR_MLOCK,		/* mlock()ed pages found and moved off LRU */
#else
#else
	NR_UNEVICTABLE = NR_ACTIVE_FILE, /* avoid compiler errors in dead code */
	NR_UNEVICTABLE = NR_ACTIVE_FILE, /* avoid compiler errors in dead code */
	NR_MLOCK = NR_ACTIVE_FILE,
#endif
#endif
	NR_ANON_PAGES,	/* Mapped anonymous pages */
	NR_ANON_PAGES,	/* Mapped anonymous pages */
	NR_FILE_MAPPED,	/* pagecache pages mapped into pagetables.
	NR_FILE_MAPPED,	/* pagecache pages mapped into pagetables.
+4 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
		UNEVICTABLE_PGCULLED,	/* culled to noreclaim list */
		UNEVICTABLE_PGCULLED,	/* culled to noreclaim list */
		UNEVICTABLE_PGSCANNED,	/* scanned for reclaimability */
		UNEVICTABLE_PGSCANNED,	/* scanned for reclaimability */
		UNEVICTABLE_PGRESCUED,	/* rescued from noreclaim list */
		UNEVICTABLE_PGRESCUED,	/* rescued from noreclaim list */
		UNEVICTABLE_PGMLOCKED,
		UNEVICTABLE_PGMUNLOCKED,
		UNEVICTABLE_PGCLEARED,	/* on COW, page truncate */
		UNEVICTABLE_PGSTRANDED,	/* unable to isolate on unlock */
#endif
#endif
		NR_VM_EVENT_ITEMS
		NR_VM_EVENT_ITEMS
};
};
+13 −3
Original line number Original line Diff line number Diff line
@@ -101,7 +101,10 @@ static inline int is_mlocked_vma(struct vm_area_struct *vma, struct page *page)
	if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED))
	if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED))
		return 0;
		return 0;


	SetPageMlocked(page);
	if (!TestSetPageMlocked(page)) {
		inc_zone_page_state(page, NR_MLOCK);
		count_vm_event(UNEVICTABLE_PGMLOCKED);
	}
	return 1;
	return 1;
}
}


@@ -128,12 +131,19 @@ static inline void clear_page_mlock(struct page *page)


/*
/*
 * mlock_migrate_page - called only from migrate_page_copy() to
 * mlock_migrate_page - called only from migrate_page_copy() to
 * migrate the Mlocked page flag
 * migrate the Mlocked page flag; update statistics.
 */
 */
static inline void mlock_migrate_page(struct page *newpage, struct page *page)
static inline void mlock_migrate_page(struct page *newpage, struct page *page)
{
{
	if (TestClearPageMlocked(page))
	if (TestClearPageMlocked(page)) {
		unsigned long flags;

		local_irq_save(flags);
		__dec_zone_page_state(page, NR_MLOCK);
		SetPageMlocked(newpage);
		SetPageMlocked(newpage);
		__inc_zone_page_state(newpage, NR_MLOCK);
		local_irq_restore(flags);
	}
}
}




Loading