Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp462944pxb; Fri, 8 Jan 2021 09:18:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwji1auaDdsnGBngS9ZkKA86fLAF85KM6taiSBBwGvS7uVFSAOhiB8MCqBSEz5j5UHcuyGF X-Received: by 2002:a17:907:2111:: with SMTP id qn17mr3106339ejb.525.1610126281443; Fri, 08 Jan 2021 09:18:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610126281; cv=none; d=google.com; s=arc-20160816; b=DUVO5WTwHaBQvyxZHIiLlv0A+Eaj6kZBgjYmF6iXghaFWJp4/YayLKRJXWlQ4mdB53 QCjyTjveeH1HBZbZBK2cFIjULSnA0WGgwErvpQtnmz0tnt+Ou9g3QJ0DQMp8N+fBRkNj 7PLXY/jv2I3RQIooE+kMUJwTGF3C9tY4iYXft1rrrbNPmf0Gyyycu5kidX1TXoYhm1fz XgvCMYtADTe0OBIrdsHhj4tu4gY5jP3hRqlNU51AD8bdM+Yh3F1tZ21/1qiqYhCZup7T qsV1OPqKExIOl+fHBg7VPg4GWgiH/Kz6STjlrnDWgre3L4+elGplRydadY2JfCprVxnZ gPgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JoyB+D4AK/Kb6T0F9Q4HAU1HXHzHoS9qOJO6LqPgRMs=; b=zO+vRmkxJ2WsA85P5CzAj+yooTGzh4IWyMtjMZ6oD1uD90Pu7gOnX3n+yEhOLhfEzF q7Gf4U5w4VLgVXFMWNh2GMmwqhWR80pIX8xv8mM67wk1lwofRLKpOtm851OkKznhmSxW lLOqCrMmbTASL6DwLo21PlBNvWywuqIfhWQ9fnrmAcuQk2XNv3Dcx8eithT9Dj0pJ2Mu Qf324TdzaMEAgvXPLIY8JwtBE5TaQyjuKSWlFDJ8Cafi/L+ZKjtaKe3l6G07cfFHGrFu 6vEck6bfOK78/FmFm4vNS7MaN0v24TabG7lOQ3kY5cO254/+rkJy5u/p/fDKrLvPo+m6 4Yfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W9nPI7iv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw23si3807851ejb.235.2021.01.08.09.17.37; Fri, 08 Jan 2021 09:18:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W9nPI7iv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbhAHRQS (ORCPT + 99 others); Fri, 8 Jan 2021 12:16:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:50686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728408AbhAHRQR (ORCPT ); Fri, 8 Jan 2021 12:16:17 -0500 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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__ */ -- 2.29.2.729.g45daf8777d-goog