From: Larry Woodman <lwoodman@redhat.com>
To: linux-mm@kvack.org
Subject: [RFC] shared page table for hugetlbpage memory causing leak.
Date: Wed, 16 Jan 2008 12:25:14 -0500 [thread overview]
Message-ID: <478E3DFA.9050900@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
I think the shared page table code for hugetlb memory on x86 and x86_64
is causing a leak. When a user of hugepages exits using this code the
system
leaks some of the hugepages.
-------------------------------------------------------
Part of /proc/meminfo just before database startup:
HugePages_Total: 5500
HugePages_Free: 5500
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
Just before shutdown:
HugePages_Total: 5500
HugePages_Free: 4475
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
After shutdown:
HugePages_Total: 5500
HugePages_Free: 4988
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
----------------------------------------------------------
I think the problem occurs durring a fork, in copy_hugetlb_page_range().
It locates the dst_pte using huge_pte_alloc(). Since huge_pte_alloc()
calls huge_pmd_share() it will share the pmd page if can yet the main
loop in copy_hugetlb_page_range() does a get_page() on every hugepage.
This is a violation of the shared hugepmd pagetable protocol and creates
additional referenced to the hugepages.
I think we can skip the entire replication of the ptes when the hugepage
pagetables are shared. This patch skips copying the ptes and the get_page()
calls if the hugetlbpage pagetable is shared.
[-- Attachment #2: linux-shared.patch --]
[-- Type: text/plain, Size: 1178 bytes --]
--- linux-2.6.23/mm/hugetlb.c.orig 2008-01-16 12:05:41.496448000 -0500
+++ linux-2.6.23/mm/hugetlb.c 2008-01-16 12:09:57.184746000 -0500
@@ -377,18 +377,22 @@ int copy_hugetlb_page_range(struct mm_st
dst_pte = huge_pte_alloc(dst, addr);
if (!dst_pte)
goto nomem;
- spin_lock(&dst->page_table_lock);
- spin_lock(&src->page_table_lock);
- if (!pte_none(*src_pte)) {
- if (cow)
- ptep_set_wrprotect(src, addr, src_pte);
- entry = *src_pte;
- ptepage = pte_page(entry);
- get_page(ptepage);
- set_huge_pte_at(dst, addr, dst_pte, entry);
+
+ /* if hugetlbpage pagetables are shared dont take additional references */
+ if(!(is_vm_hugtlb_page(vma) && dst_pte == src_pte)) {
+ spin_lock(&dst->page_table_lock);
+ spin_lock(&src->page_table_lock);
+ if (!pte_none(*src_pte)) {
+ if (cow)
+ ptep_set_wrprotect(src, addr, src_pte);
+ entry = *src_pte;
+ ptepage = pte_page(entry);
+ get_page(ptepage);
+ set_huge_pte_at(dst, addr, dst_pte, entry);
+ }
+ spin_unlock(&src->page_table_lock);
+ spin_unlock(&dst->page_table_lock);
}
- spin_unlock(&src->page_table_lock);
- spin_unlock(&dst->page_table_lock);
}
return 0;
next reply other threads:[~2008-01-16 17:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-16 17:25 Larry Woodman [this message]
2008-01-16 18:54 ` [RFC] shared page table for hugetlbpage memory causing leak Adam Litke
2008-01-16 18:55 ` Larry Woodman
2008-01-17 10:19 ` Balbir Singh
2008-01-17 11:53 ` Larry Woodman
2008-01-17 12:12 ` Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=478E3DFA.9050900@redhat.com \
--to=lwoodman@redhat.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).