From: Anshuman Khandual <anshuman.khandual@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: mark.rutland@arm.com, yuzhao@google.com, Steve.Capper@arm.com,
marc.zyngier@arm.com, Catalin.Marinas@arm.com,
suzuki.poulose@arm.com, will.deacon@arm.com, james.morse@arm.com
Subject: [PATCH V2 6/6] arm64/mm: Enable ARCH_ENABLE_SPLIT_PMD_PTLOCK
Date: Mon, 25 Feb 2019 10:33:59 +0530 [thread overview]
Message-ID: <1551071039-20192-7-git-send-email-anshuman.khandual@arm.com> (raw)
In-Reply-To: <1551071039-20192-1-git-send-email-anshuman.khandual@arm.com>
Enabling ARCH_ENABLE_SPLIT_PMD_PTLOCK should help reduce lock contention on
larger systems when the page tables are being modified concurrently. This
moves locking granularity from mm_struct (mm->page_table_lock) to per pmd
page table lock (page->ptl).
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/arm64/Kconfig | 4 +++
arch/arm64/include/asm/pgalloc.h | 43 ++++++++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a4168d366127..b909e5d3b951 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -285,6 +285,10 @@ config PGTABLE_LEVELS
default 3 if ARM64_16K_PAGES && ARM64_VA_BITS_47
default 4 if !ARM64_64K_PAGES && ARM64_VA_BITS_48
+config ARCH_ENABLE_SPLIT_PMD_PTLOCK
+ def_bool y
+ depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE && (PGTABLE_LEVELS > 2)
+
config ARCH_SUPPORTS_UPROBES
def_bool y
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
index a02a4d1d967d..9e06238be9b6 100644
--- a/arch/arm64/include/asm/pgalloc.h
+++ b/arch/arm64/include/asm/pgalloc.h
@@ -35,15 +35,54 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte);
#if CONFIG_PGTABLE_LEVELS > 2
+/*
+ * FIXME: _workaround might not be the right suffix here but it does
+ * indicate the intent behind it. Generic pgtable_pmd_page_ctor/dtor
+ * constructs neither do account the PMD page towards NR_PAGETABLE
+ * nor do they update page state with the new page type PageTable.
+ * Ideally pgtable_pmd_page_ctor/dtor should have been just taking care
+ * of page->pmd_huge_pte when applicable along with what is already
+ * achieved with pgtable_page_ctor/dtor constructs. Unfortunately that
+ * is not the case currently and changing those generic mm constructs
+ * might impact other archs. For now lets do the right thing here and
+ * drop this when generic PMD constructs accommodate required changes.
+ */
+#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS
+static inline void pgtable_pmd_page_ctor_workaround(struct page *page)
+{
+ page->pmd_huge_pte = NULL;
+}
+
+static inline void pgtable_pmd_page_dtor_workaround(struct page *page)
+{
+ VM_BUG_ON_PAGE(page->pmd_huge_pte, page);
+}
+#else
+static inline void pgtable_pmd_page_ctor_workaround(struct page *page) { }
+static inline void pgtable_pmd_page_dtor_workaround(struct page *page) { }
+#endif
+
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
{
- return (pmd_t *)pte_alloc_one_virt(mm);
+ pgtable_t ptr;
+
+ ptr = pte_alloc_one(mm);
+ if (!ptr)
+ return 0;
+
+ pgtable_pmd_page_ctor_workaround(ptr);
+ return (pmd_t *)page_to_virt(ptr);
}
static inline void pmd_free(struct mm_struct *mm, pmd_t *pmdp)
{
+ struct page *page;
+
BUG_ON((unsigned long)pmdp & (PAGE_SIZE-1));
- pte_free(mm, virt_to_page(pmdp));
+ page = virt_to_page(pmdp);
+
+ pgtable_pmd_page_dtor_workaround(page);
+ pte_free(mm, page);
}
static inline void __pud_populate(pud_t *pudp, phys_addr_t pmdp, pudval_t prot)
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2019-02-25 5:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-25 5:03 [PATCH V2 0/6] arm64/mm: Enable accounting for page table pages Anshuman Khandual
2019-02-25 5:03 ` [PATCH V2 1/6] KVM: ARM: Remove pgtable standard functions from stage-2 page tables Anshuman Khandual
2019-02-25 11:00 ` Mark Rutland
2019-02-25 14:20 ` Anshuman Khandual
2019-02-25 15:49 ` Mark Rutland
2019-02-26 4:15 ` Anshuman Khandual
2019-02-26 8:51 ` Anshuman Khandual
2019-02-25 5:03 ` [PATCH V2 2/6] arm64/mm: Make pgd_pgtable_alloc() call pte_alloc_one() always Anshuman Khandual
2019-02-25 11:08 ` Mark Rutland
2019-02-25 14:41 ` Anshuman Khandual
2019-02-25 5:03 ` [PATCH V2 3/6] arm64/mm: Make all page table pages cycles through standard constructs Anshuman Khandual
2019-02-25 5:03 ` [PATCH V2 4/6] arm64/mm: Call pgtable_page_dtor() for both PMD and PUD page table pages Anshuman Khandual
2019-02-25 5:03 ` [PATCH V2 5/6] arm64/mm: Enable page table page accounting for user space Anshuman Khandual
2019-02-25 11:11 ` Mark Rutland
2019-02-25 14:49 ` Anshuman Khandual
2019-02-25 15:35 ` Mark Rutland
2019-02-26 5:06 ` Anshuman Khandual
2019-02-26 6:37 ` Anshuman Khandual
2019-02-25 5:03 ` Anshuman Khandual [this message]
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=1551071039-20192-7-git-send-email-anshuman.khandual@arm.com \
--to=anshuman.khandual@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Steve.Capper@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will.deacon@arm.com \
--cc=yuzhao@google.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;
as well as URLs for NNTP newsgroup(s).