From nobody Sun Feb 8 00:50:25 2026 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EC9917A303 for ; Tue, 23 Dec 2025 05:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766468935; cv=none; b=shAaBRdDR9zqg3MavA0uiAWhcqza1gfgP8CB6mf0qik9T0TPjwZNzfL9sJnF/dwLAPoPUuOyB30HCqglJdDYuLN92E8umViAO94YWA5LhqYXP4PcM/PANgRUeKiR41XPH2LrqCamerSzh/vv5nmx/FdTVI1AC30NIT8VDd1+waA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766468935; c=relaxed/simple; bh=NKI5nbUjfI6CU3Y3XlRYxpndvWz8/a7qjNELYOTUh/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eZHglitu2zfkiymIK/RK+KrSCaSGKgszF3dD/4G02GrcjBCf3kkIr9CB+U+lh0fbFIYF8EHA1EqKebEUrDhTZ55d91FrH4wXsuyjYjDFBSRiVlmx5BlGEEYN3QMZb1XAkUpmEHCWI5BOnKBeRWhshT+GCyW7IwoEY3Mo8W/TvME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=lccI3o52; arc=none smtp.client-ip=115.124.30.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="lccI3o52" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1766468929; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=+a78DMtklkrNbj5wKq84JjELX4bL639or56rrqyDL8M=; b=lccI3o52wq33fTkG6PUxq+hAgd5UzvDf6wJxQy6PMOK+O7RchlrQNVMUGnZFMEpyK/PKoA5Uxv2bwiaxuuLFaVo0kH1gY4D/USksoLiah5Yn5aeoMep+ZGTJsA9w34MNFegvzfj7Pfg9Mt4kRy8lp7PAQXvHV/oeU1kMa8UIhr0= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WvWWGsJ_1766468926 cluster:ay36) by smtp.aliyun-inc.com; Tue, 23 Dec 2025 13:48:47 +0800 From: Baolin Wang To: akpm@linux-foundation.org, david@kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: lorenzo.stoakes@oracle.com, ryan.roberts@arm.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, willy@infradead.org, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/5] arm64: mm: factor out the address and ptep alignment into a new helper Date: Tue, 23 Dec 2025 13:48:36 +0800 Message-ID: <47e29030347c23ffce238ff5ed752da01a8cc7cb.1766455378.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Factor out the contpte block's address and ptep alignment into a new helper, and will be reused in the following patch. No functional changes. Signed-off-by: Baolin Wang Reviewed-by: Ryan Roberts --- arch/arm64/mm/contpte.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c index 589bcf878938..e4ddeb46f25d 100644 --- a/arch/arm64/mm/contpte.c +++ b/arch/arm64/mm/contpte.c @@ -26,6 +26,26 @@ static inline pte_t *contpte_align_down(pte_t *ptep) return PTR_ALIGN_DOWN(ptep, sizeof(*ptep) * CONT_PTES); } =20 +static inline pte_t *contpte_align_addr_ptep(unsigned long *start, + unsigned long *end, pte_t *ptep, + unsigned int nr) +{ + /* + * Note: caller must ensure these nr PTEs are consecutive (present) + * PTEs that map consecutive pages of the same large folio within a + * single VMA and a single page table. + */ + if (pte_cont(__ptep_get(ptep + nr - 1))) + *end =3D ALIGN(*end, CONT_PTE_SIZE); + + if (pte_cont(__ptep_get(ptep))) { + *start =3D ALIGN_DOWN(*start, CONT_PTE_SIZE); + ptep =3D contpte_align_down(ptep); + } + + return ptep; +} + static void contpte_try_unfold_partial(struct mm_struct *mm, unsigned long= addr, pte_t *ptep, unsigned int nr) { @@ -569,14 +589,7 @@ void contpte_clear_young_dirty_ptes(struct vm_area_str= uct *vma, unsigned long start =3D addr; unsigned long end =3D start + nr * PAGE_SIZE; =20 - if (pte_cont(__ptep_get(ptep + nr - 1))) - end =3D ALIGN(end, CONT_PTE_SIZE); - - if (pte_cont(__ptep_get(ptep))) { - start =3D ALIGN_DOWN(start, CONT_PTE_SIZE); - ptep =3D contpte_align_down(ptep); - } - + ptep =3D contpte_align_addr_ptep(&start, &end, ptep, nr); __clear_young_dirty_ptes(vma, start, ptep, (end - start) / PAGE_SIZE, fla= gs); } EXPORT_SYMBOL_GPL(contpte_clear_young_dirty_ptes); --=20 2.47.3