]> Git Repo - linux.git/commit
mm, thp: fix mlock statistics
authorDavid Rientjes <[email protected]>
Mon, 8 Oct 2012 23:34:06 +0000 (16:34 -0700)
committerLinus Torvalds <[email protected]>
Tue, 9 Oct 2012 07:23:03 +0000 (16:23 +0900)
commit8449d21fb49e9824e2736c5febd6b5d287cd2ba1
tree8685691f2e75ab7ceeacb05c661fa151270c3ee8
parentb676b293fb48672904ee1b9828cb50b4eed01717
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 <[email protected]>
Reported-by: Hugh Dickens <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Reviewed-by: Andrea Arcangeli <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Johannes Weiner <[email protected]>
Reviewed-by: Michel Lespinasse <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/internal.h
mm/mlock.c
This page took 0.0448229999999999 seconds and 4 git commands to generate.