From patchwork Fri Jan 8 17:15:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12007085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C660C433E0 for ; Fri, 8 Jan 2021 17:19:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B56792396F for ; Fri, 8 Jan 2021 17:19:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B56792396F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=o/3xS7Qchmj4lVycvY3qKhIAYf+NRWmtkgl3N4qhyu8=; b=OSsmlgBbU8lG9vl1+d4jTIuKj QAHugoXcE44Dbed2yERXMF8eFYT4c6O69wEslrWknwRsWv0UNKDuUpzwzJALj0wvnRP2gmuIu/2M+ fcZ2n0X/CgHW7Alk+qPd63UvExyC4arIhh5+59HKlYI2VFs7E6jIQGFbi5qcpRc1QhqHmCAArNwC9 kkTcS7Prr0dJW5DwnPTdT33nRJ1Mjb89Cx4HlDcrYlwkO4+oF3aYmQ51/31uBHG+a13AUo6MbuybZ Rzzy2JRZOgsznvB1mmd72m0jdpXAIr5qDkvK6uSk4wMJPyWKyU9CTiswshkfkwAscFS/RoTviFDEK vVxejWu/A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxvNp-00057k-AH; Fri, 08 Jan 2021 17:17:05 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxvMP-0004rW-Qw for linux-arm-kernel@lists.infradead.org; Fri, 08 Jan 2021 17:15:38 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 227E623A1D; Fri, 8 Jan 2021 17:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610126137; bh=a8XtFnA7Zvrd0DWLoNyieMx6jPLocftcZJUWhZ6r6ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W9nPI7ivwFyQT3P0dzQuu+zFqBTC4v2Wgv7wkX0WyHOzmeOnQYOmKVaQHDreD0RFh 0UFgmwKyA/o+dHv58kCLc7pdd9DTj6Rfki3fYqQ/ghiZiTQnbRGWExe0tWmjI+ynRr uGFzbQdWdameHsCIHXBXqhXL7ZaolzjQYGQXlzPQMHAvnHC0uw+ckErXkOc7s7RQ2D NX7Mh2z0TuDNU8YhSfJuB5D5cg+QaeKq7bFU2enyldXU8NtTZW/p/sFmYlSFvgVIek onUwKo5nbROA5DW3ShBzanFVGJP+D4+Lv0bBY1R7Yfw9zAQYFs3g+RiGAVy/2nowf8 ROpcP+z5L6/4w== From: Will Deacon To: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] arm64: mm: Implement arch_wants_old_prefaulted_pte() Date: Fri, 8 Jan 2021 17:15:17 +0000 Message-Id: <20210108171517.5290-4-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210108171517.5290-1-will@kernel.org> References: <20210108171517.5290-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210108_121537_978258_21564EFD X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Jan Kara , Minchan Kim , Catalin Marinas , Linus Torvalds , Hugh Dickins , linux-mm@kvack.org, Vinayak Menon , "Kirill A . Shutemov" , Andrew Morton , Will Deacon , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On CPUs with hardware AF/DBM, initialising prefaulted PTEs as 'old' improves vmscan behaviour and does not appear to introduce any overhead. Implement arch_wants_old_prefaulted_pte() to return 'true' if we detect hardware access flag support at runtime. This can be extended in future based on MIDR matching if necessary. Cc: Catalin Marinas Signed-off-by: Will Deacon --- arch/arm64/include/asm/pgtable.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 501562793ce2..e17b96d0e4b5 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -980,7 +980,17 @@ static inline bool arch_faults_on_old_pte(void) return !cpu_has_hw_af(); } -#define arch_faults_on_old_pte arch_faults_on_old_pte +#define arch_faults_on_old_pte arch_faults_on_old_pte + +/* + * Experimentally, it's cheap to set the access flag in hardware and we + * benefit from prefaulting mappings as 'old' to start with. + */ +static inline bool arch_wants_old_prefaulted_pte(void) +{ + return !arch_faults_on_old_pte(); +} +#define arch_wants_old_prefaulted_pte arch_wants_old_prefaulted_pte #endif /* !__ASSEMBLY__ */