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: 12007065 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 5FC94C433DB for ; Fri, 8 Jan 2021 17:15:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1557523A00 for ; Fri, 8 Jan 2021 17:15:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1557523A00 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9E0FA6B02B2; Fri, 8 Jan 2021 12:15:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 96A956B02B9; Fri, 8 Jan 2021 12:15:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 834546B02BA; Fri, 8 Jan 2021 12:15:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 6413F6B02B2 for ; Fri, 8 Jan 2021 12:15:40 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 29C93180AD811 for ; Fri, 8 Jan 2021 17:15:40 +0000 (UTC) X-FDA: 77683259640.15.hook09_120947a274f4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id C18AD1814B0C1 for ; Fri, 8 Jan 2021 17:15:39 +0000 (UTC) X-HE-Tag: hook09_120947a274f4 X-Filterd-Recvd-Size: 3110 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 Jan 2021 17:15:38 +0000 (UTC) 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 Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , "Kirill A . Shutemov" , Linus Torvalds , Vinayak Menon , Hugh Dickins , kernel-team@android.com 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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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__ */