From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 1707E1F9ECB for ; Wed, 24 Dec 2025 18:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766599623; cv=none; b=uY9kSfp2y6swTJP6UDUKsUmz569GxvHaiWsncm9ZknLzDz1E8TywfLeOaIGPtIaHSF5JRVli2TiQxe5L5z6yHlPtggjk0aushSqIjpeGyRqiJmreQhsf3Dw77s1R5LqIGNIqPut1NDUkm9mV0eLDvhVXNLXAnZHXM7eiS8iPJ2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766599623; c=relaxed/simple; bh=rmJxAKWIcxof/8I6ZEy9zgmGtni47icT0og6do2qM5E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QLm0LhDBdwFe7Fbk8epsZWcZ7OTJlqqPWpaZkbguzXCLGSdhYZxczVscEs7X5k13Kmyhx6AC9om1s9dUTSPXR0XdzFFPY8ksrE9m4HpsxUdPIvgNZIXXKSL3+LbWP3Amq8FM6LDNLpNJ9CqJf2CPZEvfhRe5ZOUPlWpe+HPEDTE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=hme0MOhh; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hme0MOhh" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BQKGjyZDvWvZ8jDpsdKnYLCVOQ+GPoRi6k3p/8BF64o=; b=hme0MOhhI8LkoVY2AKAI83bY+f bYGIZe2Psau5T4X/Mq5qWfMaSaNnf7PBGt9n6fieHQPZeonQVA7bO4Ch3IxwnduJly1SOxD8PVmYz mz8Y656AkSwn62wrheMHcaPvmfdgEO79CE/j4eFJzXcsuHe8kkHFPb001ggiwjnhcYwFy4eVWxcto DTKJjAMriEkEtEwqRnhY9KLYqGXooxFaSeb7kE1Eyp9M7F5StcbvJwNXhWpNLI83TLVnalli83fAD LcCxfhXHM26IkNGnUvr/V/oJbya7RQKcNzgHtn/wACQ9NP5JMeQRUdDI/gbM8w1SmARm3VMn9rpbi G8+i2ZpA==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vYTG4-0000000EYJO-32YH; Wed, 24 Dec 2025 18:06:48 +0000 Date: Wed, 24 Dec 2025 18:06:48 +0000 From: Matthew Wilcox To: David Laight Cc: Lance Yang , baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, akpm@linux-foundation.org, axelrasmussen@google.com, chandna.sahil@gmail.com, chengming.zhou@linux.dev, david@kernel.org, david@redhat.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, mhocko@suse.com, nphamcs@gmail.com, rppt@kernel.org, shakeel.butt@linux.dev, surenb@google.com, vbabka@suse.cz, weixugc@google.com, yosry.ahmed@linux.dev, yuanchu@google.com, zhengqi.arch@bytedance.com, Lance Yang Subject: Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary Message-ID: References: <62a2d7ba-e7c3-4153-b227-c08802ca9e1c@linux.alibaba.com> <20251224092332.53214-1-ioworker0@gmail.com> <20251224140829.2ec7bbae@pumpkin> 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: <20251224140829.2ec7bbae@pumpkin> On Wed, Dec 24, 2025 at 02:08:29PM +0000, David Laight wrote: > > > > +++ b/mm/pagewalk.c > > > > @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, > > > > static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, > > > > unsigned long end) > > > > { > > > > - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); > > > > - return boundary < end ? boundary : end; > > > > + return min(ALIGN(addr, huge_page_size(h)), end); > > > > } > > > > > > Please drop this patch from the mm-new branch, as it causes > > > 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging > > > when executing hugepage-vmemmap test, because the program falls into an > > > infinite loop in walk_hugetlb_range() and cannot break out. > > > > Good catch! The problem is that ALIGN() returns addr itself when already > > aligned, causing the infinite loop ... > > Using ALIGN(addr + 1, huge_page_size(h)) would work. > Although it could be (addr + 1) & ~huge_page_mask(h) which is probably > the easiest to understand. > Some of the 'helper' macros don't really make the code easier to read. > (And that includes a lot of uses of min().) Or we could go back to my original suggestion. https://lore.kernel.org/linux-mm/aRyOWrARRlUCeEz6@casper.infradead.org/ which was in v2: https://lore.kernel.org/linux-mm/f802959f58865371ba1b10081bced98e3784c5e4.1763796152.git.chandna.sahil@gmail.com/