From patchwork Thu Feb 6 14:16:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 24260 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CDAF820143 for ; Thu, 6 Feb 2014 14:20:49 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id i4sf9882222oah.3 for ; Thu, 06 Feb 2014 06:20:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=hjYJpUa0UzYuaR/AW19PsVv5BNu1VNcMAc8HJ3gIi8k=; b=IkWyqI9dv75nv2UDm4OJWv2BU3wN4TK++xhABqblD1AmpuJ8Jbn2S+eSB9OkFNAUK+ SvlOg32KmOA/7tGDYYtgSgInegV07XAaTCSis3tH2DfINYGJWbLTXikBBGm5/a2uySEf aBZoeweMZx90H/uCc/Igv2zf32oJL6hoXXloIsRb/7Tknd/0dCV0Pa9GlY6Hf5gdGavd gzZkbGYNcAGjpS8509c69dPmYfYzuBII2bgmeFS3ZgEwCznTbhc4AWpYERJ5DMkGDmKq OtNKzsv1VyKf7aITqAQiBpdH+dgK64fZDtib3BZ8e3v4+Tk+o0S6nA/3AQSLyFlTaAiK 2EPQ== X-Gm-Message-State: ALoCoQkgH3+frowTDw68eTVt02P4Jxbf7Nyoq2/GD+3XnMu1J4yAb1fXe31zqkfardVUmPihWzQB X-Received: by 10.50.21.3 with SMTP id r3mr276160ige.4.1391696448869; Thu, 06 Feb 2014 06:20:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.195 with SMTP id 61ls557450qgv.19.gmail; Thu, 06 Feb 2014 06:20:48 -0800 (PST) X-Received: by 10.58.200.168 with SMTP id jt8mr928201vec.30.1391696448641; Thu, 06 Feb 2014 06:20:48 -0800 (PST) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id yj2si281543veb.85.2014.02.06.06.20.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Feb 2014 06:20:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id jx11so1550894veb.10 for ; Thu, 06 Feb 2014 06:20:48 -0800 (PST) X-Received: by 10.52.118.33 with SMTP id kj1mr1268483vdb.33.1391696448395; Thu, 06 Feb 2014 06:20:48 -0800 (PST) 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.174.196 with SMTP id u4csp16385vcz; Thu, 6 Feb 2014 06:20:47 -0800 (PST) X-Received: by 10.180.37.178 with SMTP id z18mr21627204wij.46.1391696447251; Thu, 06 Feb 2014 06:20:47 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id x4si637803wjf.112.2014.02.06.06.20.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Feb 2014 06:20:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBPmR-0000Rj-7U; Thu, 06 Feb 2014 14:18:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBPlq-00009x-TY; Thu, 06 Feb 2014 14:17:38 +0000 Received: from mail-we0-f178.google.com ([74.125.82.178]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBPlY-0008UG-KX for linux-arm-kernel@lists.infradead.org; Thu, 06 Feb 2014 14:17:22 +0000 Received: by mail-we0-f178.google.com with SMTP id q59so1348555wes.9 for ; Thu, 06 Feb 2014 06:16:24 -0800 (PST) X-Received: by 10.194.22.129 with SMTP id d1mr6260278wjf.22.1391696183984; Thu, 06 Feb 2014 06:16:23 -0800 (PST) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id ci4sm2719045wjc.21.2014.02.06.06.16.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Feb 2014 06:16:23 -0800 (PST) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] arm64: mm: Route pmd thp functions through pte equivalents Date: Thu, 6 Feb 2014 14:16:10 +0000 Message-Id: <1391696171-8922-3-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391696171-8922-1-git-send-email-steve.capper@linaro.org> References: <1391696171-8922-1-git-send-email-steve.capper@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140206_091720_841187_83A9E891 X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.178 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: catalin.marinas@arm.com, will.deacon@arm.com, Steve Capper , linux@arm.linux.org.uk X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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.128.179 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 Rather than have separate hugetlb and transparent huge page pmd manipulation functions, re-wire our thp functions to simply call the pte equivalents. This allows THP to take advantage of the new PTE_WRITE logic introduced in: c2c93e5 arm64: mm: Introduce PTE_WRITE To represent splitting THPs we use the PTE_SPECIAL bit as this is not used for pmds. Signed-off-by: Steve Capper --- arch/arm64/include/asm/pgtable.h | 67 +++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index a3fb1e4..a5d5832 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -228,59 +228,65 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, #define __HAVE_ARCH_PTE_SPECIAL /* - * Software PMD bits for THP - */ - -#define PMD_SECT_DIRTY (_AT(pmdval_t, 1) << 55) -#define PMD_SECT_SPLITTING (_AT(pmdval_t, 1) << 57) - -/* * THP definitions. */ -#define pmd_young(pmd) (pmd_val(pmd) & PMD_SECT_AF) - #define __HAVE_ARCH_PMD_WRITE -#define pmd_write(pmd) (!(pmd_val(pmd) & PMD_SECT_RDONLY)) +static inline long pmd_write(pmd_t pmd) +{ + pte_t pte = __pte(pmd_val(pmd)); + return pte_write(pte); +} #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define pmd_trans_huge(pmd) (pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT)) -#define pmd_trans_splitting(pmd) (pmd_val(pmd) & PMD_SECT_SPLITTING) + +static inline long pmd_trans_splitting(pmd_t pmd) +{ + pte_t pte = __pte(pmd_val(pmd)); + return pte_special(pte); +} #endif +static inline long pmd_young(pmd_t pmd) +{ + pte_t pte = __pte(pmd_val(pmd)); + return pte_young(pte); +} + static inline pmd_t pmd_wrprotect(pmd_t pmd) { - pmd_val(pmd) |= PMD_SECT_RDONLY; - return pmd; + pte_t pte = pte_wrprotect(__pte(pmd_val(pmd))); + return __pmd(pte_val(pte)); } static inline pmd_t pmd_mkold(pmd_t pmd) { - pmd_val(pmd) &= ~PMD_SECT_AF; - return pmd; + pte_t pte = pte_mkold(__pte(pmd_val(pmd))); + return __pmd(pte_val(pte)); } static inline pmd_t pmd_mksplitting(pmd_t pmd) { - pmd_val(pmd) |= PMD_SECT_SPLITTING; - return pmd; + pte_t pte = pte_mkspecial(__pte(pmd_val(pmd))); + return __pmd(pte_val(pte)); } static inline pmd_t pmd_mkwrite(pmd_t pmd) { - pmd_val(pmd) &= ~PMD_SECT_RDONLY; - return pmd; + pte_t pte = pte_mkwrite(__pte(pmd_val(pmd))); + return __pmd(pte_val(pte)); } static inline pmd_t pmd_mkdirty(pmd_t pmd) { - pmd_val(pmd) |= PMD_SECT_DIRTY; - return pmd; + pte_t pte = pte_mkdirty(__pte(pmd_val(pmd))); + return __pmd(pte_val(pte)); } static inline pmd_t pmd_mkyoung(pmd_t pmd) { - pmd_val(pmd) |= PMD_SECT_AF; - return pmd; + pte_t pte = pte_mkyoung(__pte(pmd_val(pmd))); + return __pmd(pte_val(pte)); } static inline pmd_t pmd_mknotpresent(pmd_t pmd) @@ -297,15 +303,6 @@ static inline pmd_t pmd_mknotpresent(pmd_t pmd) #define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) -static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) -{ - const pmdval_t mask = PMD_SECT_USER | PMD_SECT_PXN | PMD_SECT_UXN | - PMD_SECT_RDONLY | PMD_SECT_PROT_NONE | - PMD_SECT_VALID; - pmd_val(pmd) = (pmd_val(pmd) & ~mask) | (pgprot_val(newprot) & mask); - return pmd; -} - #define set_pmd_at(mm, addr, pmdp, pmd) set_pmd(pmdp, pmd) static inline int has_transparent_hugepage(void) @@ -414,6 +411,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) return pte; } +static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) +{ + pte_t pte = pte_modify(__pte(pmd_val(pmd)), newprot); + return __pmd(pte_val(pte)); +} + extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; extern pgd_t idmap_pg_dir[PTRS_PER_PGD];