Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp686430rdb; Fri, 2 Feb 2024 00:12:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8BnuDJtdo9NSGIcCyzXyIw51xi3V7iRMhR73jb/JAiPDIKkQ93D58IlAebXdWDyWRnjSN X-Received: by 2002:a50:cd94:0:b0:55f:ce14:337a with SMTP id p20-20020a50cd94000000b0055fce14337amr1309955edi.11.1706861547385; Fri, 02 Feb 2024 00:12:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706861547; cv=pass; d=google.com; s=arc-20160816; b=h8VVcDTeTC999XpokLHhP1kYkFsf8+6Ql7RYOaOVYj50ugr5RIVwBss49FUFIpQPtA hfv6AV+yzkKHFH/dSTB9D8m1yKFO69fnFCOrGUSLhPq4FLhMjU/KKt4cn9ffwnpvG0ce 7AU0gSI+Z06cJHb0m0RAXAUBjSa6e5NyVQFsN2AcKt2XwV7dnDpyVh3d6jGmqlgoDtkq 9jmKkeEXw1cKb1dYpdXNO/XvsgVodikoSxdfUXKamjlyi0hLX4U6trgVbAzu3808DAta ggH3vZQsAaaxY4H7w5PBzEsB0KznpJoonDmP8Uugybf+YtVurQZXA3eEqGVchU7ALB9j 1swA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ugmxcY8A+ihqkEHAUXwkD3Iz3A7BIhWHSuJUsSWcNFg=; fh=Vc1R9MUXv4bIVLrcETUey3uB75hGWOzgAokaFQlCWbg=; b=L6ixKK699MA/B3hE9SC3ZXE9h4kS+HjQ+NyqkqiRqqFeuRpdieDBYnC98q0g6oYCsx tq8PBBIfeJWt3uymbnWcLXrrNONYWT/NIaW8n8uX7oRZfg/dgCPJvImSuJTH2uj5vzPG KNx7mByEtd9EwrON60f/i4o4URJEW5qybuilKY82wVmg0a5CSMCV9HBmPjDKfFfyqWx2 unFIMcUF9HKY2clpslDiWB6DYco/EaXpR2ITKd7JbnjjCZgLvg/z3zoQ6LSIPvioJL3T ynA1CJ3ny82ekQPVmdo7AeN3OuZCkFo47ccVj8deKKLXE2y8D78qHhgO1WDE1rZOl5xU 1Auw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49425-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCV1DY7tp3qVBw1yPxAFRm+O+jxftPUCXp2EAtiRQU8oJIoLyOtkUs1TpfdmDs3WspKuBeHfyc0lR3G+kluenlzcCOHbfx6WKBjgyASVUg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x73-20020a50bacf000000b0055ef9e79403si590309ede.180.2024.02.02.00.12.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:12:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49425-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49425-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 896331F24A6A for ; Fri, 2 Feb 2024 08:12:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22B27481B7; Fri, 2 Feb 2024 08:09:05 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB84247F75 for ; Fri, 2 Feb 2024 08:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861344; cv=none; b=qFlosKVAOjmkyljUAXfM5Ruoes9rk5yEElBwAOYGnKbMf+kY5PirQveM9cVnQzDQpndFvma8/5eG6GJZahuZBa9dAnL0NYEyLlxWa0lcHm3Z35/3/sxy50YcxiwEiWyFLQgkPbSbS1pwjI+kE968JxLiI+26UIw4QRHVnGqNlvA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861344; c=relaxed/simple; bh=T+5tL5OaMcK45Qb1IdlrU27RwZpiR8LxzCR/Ab24cWc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JMMP4vdWolTCrqlURgZKEwE0GBJBVLqxevvd2Gpb/beDGcjRsmqAVnTHmLRweq+ARtbATP7hw/dOxwYKnPsYLUJZAyeSaFQq3bE+DDedGKvid67sG9bjqffBZVJ5shbERwKY0bGu+Hd4RhUlUOLnWJDwyEcs9BeSlwAx9mtrlw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70FC91A9A; Fri, 2 Feb 2024 00:09:44 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 852FB3F5A1; Fri, 2 Feb 2024 00:08:58 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 12/25] arm64/mm: ptep_get_and_clear(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:43 +0000 Message-Id: <20240202080756.1453939-13-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Create a new layer for the in-table PTE manipulation APIs. For now, The existing API is prefixed with double underscore to become the arch-private API and the public API is just a simple wrapper that calls the private API. The public API implementation will subsequently be used to transparently manipulate the contiguous bit where appropriate. But since there are already some contig-aware users (e.g. hugetlb, kernel mapper), we must first ensure those users use the private API directly so that the future contig-bit manipulations in the public API do not interfere with those existing uses. Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 5 +++-- arch/arm64/mm/hugetlbpage.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 3b0ff58109c5..5f560326116e 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -953,8 +953,7 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -#define __HAVE_ARCH_PTEP_GET_AND_CLEAR -static inline pte_t ptep_get_and_clear(struct mm_struct *mm, +static inline pte_t __ptep_get_and_clear(struct mm_struct *mm, unsigned long address, pte_t *ptep) { pte_t pte = __pte(xchg_relaxed(&pte_val(*ptep), 0)); @@ -1141,6 +1140,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #define set_pte __set_pte #define set_ptes __set_ptes #define pte_clear __pte_clear +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +#define ptep_get_and_clear __ptep_get_and_clear #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 3d73b83cf97f..7e74e7b67107 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -188,7 +188,7 @@ static pte_t get_clear_contig(struct mm_struct *mm, unsigned long i; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) { - pte_t pte = ptep_get_and_clear(mm, addr, ptep); + pte_t pte = __ptep_get_and_clear(mm, addr, ptep); /* * If HW_AFDBM is enabled, then the HW could turn on @@ -236,7 +236,7 @@ static void clear_flush(struct mm_struct *mm, unsigned long i, saddr = addr; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - ptep_clear(mm, addr, ptep); + __ptep_get_and_clear(mm, addr, ptep); flush_tlb_range(&vma, saddr, addr); } @@ -411,7 +411,7 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, pte_t orig_pte = ptep_get(ptep); if (!pte_cont(orig_pte)) - return ptep_get_and_clear(mm, addr, ptep); + return __ptep_get_and_clear(mm, addr, ptep); ncontig = find_num_contig(mm, addr, ptep, &pgsize); -- 2.25.1