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: 3596351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AFDC9F382 for ; Thu, 6 Feb 2014 14:20:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 574DC20131 for ; Thu, 6 Feb 2014 14:20:03 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A90A2010B for ; Thu, 6 Feb 2014 14:20:02 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBPmP-0000Ri-06; Thu, 06 Feb 2014 14:18:14 +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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R4R+IGY8TVanCt+Fa2cq64HH58dwByasQ/5+BzElwJ4=; b=KBd0xeYGDtOpSdwa01pXk5FQTtkKb9Dn2X5c4q06OewIHoKKyPF7n1RDazLsa7TBo1 W7nKaBeZ1nYN+wYeAJUuabZn3VBEmaApzzg2hwDKMqhvl3hIwSPXimUbFZCVwNn+Upvj ISmuzluDTK746Wf9biLOX7Bd61+tklMSYu5YGTUVgWdzcw+bicas90UAU9ElvVkb94yz uIEarIoHIDNQqJ/WGXe2Ti1SrjZuE7DWgdi3imkq48HIAZdneEm0Q8qhfpkF5HRTzgIW ihWWJSF1sDZmi2/GqfVYGj19aLo0LU/kJC/yEocjbUAe4eTI6WnxcCt7YmV4wgPumT++ 5zLA== X-Gm-Message-State: ALoCoQmjCG0QKs3Jw9XmQZbXuyACG3zFk6jZUH4T06ZImVsPf0GolACOaDl1KgGdAZMNji6EWqnY 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 (--) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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];