From: David Gibson <david@gibson.dropbear.id.au>
To: Andrew Morton <akpm@osdl.org>
Cc: Anton Blanchard <anton@samba.org>,
Paul Mackerras <paulus@samba.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
linux-kernel@vger.kernel.org, linuxppc64-dev@lists.linuxppc.org
Subject: Yet another PPC64 hugepage bugfix
Date: Tue, 6 Apr 2004 15:25:38 +1000 [thread overview]
Message-ID: <20040406052538.GH15981@zax> (raw)
Andrew, please apply. Found this again while looking at hugepage
extensions. Haven't actually had it bite yet - the race is small and
the other bug will never be triggered in 32-bit processes, and the
function is rarely called on 64-bit processes.
This patch fixes two bugs in the (same part of the) PPC64 hugepage
code. First the method we were using to free stale PTE pages was not
safe with some recent changes (race condition). BenH has fixed this
to work in the new way. Second, we were not checking for a valid PGD
entry before dereferencing the PMD page when scanning for stale PTE
page pointers.
===== arch/ppc64/mm/hugetlbpage.c 1.14 vs edited =====
Index: working-2.6/arch/ppc64/mm/hugetlbpage.c
===================================================================
--- working-2.6.orig/arch/ppc64/mm/hugetlbpage.c 2004-04-05 17:45:53.000000000 +1000
+++ working-2.6/arch/ppc64/mm/hugetlbpage.c 2004-04-06 15:09:29.383726856 +1000
@@ -247,6 +247,7 @@
{
struct vm_area_struct *vma;
unsigned long addr;
+ struct mmu_gather *tlb;
if (mm->context.low_hpages)
return 0; /* The window is already open */
@@ -262,32 +263,39 @@
/* Clean up any leftover PTE pages in the region */
spin_lock(&mm->page_table_lock);
+ tlb = tlb_gather_mmu(mm, 0);
for (addr = TASK_HPAGE_BASE_32; addr < TASK_HPAGE_END_32;
addr += PMD_SIZE) {
pgd_t *pgd = pgd_offset(mm, addr);
- pmd_t *pmd = pmd_offset(pgd, addr);
-
- if (! pmd_none(*pmd)) {
- struct page *page = pmd_page(*pmd);
- pte_t *pte = (pte_t *)pmd_page_kernel(*pmd);
- int i;
-
- /* No VMAs, so there should be no PTEs, check
- * just in case. */
- for (i = 0; i < PTRS_PER_PTE; i++) {
- BUG_ON(! pte_none(*pte));
- pte++;
- }
+ pmd_t *pmd;
+ struct page *page;
+ pte_t *pte;
+ int i;
+ if (pgd_none(*pgd))
+ continue;
+ pmd = pmd_offset(pgd, addr);
+ if (!pmd || pmd_none(*pmd))
+ continue;
+ if (pmd_bad(*pmd)) {
+ pmd_ERROR(*pmd);
pmd_clear(pmd);
- pgtable_remove_rmap(page);
- pte_free(page);
+ continue;
}
+ pte = (pte_t *)pmd_page_kernel(*pmd);
+ /* No VMAs, so there should be no PTEs, check just in case. */
+ for (i = 0; i < PTRS_PER_PTE; i++) {
+ BUG_ON(!pte_none(*pte));
+ pte++;
+ }
+ page = pmd_page(*pmd);
+ pmd_clear(pmd);
+ pgtable_remove_rmap(page);
+ pte_free_tlb(tlb, page);
}
+ tlb_finish_mmu(tlb, TASK_HPAGE_BASE_32, TASK_HPAGE_END_32);
spin_unlock(&mm->page_table_lock);
- /* FIXME: do we need to scan for PTEs too? */
-
mm->context.low_hpages = 1;
/* the context change must make it to memory before the slbia,
--
David Gibson | For every complex problem there is a
david AT gibson.dropbear.id.au | solution which is simple, neat and
| wrong.
http://www.ozlabs.org/people/dgibson
reply other threads:[~2004-04-06 5:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20040406052538.GH15981@zax \
--to=david@gibson.dropbear.id.au \
--cc=akpm@osdl.org \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc64-dev@lists.linuxppc.org \
--cc=paulus@samba.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
all inboxes | Powered by JetHome®