linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm hugetlb x86: add hugepage support to pagemap
@ 2009-12-07  7:59 Naoya Horiguchi
  2009-12-08 22:39 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Naoya Horiguchi @ 2009-12-07  7:59 UTC (permalink / raw)
  To: LKML; +Cc: linux-mm, hugh.dickins, ak, Wu Fengguang

Hi,

Most callers of pmd_none_or_clear_bad() check whether the target
page is in a hugepage or not, but mincore() and walk_page_range() do
not check it. So if we read /proc/pid/pagemap for the hugepage
on x86 machine, the hugepage memory is leaked as shown below.
This patch fixes it by extending pagemap interface to support hugepages.

I split this fix into two patches.  The first patch just adds the check
for hugepages, and the second patch adds a new member to struct mm_walk
to handle the hugepages.

 fs/proc/task_mmu.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mm.h |    3 +++
 mm/pagewalk.c      |   29 ++++++++++++++++++++++++++++-
 3 files changed, 74 insertions(+), 1 deletions(-)

Details
=======
My test program (leak_pagemap) works as follows:
 - creat() and mmap() a file on hugetlbfs (file size is 200MB == 100 hugepages,)
 - read()/write() something on it,
 - call page-types with option -p,
 - munmap() and unlink() the file on hugetlbfs
    
Without my patches
------------------
$ cat /proc/meminfo |grep "HugePage"
HugePages_Total:    1000
HugePages_Free:     1000
HugePages_Rsvd:        0
HugePages_Surp:        0
$ ./leak_pagemap
             flags page-count       MB  symbolic-flags                     long-symbolic-flags
0x0000000000000000          1        0  __________________________________ 
0x0000000000000804          1        0  __R________M______________________ referenced,mmap
0x000000000000086c         81        0  __RU_lA____M______________________ referenced,uptodate,lru,active,mmap
0x0000000000005808          5        0  ___U_______Ma_b___________________ uptodate,mmap,anonymous,swapbacked
0x0000000000005868         12        0  ___U_lA____Ma_b___________________ uptodate,lru,active,mmap,anonymous,swapbacked
0x000000000000586c          1        0  __RU_lA____Ma_b___________________ referenced,uptodate,lru,active,mmap,anonymous,swapbacked
             total        101        0
$ cat /proc/meminfo |grep "HugePage"
HugePages_Total:    1000
HugePages_Free:      900
HugePages_Rsvd:        0
HugePages_Surp:        0
$ ls /hugetlbfs/
$ 

The output of page-types don't show any hugepage, and 100 hugepages are
accounted as used while there is no file on hugetlbfs


With my patches
---------------
$ cat /proc/meminfo |grep "HugePage"
HugePages_Total:    1000
HugePages_Free:     1000
HugePages_Rsvd:        0
HugePages_Surp:        0
$ ./leak_pagemap 
             flags page-count       MB  symbolic-flags                     long-symbolic-flags
0x0000000000000000          1        0  __________________________________ 
0x0000000000030000      51100      199  ________________TG________________ compound_tail,huge
0x0000000000028018        100        0  ___UD__________H_G________________ uptodate,dirty,compound_head,huge
0x0000000000000804          1        0  __R________M______________________ referenced,mmap
0x000000000000080c          1        0  __RU_______M______________________ referenced,uptodate,mmap
0x000000000000086c         80        0  __RU_lA____M______________________ referenced,uptodate,lru,active,mmap
0x0000000000005808          4        0  ___U_______Ma_b___________________ uptodate,mmap,anonymous,swapbacked
0x0000000000005868         12        0  ___U_lA____Ma_b___________________ uptodate,lru,active,mmap,anonymous,swapbacked
0x000000000000586c          1        0  __RU_lA____Ma_b___________________ referenced,uptodate,lru,active,mmap,anonymous,swapbacked
             total      51300      200
$ cat /proc/meminfo |grep "HugePage"
HugePages_Total:    1000
HugePages_Free:     1000
HugePages_Rsvd:        0
HugePages_Surp:        0
$ ls /hugetlbfs
$ 

The output of page-types shows 51200 pages contributing to hugepages,
containing 100 head pages and 51100 tail pages as expected.
And no memory leaks.

Thanks,
Naoya Horiguchi


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 0/2] mm hugetlb x86: add hugepage support to pagemap
  2009-12-07  7:59 [PATCH 0/2] mm hugetlb x86: add hugepage support to pagemap Naoya Horiguchi
@ 2009-12-08 22:39 ` Andrew Morton
  2009-12-09  1:08   ` Naoya Horiguchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-12-08 22:39 UTC (permalink / raw)
  To: n-horiguchi; +Cc: LKML, linux-mm, hugh.dickins, ak, Wu Fengguang

On Mon, 07 Dec 2009 16:59:18 +0900
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:

> Most callers of pmd_none_or_clear_bad() check whether the target
> page is in a hugepage or not, but mincore() and walk_page_range() do
> not check it. So if we read /proc/pid/pagemap for the hugepage
> on x86 machine, the hugepage memory is leaked as shown below.
> This patch fixes it by extending pagemap interface to support hugepages.
> 
> I split this fix into two patches.  The first patch just adds the check
> for hugepages, and the second patch adds a new member to struct mm_walk
> to handle the hugepages.

I kind of dislike the practice of putting all the changelog in patch
[0/n] and then leaving the patches themselves practically
unchangelogged.  Because

a) Someone (ie: me) needs to go and shuffle all the text around so
   that the information gets itself into the git record.  We don't add
   changelog-only commits to git!

b) Someone (ie: me) might decide to backport a subset of the patches
   into -stable.  Now someone (ie: me) needs to carve up the changelogs
   so that the pieces which go into -stable still make standalone sense.

I'm not sure that I did this particularly well in this case.  Oh well.


Please confirm that
mm-hugetlb-fix-hugepage-memory-leak-in-walk_page_range.patch is
suitable for a -stable backport without inclusion of
mm-hugetlb-add-hugepage-support-to-pagemap.patch.  I think it is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 0/2] mm hugetlb x86: add hugepage support to pagemap
  2009-12-08 22:39 ` Andrew Morton
@ 2009-12-09  1:08   ` Naoya Horiguchi
  0 siblings, 0 replies; 3+ messages in thread
From: Naoya Horiguchi @ 2009-12-09  1:08 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, linux-mm, hugh.dickins, ak, Wu Fengguang

> I kind of dislike the practice of putting all the changelog in patch
> [0/n] and then leaving the patches themselves practically
> unchangelogged.  Because

Sorry, I agree.

> 
> a) Someone (ie: me) needs to go and shuffle all the text around so
>    that the information gets itself into the git record.  We don't add
>    changelog-only commits to git!
> 
> b) Someone (ie: me) might decide to backport a subset of the patches
>    into -stable.  Now someone (ie: me) needs to carve up the changelogs
>    so that the pieces which go into -stable still make standalone sense.
> 
> I'm not sure that I did this particularly well in this case.  Oh well.
> 
> 
> Please confirm that
> mm-hugetlb-fix-hugepage-memory-leak-in-walk_page_range.patch is
> suitable for a -stable backport without inclusion of
> mm-hugetlb-add-hugepage-support-to-pagemap.patch.  I think it is.
> 

I think that's OK.

Thanks,
Naoya Horiguchi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-09  1:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-07  7:59 [PATCH 0/2] mm hugetlb x86: add hugepage support to pagemap Naoya Horiguchi
2009-12-08 22:39 ` Andrew Morton
2009-12-09  1:08   ` Naoya Horiguchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).