From patchwork Wed Apr 16 11:46:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 28460 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4F7AB2036A for ; Wed, 16 Apr 2014 11:47:56 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf57484516oag.4 for ; Wed, 16 Apr 2014 04:47:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=ylbGq03974gcUxdU/mTaXsK40HUL3EF6GmsmMlDVK5o=; b=hCjVqrYpXK2AlIQifYRrBBfyOblpEtl9ecVqV/tY2H8VkDtWyaWqlhSWaUdDiI66cH r+IhIDwJLTU4dxTK9qrkN48ki8H0YXifLyeIadj/PMngo1qS2m8FG/dxJmm4gYwcEQoJ dp2oLLMVjsLo75rGW0bPSJUo06bdRGOjBt0zAQkFA18bIwtsHlIJt3tdAd9/Q+8tW1j5 UTeguzn5VpLYzcjsxRcIS3hPK6nnyc2GYA56up9IpuBCIcmfcSNfHty5MVrmnEfIQdr4 djIlCsIz3Usp3y8bORrNZTuE7FDwct+P4UN+KrlDw/Zm+8+ZbFiofPHxxWJ2MrYSsrA6 bQYg== X-Gm-Message-State: ALoCoQn0wyAVwL6+dEhhrGgcEMtv1mbq+E1BGOjWgkXuVcZIkB+slWnxj3pXzCQ2NJHsPjB76UZd X-Received: by 10.182.28.99 with SMTP id a3mr3749420obh.40.1397648874953; Wed, 16 Apr 2014 04:47:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.229 with SMTP id o92ls550034qge.95.gmail; Wed, 16 Apr 2014 04:47:54 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr2665584vcx.7.1397648874728; Wed, 16 Apr 2014 04:47:54 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id vd8si3821272vdc.196.2014.04.16.04.47.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 04:47:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so10399504vcb.2 for ; Wed, 16 Apr 2014 04:47:54 -0700 (PDT) X-Received: by 10.220.59.65 with SMTP id k1mr1733396vch.22.1397648874651; Wed, 16 Apr 2014 04:47:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp305504vcb; Wed, 16 Apr 2014 04:47:54 -0700 (PDT) X-Received: by 10.68.196.137 with SMTP id im9mr7865730pbc.105.1397648873911; Wed, 16 Apr 2014 04:47:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ai4si7992599pbd.125.2014.04.16.04.47.53; Wed, 16 Apr 2014 04:47:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756191AbaDPLrg (ORCPT + 26 others); Wed, 16 Apr 2014 07:47:36 -0400 Received: from mail-we0-f175.google.com ([74.125.82.175]:57245 "EHLO mail-we0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756017AbaDPLq7 (ORCPT ); Wed, 16 Apr 2014 07:46:59 -0400 Received: by mail-we0-f175.google.com with SMTP id q58so10522255wes.6 for ; Wed, 16 Apr 2014 04:46:58 -0700 (PDT) X-Received: by 10.181.9.65 with SMTP id dq1mr7109327wid.51.1397648818089; Wed, 16 Apr 2014 04:46:58 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id mw4sm24116996wib.12.2014.04.16.04.46.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Apr 2014 04:46:57 -0700 (PDT) From: Steve Capper To: linux@arm.linux.org.uk, akpm@linux-foundation.org Cc: will.deacon@arm.com, catalin.marinas@arm.com, robherring2@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gerald.schaefer@de.ibm.com, Steve Capper Subject: [PATCH V2 5/5] arm: mm: Add Transparent HugePage support for non-LPAE Date: Wed, 16 Apr 2014 12:46:43 +0100 Message-Id: <1397648803-15961-6-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397648803-15961-1-git-send-email-steve.capper@linaro.org> References: <1397648803-15961-1-git-send-email-steve.capper@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Much of the required code for THP has been implemented in the earlier non-LPAE HugeTLB patch. One more domain bit is used (to store whether or not the THP is splitting). Some THP helper functions are defined; and we have to re-define pmd_page such that it distinguishes between page tables and sections. Signed-off-by: Steve Capper --- arch/arm/Kconfig | 2 +- arch/arm/include/asm/pgtable-2level.h | 32 ++++++++++++++++++++++++++++++++ arch/arm/include/asm/pgtable-3level.h | 1 + arch/arm/include/asm/pgtable.h | 2 -- arch/arm/include/asm/tlb.h | 3 +++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5e80fad..f5d4354 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1836,7 +1836,7 @@ config SYS_SUPPORTS_HUGETLBFS config HAVE_ARCH_TRANSPARENT_HUGEPAGE def_bool y - depends on ARM_LPAE + depends on SYS_SUPPORTS_HUGETLBFS config ARCH_WANT_GENERAL_HUGETLB def_bool y diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index 323e19f..bc1a7b8 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -212,6 +212,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) */ #define PMD_DSECT_DIRTY (_AT(pmdval_t, 1) << 5) #define PMD_DSECT_AF (_AT(pmdval_t, 1) << 6) +#define PMD_DSECT_SPLITTING (_AT(pmdval_t, 1) << 7) #define PMD_BIT_FUNC(fn,op) \ static inline pmd_t pmd_##fn(pmd_t pmd) { pmd_val(pmd) op; return pmd; } @@ -232,6 +233,16 @@ extern pgprot_t get_huge_pgprot(pgprot_t newprot); #define pfn_pmd(pfn,prot) __pmd(__pfn_to_phys(pfn) | pgprot_val(prot)); #define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),get_huge_pgprot(prot)); +#define pmd_mkhuge(pmd) (pmd) + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define pmd_trans_splitting(pmd) (pmd_val(pmd) & PMD_DSECT_SPLITTING) +#define pmd_trans_huge(pmd) (pmd_thp_or_huge(pmd)) +#else +static inline int pmd_trans_huge(pmd_t pmd); +#endif + +#define pmd_mknotpresent(pmd) (__pmd(0)) PMD_BIT_FUNC(mkdirty, |= PMD_DSECT_DIRTY); PMD_BIT_FUNC(mkwrite, |= PMD_SECT_AP_WRITE); @@ -239,6 +250,8 @@ PMD_BIT_FUNC(wrprotect, &= ~PMD_SECT_AP_WRITE); PMD_BIT_FUNC(mknexec, |= PMD_SECT_XN); PMD_BIT_FUNC(rmprotnone, |= PMD_TYPE_SECT); PMD_BIT_FUNC(mkyoung, |= PMD_DSECT_AF); +PMD_BIT_FUNC(mkold, &= ~PMD_DSECT_AF); +PMD_BIT_FUNC(mksplitting, |= PMD_DSECT_SPLITTING); #define pmd_young(pmd) (pmd_val(pmd) & PMD_DSECT_AF) #define pmd_write(pmd) (pmd_val(pmd) & PMD_SECT_AP_WRITE) @@ -279,6 +292,25 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) return pmd; } +static inline int has_transparent_hugepage(void) +{ + return 1; +} + +static inline struct page *pmd_page(pmd_t pmd) +{ + /* + * for a section, we need to mask off more of the pmd + * before looking up the page as it is a section descriptor. + * + * pmd_page only gets sections from the thp code. + */ + if (pmd_trans_huge(pmd)) + return (phys_to_page(pmd_val(pmd) & HPAGE_MASK)); + + return phys_to_page(pmd_val(pmd) & PHYS_MASK); +} + #endif /* __ASSEMBLY__ */ #endif /* _ASM_PGTABLE_2LEVEL_H */ diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index a4b71c1..82c61d6 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -214,6 +214,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_hugewillfault(pmd) (!pmd_young(pmd) || !pmd_write(pmd)) #define pmd_thp_or_huge(pmd) (pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT)) +#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define pmd_trans_huge(pmd) (pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT)) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index 576511f2..95f1909 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -189,8 +189,6 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd) return __va(pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK); } -#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) - #ifndef CONFIG_HIGHPTE #define __pte_map(pmd) pmd_page_vaddr(*(pmd)) #define __pte_unmap(pte) do { } while (0) diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h index b2498e6..77037d9 100644 --- a/arch/arm/include/asm/tlb.h +++ b/arch/arm/include/asm/tlb.h @@ -218,6 +218,9 @@ static inline void tlb_remove_pmd_tlb_entry(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { tlb_add_flush(tlb, addr); +#ifndef CONFIG_ARM_LPAE + tlb_add_flush(tlb, addr + SZ_1M); +#endif } #define pte_free_tlb(tlb, ptep, addr) __pte_free_tlb(tlb, ptep, addr)