From: David Gibson <dwg@au1.ibm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: paulus@samba.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org
Subject: Re: [PATCH -V7 05/10] powerpc: Replace find_linux_pte with find_linux_pte_or_hugepte
Date: Fri, 3 May 2013 14:56:24 +1000 [thread overview]
Message-ID: <20130503045624.GQ13041@truffula.fritz.box> (raw)
In-Reply-To: <1367178711-8232-6-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 7612 bytes --]
On Mon, Apr 29, 2013 at 01:21:46AM +0530, Aneesh Kumar K.V wrote:
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>
> Replace find_linux_pte with find_linux_pte_or_hugepte and explicitly
> document why we don't need to handle transparent hugepages at callsites.
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/pgtable-ppc64.h | 24 ------------------------
> arch/powerpc/kernel/io-workarounds.c | 10 ++++++++--
> arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +-
> arch/powerpc/mm/hash_utils_64.c | 8 +++++++-
> arch/powerpc/mm/hugetlbpage.c | 8 ++++++--
> arch/powerpc/mm/tlb_hash64.c | 7 ++++++-
> arch/powerpc/platforms/pseries/eeh.c | 7 ++++++-
> 7 files changed, 34 insertions(+), 32 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
> index f0effab..97fc839 100644
> --- a/arch/powerpc/include/asm/pgtable-ppc64.h
> +++ b/arch/powerpc/include/asm/pgtable-ppc64.h
> @@ -343,30 +343,6 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
>
> void pgtable_cache_add(unsigned shift, void (*ctor)(void *));
> void pgtable_cache_init(void);
> -
> -/*
> - * find_linux_pte returns the address of a linux pte for a given
> - * effective address and directory. If not found, it returns zero.
> - */
> -static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
> -{
> - pgd_t *pg;
> - pud_t *pu;
> - pmd_t *pm;
> - pte_t *pt = NULL;
> -
> - pg = pgdir + pgd_index(ea);
> - if (!pgd_none(*pg)) {
> - pu = pud_offset(pg, ea);
> - if (!pud_none(*pu)) {
> - pm = pmd_offset(pu, ea);
> - if (pmd_present(*pm))
> - pt = pte_offset_kernel(pm, ea);
> - }
> - }
> - return pt;
> -}
> -
> pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
> unsigned *shift);
> #endif /* __ASSEMBLY__ */
> diff --git a/arch/powerpc/kernel/io-workarounds.c b/arch/powerpc/kernel/io-workarounds.c
> index 50e90b7..e5263ab 100644
> --- a/arch/powerpc/kernel/io-workarounds.c
> +++ b/arch/powerpc/kernel/io-workarounds.c
> @@ -55,6 +55,7 @@ static struct iowa_bus *iowa_pci_find(unsigned long vaddr, unsigned long paddr)
>
> struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr)
> {
> + unsigned shift;
> struct iowa_bus *bus;
> int token;
>
> @@ -70,11 +71,16 @@ struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr)
> if (vaddr < PHB_IO_BASE || vaddr >= PHB_IO_END)
> return NULL;
>
> - ptep = find_linux_pte(init_mm.pgd, vaddr);
> + ptep = find_linux_pte_or_hugepte(init_mm.pgd, vaddr, &shift);
> if (ptep == NULL)
> paddr = 0;
> - else
> + else {
> + /*
> + * we don't have hugepages backing iomem
> + */
> + BUG_ON(shift);
> paddr = pte_pfn(*ptep) << PAGE_SHIFT;
> + }
> bus = iowa_pci_find(vaddr, paddr);
>
> if (bus == NULL)
> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> index 19c93ba..8c345df 100644
> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> @@ -27,7 +27,7 @@ static void *real_vmalloc_addr(void *x)
> unsigned long addr = (unsigned long) x;
> pte_t *p;
>
> - p = find_linux_pte(swapper_pg_dir, addr);
> + p = find_linux_pte_or_hugepte(swapper_pg_dir, addr, NULL);
> if (!p || !pte_present(*p))
> return NULL;
> /* assume we don't have huge pages in vmalloc space... */
> diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
> index d0eb6d4..e942ae9 100644
> --- a/arch/powerpc/mm/hash_utils_64.c
> +++ b/arch/powerpc/mm/hash_utils_64.c
> @@ -1131,6 +1131,7 @@ EXPORT_SYMBOL_GPL(hash_page);
> void hash_preload(struct mm_struct *mm, unsigned long ea,
> unsigned long access, unsigned long trap)
> {
> + int shift;
> unsigned long vsid;
> pgd_t *pgdir;
> pte_t *ptep;
> @@ -1152,10 +1153,15 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
> pgdir = mm->pgd;
> if (pgdir == NULL)
> return;
> - ptep = find_linux_pte(pgdir, ea);
> + /*
> + * THP pages use update_mmu_cache_pmd. We don't do
> + * hash preload there. Hence can ignore THP here
> + */
> + ptep = find_linux_pte_or_hugepte(pgdir, ea, &shift);
> if (!ptep)
> return;
>
> + BUG_ON(shift);
> #ifdef CONFIG_PPC_64K_PAGES
> /* If either _PAGE_4K_PFN or _PAGE_NO_CACHE is set (and we are on
> * a 64K kernel), then we don't preload, hash_page() will take
> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
> index 081c001..1154714 100644
> --- a/arch/powerpc/mm/hugetlbpage.c
> +++ b/arch/powerpc/mm/hugetlbpage.c
> @@ -105,6 +105,7 @@ int pgd_huge(pgd_t pgd)
>
> pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
> {
> + /* Only called for HugeTLB pages, hence can ignore THP */
> return find_linux_pte_or_hugepte(mm->pgd, addr, NULL);
> }
>
> @@ -673,11 +674,14 @@ follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
> struct page *page;
> unsigned shift;
> unsigned long mask;
> -
> + /*
> + * Transparent hugepages are handled by generic code. We can skip them
> + * here.
> + */
> ptep = find_linux_pte_or_hugepte(mm->pgd, address, &shift);
>
> /* Verify it is a huge page else bail. */
> - if (!ptep || !shift)
> + if (!ptep || !shift || pmd_trans_huge((pmd_t)*ptep))
> return ERR_PTR(-EINVAL);
>
> mask = (1UL << shift) - 1;
> diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c
> index 023ec8a..56d9b85 100644
> --- a/arch/powerpc/mm/tlb_hash64.c
> +++ b/arch/powerpc/mm/tlb_hash64.c
> @@ -189,6 +189,7 @@ void tlb_flush(struct mmu_gather *tlb)
> void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
> unsigned long end)
> {
> + int shift;
> unsigned long flags;
>
> start = _ALIGN_DOWN(start, PAGE_SIZE);
> @@ -206,11 +207,15 @@ void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
> local_irq_save(flags);
> arch_enter_lazy_mmu_mode();
> for (; start < end; start += PAGE_SIZE) {
> - pte_t *ptep = find_linux_pte(mm->pgd, start);
> + pte_t *ptep = find_linux_pte_or_hugepte(mm->pgd, start, &shift);
> unsigned long pte;
>
> if (ptep == NULL)
> continue;
> + /*
> + * We won't find hugepages here, this is iomem.
> + */
Really? Why?
> + BUG_ON(shift);
> pte = pte_val(*ptep);
> if (!(pte & _PAGE_HASHPTE))
> continue;
> diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
> index 6b73d6c..d2e76d2 100644
> --- a/arch/powerpc/platforms/pseries/eeh.c
> +++ b/arch/powerpc/platforms/pseries/eeh.c
> @@ -258,12 +258,17 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
> */
> static inline unsigned long eeh_token_to_phys(unsigned long token)
> {
> + int shift;
> pte_t *ptep;
> unsigned long pa;
>
> - ptep = find_linux_pte(init_mm.pgd, token);
> + /*
> + * We won't find hugepages here, iomem
> + */
> + ptep = find_linux_pte_or_hugepte(init_mm.pgd, token, &shift);
> if (!ptep)
> return token;
> + BUG_ON(shift);
> pa = pte_pfn(*ptep) << PAGE_SHIFT;
>
> return pa | (token & (PAGE_SIZE-1));
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-05-03 5:30 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-28 19:51 [PATCH -V7 00/10] THP support for PPC64 (Patchset 2) Aneesh Kumar K.V
2013-04-28 19:51 ` [PATCH -V7 01/10] powerpc/THP: Double the PMD table size for THP Aneesh Kumar K.V
2013-05-03 3:21 ` David Gibson
2013-04-28 19:51 ` [PATCH -V7 02/10] powerpc/THP: Implement transparent hugepages for ppc64 Aneesh Kumar K.V
2013-05-03 4:52 ` David Gibson
2013-05-03 8:19 ` Benjamin Herrenschmidt
2013-05-03 11:54 ` David Gibson
2013-05-03 13:00 ` Benjamin Herrenschmidt
2013-05-03 18:54 ` Aneesh Kumar K.V
2013-05-04 19:14 ` Aneesh Kumar K.V
2013-05-04 21:39 ` Benjamin Herrenschmidt
2013-05-06 1:28 ` David Gibson
2013-04-28 19:51 ` [PATCH -V7 03/10] powerpc: move find_linux_pte_or_hugepte and gup_hugepte to common code Aneesh Kumar K.V
2013-04-28 19:51 ` [PATCH -V7 04/10] powerpc: Update find_linux_pte_or_hugepte to handle transparent hugepages Aneesh Kumar K.V
2013-05-03 4:53 ` David Gibson
2013-05-03 18:58 ` Aneesh Kumar K.V
2013-05-04 6:28 ` David Gibson
2013-04-28 19:51 ` [PATCH -V7 05/10] powerpc: Replace find_linux_pte with find_linux_pte_or_hugepte Aneesh Kumar K.V
2013-05-03 4:56 ` David Gibson [this message]
2013-04-28 19:51 ` [PATCH -V7 06/10] powerpc: Update gup_pmd_range to handle transparent hugepages Aneesh Kumar K.V
2013-05-03 4:57 ` David Gibson
2013-04-28 19:51 ` [PATCH -V7 07/10] powerpc/THP: Add code to handle HPTE faults for large pages Aneesh Kumar K.V
2013-05-03 5:13 ` David Gibson
2013-04-28 19:51 ` [PATCH -V7 08/10] powerpc/THP: Enable THP on PPC64 Aneesh Kumar K.V
2013-05-03 5:15 ` David Gibson
2013-05-03 18:49 ` Aneesh Kumar K.V
2013-05-05 8:59 ` David Gibson
2013-04-28 19:51 ` [PATCH -V7 09/10] powerpc: Optimize hugepage invalidate Aneesh Kumar K.V
2013-05-03 5:28 ` David Gibson
2013-05-03 19:05 ` Aneesh Kumar K.V
2013-05-03 21:54 ` Benjamin Herrenschmidt
2013-04-28 19:51 ` [PATCH -V7 10/10] powerpc: disable assert_pte_locked Aneesh Kumar K.V
2013-05-03 5:30 ` David Gibson
2013-05-03 19:07 ` Aneesh Kumar K.V
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=20130503045624.GQ13041@truffula.fritz.box \
--to=dwg@au1.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).