From patchwork Wed Dec 20 04:00:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 181438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2403171dyi; Tue, 19 Dec 2023 20:01:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJIZBxCiZ+KHRZFWtkCY80cyuJfFWO44scWdNa/COLM8WXL4DnkLgzKTGkmRjCGWbQDtL1 X-Received: by 2002:a05:620a:88b:b0:781:149f:4e65 with SMTP id b11-20020a05620a088b00b00781149f4e65mr47531qka.39.1703044893732; Tue, 19 Dec 2023 20:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703044893; cv=none; d=google.com; s=arc-20160816; b=dfHro0afivpDH7Lxj8WwVB0LyIDvIJUu2VSV6l9bBoAzariPJvYpVg/RQMY/kCLmbs MWRqY0JbLmbZej+rZCaf8Y2d2IpNg7abMYoF4wKJxdJ0qQiwPu3km0KkfqJ5qMKhdeBe dRLodvVOL/pRJ0gBfkgHPmVH49iOSRSA8QpH4AK2CTPnhpVaFScDndAlLnznw6UJKEfE ljGW+CsthmZE19+lFgZnWOn2IBoQI8KJtqJTZySoT+dU7u2GZy9vg9Sh+PwhKLOM8IpH 5ZJ4WHOze2qFU0GdDvZwR2AnAFNaj+mf3p7HN1RzK6FwbDJrTGVcPSIBcLvpO7psEyt0 2vaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=wTWOqyfMsQnqPpUH1dExxKEsGutDkMUJttQEhdAsH5o=; fh=COwL00CAVvf6HClNn9uW/acbdshq5DvvB3VM/yZ8sXw=; b=m3yHk6qQSN+oSLi26nUIAPPLkjMN4IlNhAffcasZMxHVIXR+cLqWian496eJIWTPQ7 K+SxIDNzkk+H9g/D5437lweiqoY1y9gFkEeTf6szT2wGEJ4R75MZRfxYi5+uE7KSkr3l IxWNb5gQ3k+0I85WnKsD8QzFVnnBsboKEEOd5u6/JWvF++rOdSeiTMYDQ2PuOX9OBvFq xzFqUkPZKTqXx2yP3m7SmEEiC0YXAZb7AiUVJPG9tSpQ6ZZwCCM93YwacotAtgrVKlcV 2xlk/bAmO5HBFtD5UUchxrDm0O1KWWaxpUwVvj6de61CTXcx1PXSwDduamjXRNowFc6s N7sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rKsaJcrs; spf=pass (google.com: domain of linux-kernel+bounces-6342-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6342-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s12-20020a05620a29cc00b0077dc3ad1272si28839984qkp.299.2023.12.19.20.01.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6342-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rKsaJcrs; spf=pass (google.com: domain of linux-kernel+bounces-6342-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6342-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 73CB21C2507B for ; Wed, 20 Dec 2023 04:01:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE8FB125AB; Wed, 20 Dec 2023 04:01:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rKsaJcrs" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D41BE5B for ; Wed, 20 Dec 2023 04:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1d3eaaaa5a1so2647365ad.1 for ; Tue, 19 Dec 2023 20:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703044864; x=1703649664; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wTWOqyfMsQnqPpUH1dExxKEsGutDkMUJttQEhdAsH5o=; b=rKsaJcrs2dUuxSvmCFXLFOs5pp/EKpnYlSytbzq40qviYj5P8OE4xtUbMdScUirWtS 8cPz3NvuxxGNJ1XvEaF9o8H3HWRK4ZvBtrnqu0qy1VT3aMdCqUBOnYs4MPz30CMKmLjd g+xQ9bsoOS5a5ckqIoyV9K1KhTEiCb5ucyNBkDRKTDlUshmj2DwIkcB4yKotYAPMPLzA FfWHpt+N/6h9o0pNMWELO2yQNG7lKsOeUUOHKYlvDrJS4Lt1Vf/YQ/EcHwF0Yh7WXQSl npgnLR6TuAvicKqcomM3A77Tr1G2ySVVRYkcHzc89JLGgQGMmJANk+kdR38rymlD/kSd IOpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703044864; x=1703649664; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wTWOqyfMsQnqPpUH1dExxKEsGutDkMUJttQEhdAsH5o=; b=QCqPOErpm6udlZuL+zfkiJbNF8Rd2siQ2L9ChPFJIt89+B1TW+1e9b/7LfhSYGyCDZ jhLSuoyzNjfSZLEToXBlG7rBcCOEIQMng02OEFXzra8SaDVkkQxH53MoDqhuBKXMOQHl DOZPlVjyANPtDmQdzncBdC0RCa6Tg3TFadia3ShG90KiFlptBx52XyD0BtuNjw9nK2Ad TXPdstIkCVOhtO1j22GzPME4NabeZD3G2mmHt1rVLnK95d9+pIezuID/R3hwEtL8fp7y 0CpDFs/wIZdWLNll9NYC/IDOvj6PDJ+DmizkuRllc8i4lhL8hymAk5MsUG9woYjZ6bkY 17aA== X-Gm-Message-State: AOJu0YxKVkilAiYReGDbpfcH+tJlT+FaRy4NZ4840Yo5BWiu05qKqrhQ C+x/t3ntt0BqOT9oXvqbJj3VYgf8V6dDbw== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a17:902:da85:b0:1d0:4246:90b1 with SMTP id j5-20020a170902da8500b001d0424690b1mr110279plx.0.1703044864390; Tue, 19 Dec 2023 20:01:04 -0800 (PST) Date: Wed, 20 Dec 2023 04:00:34 +0000 In-Reply-To: <20231220040037.883811-1-kinseyho@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231220040037.883811-1-kinseyho@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231220040037.883811-2-kinseyho@google.com> Subject: [PATCH mm-unstable v1 1/4] mm/mglru: add CONFIG_ARCH_HAS_HW_PTE_YOUNG From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuzhao@google.com, Kinsey Ho , Aneesh Kumar K V X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785772002462717741 X-GMAIL-MSGID: 1785772002462717741 Some architectures are able to set the accessed bit in PTEs when PTEs are used as part of linear address translations. Add CONFIG_ARCH_HAS_HW_PTE_YOUNG for such architectures to be able to override arch_has_hw_pte_young(). Signed-off-by: Kinsey Ho Co-developed-by: Aneesh Kumar K V Signed-off-by: Aneesh Kumar K V --- arch/Kconfig | 8 ++++++++ arch/arm64/Kconfig | 1 + arch/x86/Kconfig | 1 + arch/x86/include/asm/pgtable.h | 6 ------ include/linux/pgtable.h | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index f4b210ab0612..8c8901f80586 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1470,6 +1470,14 @@ config DYNAMIC_SIGFRAME config HAVE_ARCH_NODE_DEV_GROUP bool +config ARCH_HAS_HW_PTE_YOUNG + bool + help + Architectures that select this option are capable of setting the + accessed bit in PTE entries when using them as part of linear address + translations. Architectures that require runtime check should select + this option and override arch_has_hw_pte_young(). + config ARCH_HAS_NONLEAF_PMD_YOUNG bool help diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b071a00425d..12d611f3da5d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -36,6 +36,7 @@ config ARM64 select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_DEVMAP select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_HW_PTE_YOUNG select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_DIRECT_MAP select ARCH_HAS_SET_MEMORY diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1566748f16c4..04941a1ffc0a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -88,6 +88,7 @@ config X86 select ARCH_HAS_PMEM_API if X86_64 select ARCH_HAS_PTE_DEVMAP if X86_64 select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_HW_PTE_YOUNG select ARCH_HAS_NONLEAF_PMD_YOUNG if PGTABLE_LEVELS > 2 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 select ARCH_HAS_COPY_MC if X86_64 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 57bab91bbf50..08b5cb22d9a6 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1679,12 +1679,6 @@ static inline bool arch_has_pfn_modify_check(void) return boot_cpu_has_bug(X86_BUG_L1TF); } -#define arch_has_hw_pte_young arch_has_hw_pte_young -static inline bool arch_has_hw_pte_young(void) -{ - return true; -} - #define arch_check_zapped_pte arch_check_zapped_pte void arch_check_zapped_pte(struct vm_area_struct *vma, pte_t pte); diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index af7639c3b0a3..9ecc20fa6269 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -375,7 +375,7 @@ static inline bool arch_has_hw_nonleaf_pmd_young(void) */ static inline bool arch_has_hw_pte_young(void) { - return false; + return IS_ENABLED(CONFIG_ARCH_HAS_HW_PTE_YOUNG); } #endif