From patchwork Fri Dec 13 19:05:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 22344 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 19CE0202E2 for ; Fri, 13 Dec 2013 19:06:07 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id i17sf3972940qcy.2 for ; Fri, 13 Dec 2013 11:06:06 -0800 (PST) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=kjKLNuVv95RtrwlmcFYJ0G0ZrU+ijy6+ZWKY/e1O190=; b=O2flgsmnSU70tZiJo+PiEM640eSQ4HAbyrvwgvKHPhZdBydHG66HhlspRuWN761iJf k7/3wGnQdRCNFrW6eCFOxgKt8TcBIqkXtXHXdF8ZHXA2mJTj01MRNnzRCy6stKFubVbP oeE4TF5RgMakCPwzi1gLBiIhgVZy1rDowVlO0YQXxSYFKrZrfAZLazsXSK16qCx5dWhl PTtk4ZWVXH7Znc7sm7kIgwWlcbP7yaKTUpmUrvKA/mHW3NK/WTKf2aPESbW1kwrUYpq1 rMWGJKUYvij0DPcuk/X+BHx5CfngXN7v13Smup3myrgaxBVUfJQ4eSLXeZiWD9qv6ccj tikw== X-Gm-Message-State: ALoCoQn61jF57OFqb+mxxGFeaGY66IUvCkAPTwBY/Uf12nKAHX4sn7FZEq0Hikg7wQP/0vy8t3rC X-Received: by 10.236.73.164 with SMTP id v24mr1318416yhd.24.1386961566946; Fri, 13 Dec 2013 11:06:06 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.237 with SMTP id y13ls1197389qeu.2.gmail; Fri, 13 Dec 2013 11:06:06 -0800 (PST) X-Received: by 10.58.216.133 with SMTP id oq5mr19333vec.80.1386961566777; Fri, 13 Dec 2013 11:06:06 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id pv1si1062747veb.18.2013.12.13.11.06.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 11:06:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id x11so1564925vbb.36 for ; Fri, 13 Dec 2013 11:06:06 -0800 (PST) X-Received: by 10.58.46.18 with SMTP id r18mr1951524vem.4.1386961566633; Fri, 13 Dec 2013 11:06:06 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp61448vcz; Fri, 13 Dec 2013 11:06:06 -0800 (PST) X-Received: by 10.180.39.177 with SMTP id q17mr4308499wik.16.1386961565519; Fri, 13 Dec 2013 11:06:05 -0800 (PST) Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by mx.google.com with ESMTPS id um9si1271646wjc.4.2013.12.13.11.06.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 11:06:05 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.41 is neither permitted nor denied by best guess record for domain of steve.capper@linaro.org) client-ip=74.125.82.41; Received: by mail-wg0-f41.google.com with SMTP id y10so2276217wgg.4 for ; Fri, 13 Dec 2013 11:06:05 -0800 (PST) X-Received: by 10.180.188.175 with SMTP id gb15mr4256376wic.50.1386961565086; Fri, 13 Dec 2013 11:06:05 -0800 (PST) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id o9sm289604wib.10.2013.12.13.11.06.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2013 11:06:04 -0800 (PST) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Cc: linux@arm.linux.org.uk, will.deacon@arm.com, catalin.marinas@arm.com, patches@linaro.org, robherring2@gmail.com, deepak.saxena@linaro.org, Steve Capper Subject: [RFC PATCH 6/6] arm: mm: Add Transparent HugePage support for non-LPAE Date: Fri, 13 Dec 2013 19:05:46 +0000 Message-Id: <1386961546-10061-7-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386961546-10061-1-git-send-email-steve.capper@linaro.org> References: <1386961546-10061-1-git-send-email-steve.capper@linaro.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.212.49 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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 | 34 ++++++++++++++++++++++++++++++++++ arch/arm/include/asm/pgtable-3level.h | 1 + arch/arm/include/asm/pgtable.h | 2 -- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2eeee73..f17f5c92 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1788,7 +1788,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 95ed36e..f7c2599 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -211,6 +211,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; } @@ -234,12 +235,25 @@ 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_large(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); 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(mkold, &= ~PMD_DSECT_AF); +PMD_BIT_FUNC(mksplitting, |= PMD_DSECT_SPLITTING); +PMD_BIT_FUNC(mkyoung, |= PMD_DSECT_AF); #define pmd_young(pmd) (pmd_val(pmd) & PMD_DSECT_AF) #define pmd_write(pmd) (pmd_val(pmd) & PMD_SECT_AP_WRITE) @@ -281,6 +295,26 @@ 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 520a875..4a3a256 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -215,6 +215,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_huge(pmd) || pmd_trans_huge(pmd)) +#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 9bd4046..361ca7c 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)