linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: linux-mm@kvack.org
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, akpm@linux-foundation.org,
	aarcange@redhat.com, hannes@cmpxchg.org
Subject: [PATCH 6/8] mm: Make transparent huge code not depend upon the details of pgtable_t
Date: Tue, 02 Oct 2012 18:27:18 -0400 (EDT)	[thread overview]
Message-ID: <20121002.182718.250164928532772411.davem@davemloft.net> (raw)


The code currently assumes that pgtable_t is a struct page pointer.

Fix this by pushing pgtable management behind arch helper functions.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/x86/include/asm/pgalloc.h |   26 ++++++++++++++++++++++++++
 mm/huge_memory.c               |   22 ++--------------------
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index b4389a4..f2a12e9 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -136,4 +136,30 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
 #endif	/* PAGETABLE_LEVELS > 3 */
 #endif	/* PAGETABLE_LEVELS > 2 */
 
+static inline void pmd_huge_pte_insert(struct mm_struct *mm, pgtable_t pgtable)
+{
+	/* FIFO */
+	if (!mm->pmd_huge_pte)
+		INIT_LIST_HEAD(&pgtable->lru);
+	else
+		list_add(&pgtable->lru, &mm->pmd_huge_pte->lru);
+	mm->pmd_huge_pte = pgtable;
+}
+
+static inline pgtable_t pmd_huge_pte_remove(struct mm_struct *mm)
+{
+	pgtable_t pgtable;
+
+	/* FIFO */
+	pgtable = mm->pmd_huge_pte;
+	if (list_empty(&pgtable->lru))
+		mm->pmd_huge_pte = NULL;
+	else {
+		mm->pmd_huge_pte = list_entry(pgtable->lru.next,
+					      struct page, lru);
+		list_del(&pgtable->lru);
+	}
+	return pgtable;
+}
+
 #endif /* _ASM_X86_PGALLOC_H */
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 29414c1..5d44785 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -616,12 +616,7 @@ static void prepare_pmd_huge_pte(pgtable_t pgtable,
 {
 	assert_spin_locked(&mm->page_table_lock);
 
-	/* FIFO */
-	if (!mm->pmd_huge_pte)
-		INIT_LIST_HEAD(&pgtable->lru);
-	else
-		list_add(&pgtable->lru, &mm->pmd_huge_pte->lru);
-	mm->pmd_huge_pte = pgtable;
+	pmd_huge_pte_insert(mm, pgtable);
 }
 
 static inline pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma)
@@ -805,20 +800,9 @@ out:
 /* no "address" argument so destroys page coloring of some arch */
 pgtable_t get_pmd_huge_pte(struct mm_struct *mm)
 {
-	pgtable_t pgtable;
-
 	assert_spin_locked(&mm->page_table_lock);
 
-	/* FIFO */
-	pgtable = mm->pmd_huge_pte;
-	if (list_empty(&pgtable->lru))
-		mm->pmd_huge_pte = NULL;
-	else {
-		mm->pmd_huge_pte = list_entry(pgtable->lru.next,
-					      struct page, lru);
-		list_del(&pgtable->lru);
-	}
-	return pgtable;
+	return pmd_huge_pte_remove(mm);
 }
 
 static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm,
@@ -1971,8 +1955,6 @@ static void collapse_huge_page(struct mm_struct *mm,
 	pte_unmap(pte);
 	__SetPageUptodate(new_page);
 	pgtable = pmd_pgtable(_pmd);
-	VM_BUG_ON(page_count(pgtable) != 1);
-	VM_BUG_ON(page_mapcount(pgtable) != 0);
 
 	_pmd = mk_pmd(new_page, vma->vm_page_prot);
 	_pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma);
-- 
1.7.10.4

--
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:[~2012-10-02 22:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02 22:27 David Miller [this message]
2012-10-02 22:49 ` Andrea Arcangeli

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=20121002.182718.250164928532772411.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sparclinux@vger.kernel.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