From nobody Sun Feb 8 04:13:18 2026 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 A207323D7FF for ; Fri, 19 Dec 2025 06:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766124192; cv=none; b=QOrrZIR7IdShI8AHojdhqDNcn/9MXbLBltb+XkYWv1YsdJRGGHt3lTYkII/S+5iKm18+yIyZbidpR0DhM5rNxKMlP/sXyQtEPd/w4Gh3prGvwbW+kD0BnH86wKuGTsagPmcmAnF64cEh/4F7UalTP8IZqCr0UtqUjiS20fK4z9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766124192; c=relaxed/simple; bh=mqrLN8XeN/fcSfBXFbNfZKeOpM9SeOccw7eVUZvfxdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FYEQEXO5G9TK1YqXLpABmql3fjqbxfhUldP3OXaGbESy25AM3O5mRR5hhBhoQsb1xyKoQpn3ecHsztM54tTP+0pY1AL8CmwOWHgKJg7KM+20RbSFPsbTcMaqC7PEXgk6EhbdFMyPvjEWCY5MU8tKLRoI61tXbjzjXJ6q5ytKZV0= 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=rd5QCV6j; arc=none smtp.client-ip=115.124.30.119 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="rd5QCV6j" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1766124187; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=cx0gBasjhco1rzxEYEyLJsADnhZt08xD0/YXyn0KOfU=; b=rd5QCV6jEHVtddRkvbXhN6wRi2bJQPZne+D0Rv25WV8jpBdjBnumcsrT5Ilx3hJCtB1LExOenINCp/Nn5r2aICHwvApyUPMpfOZCKoeLn8xPRaYSnNkOfSDWmtgu9npHk8kQnr+DP3PAsXTrrz7osm1khUoPzGgKNcYl4++K3yY= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WvBV0.._1766124184 cluster:ay36) by smtp.aliyun-inc.com; Fri, 19 Dec 2025 14:03:05 +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 v3 2/5] arm64: mm: factor out the address and ptep alignment into a new helper Date: Fri, 19 Dec 2025 14:02:52 +0800 Message-ID: <8606e13617bb8ec302806a6ebdbe5f680e4466a4.1766121341.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 --- 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 c0557945939c..c73e77207584 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