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 2505B247291 for ; Thu, 25 Dec 2025 09:32:55 +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=1766655176; cv=none; b=tiNTR3ULFsHNdABovZ8oJfzPYiG7s71OBKiNncRulQHdjhlGENN5OU6fkJlRgP8Ttlj8CoHQV1gQEVs3ZC8XYtXu45xSKcjlFFsI6aK9gzVQTBpdVv2RiLJaQsTo7sv23fvc53InTJuatFFnowd9Jfg13x3VOcAN41Jt6xkKrAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766655176; c=relaxed/simple; bh=crIs7Vpzht/pnJ1aDRt6pQoB0tVv3wmg1UPYo0oHvb8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MO/57/97Fv6a8d/i1xucsunMb/3muqr/ygxKEMpd8LNhlrdwVfEBoRBFjmQYFJsF7qnP432v99ZKCB8BRFnWgWL9+VfCj8FJifZpF85ztmT1RnWEmG2G3bd2/nxX0etIsVH0VGfp6YzYNzJQpYGg6xd6vcKq+Brx5HPiiIMYVOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFxu+XO1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jFxu+XO1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FD9CC4CEF1; Thu, 25 Dec 2025 09:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766655175; bh=crIs7Vpzht/pnJ1aDRt6pQoB0tVv3wmg1UPYo0oHvb8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jFxu+XO1h+7qVufOEkkeqYJ+y8+ggI/EjXBUiY3/m1mhMJxUKl5bfL1k03shi5Yqp E/ms3S/D3iMl+EDwHTlA2nFYMmWIjPZjxq96aUOCbpTwFo4YoOF243vMMb2Fs72paF kHChZbjIfDArAhQx6T3kZ36v5u0TWc3Tv+DAqgS8r9bW0zC/ZfFDyGRHRpuDyFFY+4 3oG0azPvSNPLXl1d2FTfy0zC2nRNzfYdMBdfX/7+5/rpfeSwCQfWqoQ+zbvfiWHbA8 a1VQXWYR7iLj7KpmMqOy5j0HxAa6841d/+J1EqPkgyePGGd6/Lbias2aaqFYVk92xZ K8dBSkuie0qYQ== Message-ID: Date: Thu, 25 Dec 2025 10:32:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary To: Matthew Wilcox , 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, 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 References: <62a2d7ba-e7c3-4153-b227-c08802ca9e1c@linux.alibaba.com> <20251224092332.53214-1-ioworker0@gmail.com> <20251224140829.2ec7bbae@pumpkin> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/24/25 19:06, Matthew Wilcox wrote: > 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/ I'm starting to wonder whether we should just leave that code alone :) -- Cheers David