linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Hans Rosenfeld <hans.rosenfeld@amd.com>
Cc: Matt Mackall <mpm@selenic.com>,
	linux-mm@kvack.org, Dave Hansen <dave@linux.vnet.ibm.com>
Subject: [RFC][PATCH 2/2] fix large pages in pagemap
Date: Fri, 06 Jun 2008 10:31:38 -0700	[thread overview]
Message-ID: <20080606173138.9BFE6272@kernel> (raw)
In-Reply-To: <20080606173137.24513039@kernel>

We were walking right into huge page areas in the pagemap
walker, and calling the pmds pmd_bad() and clearing them.

That leaked huge pages.  Bad.

This patch at least works around that for now.  It ignores
huge pages in the pagemap walker for the time being, and
won't leak those pages.

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
---

 linux-2.6.git-dave/fs/proc/task_mmu.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff -puN fs/proc/task_mmu.c~fix-large-pages-in-pagemap fs/proc/task_mmu.c
--- linux-2.6.git/fs/proc/task_mmu.c~fix-large-pages-in-pagemap	2008-06-06 09:44:45.000000000 -0700
+++ linux-2.6.git-dave/fs/proc/task_mmu.c	2008-06-06 09:48:44.000000000 -0700
@@ -567,12 +567,19 @@ static u64 swap_pte_to_pagemap_entry(pte
 static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 			     struct mm_walk *walk)
 {
+	struct vm_area_struct *vma = NULL;
 	struct pagemapread *pm = walk->private;
 	pte_t *pte;
 	int err = 0;
 
 	for (; addr != end; addr += PAGE_SIZE) {
 		u64 pfn = PM_NOT_PRESENT;
+
+		if (!vma || addr >= vma->vm_end)
+			vma = find_vma(walk->mm, addr);
+		if (vma && is_vm_hugetlb_page(vma)) {
+			goto add:
+
 		pte = pte_offset_map(pmd, addr);
 		if (is_swap_pte(*pte))
 			pfn = PM_PFRAME(swap_pte_to_pagemap_entry(*pte))
@@ -582,6 +589,7 @@ static int pagemap_pte_range(pmd_t *pmd,
 				| PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT;
 		/* unmap so we're not in atomic when we copy to userspace */
 		pte_unmap(pte);
+	add:
 		err = add_to_pagemap(addr, pfn, pm);
 		if (err)
 			return err;
diff -puN mm/pagewalk.c~fix-large-pages-in-pagemap mm/pagewalk.c
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2008-06-06 17:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 17:31 [RFC][PATCH 1/2] pass mm into pagewalkers Dave Hansen
2008-06-06 17:31 ` Dave Hansen [this message]
2008-06-06 18:14   ` [RFC][PATCH 2/2] fix large pages in pagemap Matt Mackall
2008-06-06 18:45     ` Dave Hansen
2008-06-06 18:06 ` [RFC][PATCH 1/2] pass mm into pagewalkers Matt Mackall
2008-06-06 18:20   ` Dave Hansen

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=20080606173138.9BFE6272@kernel \
    --to=dave@linux.vnet.ibm.com \
    --cc=hans.rosenfeld@amd.com \
    --cc=linux-mm@kvack.org \
    --cc=mpm@selenic.com \
    /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