From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BC72419D882; Wed, 19 Feb 2025 19:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991830; cv=none; b=U5QJkCWvhGfgMfKuJGI8ATBrzwDO59BciBdVtfkk5gcetfSjop5Iqxtz9k+z4NF0dZ8WaxF2pOCX+692J1bdGySQiqgKh6O0eqE3BJqKYQA8NYq5DY5nMoCzOIecXcGLLE9qe7oB1u6z/6GFLOOGrM2lt0LmoCZc9ihgv4+plNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739991830; c=relaxed/simple; bh=hV9RkYt4igjtnbWj+6XyMa9R2wiMLiWet1Pt7YOzH00=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GR0FWV8NA1krmnLkI44n0yjdacyu+GV2KkfbBe6UUjWXr6HRfUX4mhTJ4ACPgxNL/7tXg9S7MjYTB6Vs4d75wwLwcmGUpeerpc+c8knjSQ4yrZapL1NyA+ayNVpfc+rlgF+sbg9Q2AG15H0vGMZSis/ieasg0o8+RDPcouJ6Vqg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13436C4CED1; Wed, 19 Feb 2025 19:03:43 +0000 (UTC) Date: Wed, 19 Feb 2025 19:03:41 +0000 From: Catalin Marinas To: Ryan Roberts Cc: Will Deacon , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , "David S. Miller" , Andreas Larsson , Arnd Bergmann , Muchun Song , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , David Hildenbrand , "Matthew Wilcox (Oracle)" , Mark Rutland , Anshuman Khandual , Dev Jain , Kevin Brodsky , Alexandre Ghiti , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2 2/4] arm64: hugetlb: Fix huge_ptep_get_and_clear() for non-present ptes Message-ID: References: <20250217140419.1702389-1-ryan.roberts@arm.com> <20250217140419.1702389-3-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250217140419.1702389-3-ryan.roberts@arm.com> On Mon, Feb 17, 2025 at 02:04:15PM +0000, Ryan Roberts wrote: > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > index 06db4649af91..614b2feddba2 100644 > --- a/arch/arm64/mm/hugetlbpage.c > +++ b/arch/arm64/mm/hugetlbpage.c > @@ -163,24 +163,23 @@ static pte_t get_clear_contig(struct mm_struct *mm, > unsigned long pgsize, > unsigned long ncontig) > { > - pte_t orig_pte = __ptep_get(ptep); > - unsigned long i; > - > - for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) { > - pte_t pte = __ptep_get_and_clear(mm, addr, ptep); > - > - /* > - * If HW_AFDBM is enabled, then the HW could turn on > - * the dirty or accessed bit for any page in the set, > - * so check them all. > - */ > - if (pte_dirty(pte)) > - orig_pte = pte_mkdirty(orig_pte); > - > - if (pte_young(pte)) > - orig_pte = pte_mkyoung(orig_pte); > + pte_t pte, tmp_pte; > + bool present; > + > + pte = __ptep_get_and_clear(mm, addr, ptep); > + present = pte_present(pte); > + while (--ncontig) { A 'for' loop may be more consistent with the rest of the file but I really don't mind the 'while' loop. Reviewed-by: Catalin Marinas