David Rientjes 8449d21fb4 mm, thp: fix mlock statistics
NR_MLOCK is only accounted in single page units: there's no logic to
handle transparent hugepages.  This patch checks the appropriate number of
pages to adjust the statistics by so that the correct amount of memory is
reflected.

Currently:

		$ grep Mlocked /proc/meminfo
		Mlocked:           19636 kB

	#define MAP_SIZE	(4 << 30)	/* 4GB */

	void *ptr = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE,
			 MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
	mlock(ptr, MAP_SIZE);

		$ grep Mlocked /proc/meminfo
		Mlocked:           29844 kB

	munlock(ptr, MAP_SIZE);

		$ grep Mlocked /proc/meminfo
		Mlocked:           19636 kB

And with this patch:

		$ grep Mlock /proc/meminfo
		Mlocked:           19636 kB

	mlock(ptr, MAP_SIZE);

		$ grep Mlock /proc/meminfo
		Mlocked:         4213664 kB

	munlock(ptr, MAP_SIZE);

		$ grep Mlock /proc/meminfo
		Mlocked:           19636 kB

Signed-off-by: David Rientjes <rientjes@google.com>
Reported-by: Hugh Dickens <hughd@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Michel Lespinasse <walken@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-10-09 16:23:03 +09:00
..
2012-10-09 16:22:54 +09:00
2012-05-29 23:28:33 -04:00
2012-10-09 16:23:00 +09:00
2012-01-03 22:54:56 -05:00
2011-07-26 16:49:47 -07:00
2012-10-09 16:23:03 +09:00
2012-10-09 16:23:03 +09:00
2012-07-31 18:42:43 -07:00
2010-05-21 18:31:21 -04:00
2012-10-09 16:22:54 +09:00
2012-10-09 16:22:24 +09:00
2012-07-31 18:42:43 -07:00
2012-06-20 14:39:36 -07:00
2012-06-20 14:39:36 -07:00
2012-10-09 16:22:17 +09:00
2012-07-31 18:42:49 -07:00
2012-10-09 16:22:55 +09:00
2012-10-09 16:23:00 +09:00
2012-10-09 16:22:59 +09:00