From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (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 0A1EA4A3E for ; Wed, 24 Dec 2025 07:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766562648; cv=none; b=gc4GtMy4aAajaFcq/Ji7ty8UND3uRKsTxhttVnKafE+JrvwNxgD/zQEk3VRcDitB9BrZJDN6pYy/yYDfFGzarhxRAjblDHrM5zZxePFEKBK4JjwkDMYP/bV1H+KIktyuEvyb3Qpf9bazZJ2G25WCLAbRmNOef8ze8ub+4TU5Vks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766562648; c=relaxed/simple; bh=rOElGfgtDFS7BuNe+bR+F/uvJ6kAV8RQg69RbOTKQOQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CKUwTYriFRlUg3FacZtTj+yRscDGbX1ivXN7vPYvAditEYgnsUb50UhxRlzr4CQfI62/5i3h/1o9YRb+fOriWA4LB9z2A05W8mtv5zsQGpW4yoG5Yw4GZaa0mwCOi0MU+JMSkLMx/+s5gSoBSDmTdTx//UPxlsMKJh8Pt9MAHIM= 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=XsA5/a39; arc=none smtp.client-ip=115.124.30.132 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="XsA5/a39" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1766562637; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=JmuJKPdTgOxTVKhwb84MlUQ0GXDFmnEWQ3I92ijpTmk=; b=XsA5/a39xq/IhKoYhd7d4lW4iZmpM2mElSRQwCSAV/Oc9FPWFBBzWXYlnEL6mYzj9EdTGzBRM83hflii2gIXLeJmSx3omWItvvP7dXpt8hNhpp+GzOfedI9BbEVp1piIhTxaDleJr+Tct/ogci5HWeJC6jg7dYGoI8g1VEWR+tc= Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WvaRD92_1766562634 cluster:ay36) by smtp.aliyun-inc.com; Wed, 24 Dec 2025 15:50:35 +0800 Message-ID: <62a2d7ba-e7c3-4153-b227-c08802ca9e1c@linux.alibaba.com> Date: Wed, 24 Dec 2025 15:50:34 +0800 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 calculation To: Sahil Chandna , akpm@linux-foundation.org, david@redhat.com, lorenzo.stoakes@oracle.com, mhocko@suse.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, hannes@cmpxchg.org, shakeel.butt@linux.dev, zhengqi.arch@bytedance.com, Liam.Howlett@oracle.com, weixugc@google.com, axelrasmussen@google.com, yuanchu@google.com, yosry.ahmed@linux.dev, nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: david@kernel.org, Matthew Wilcox , David Laight References: <35ab82f052d248c0047c10bf01853e37e4f9b4e4.1764312627.git.chandna.sahil@gmail.com> From: Baolin Wang In-Reply-To: <35ab82f052d248c0047c10bf01853e37e4f9b4e4.1764312627.git.chandna.sahil@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Andrew, On 2025/11/28 15:01, Sahil Chandna wrote: > Replace hugepage boundary computation with ALIGN() helper instead of > an open coded expression. This helps to improves code readability. > > This was flagged by Coccinelle (misc/minmax.cocci) as an opportunity > to use min(), after which the boundary computation was updated following > review suggestions. > > Found by: make coccicheck MODE=report M=mm/ > No functional change intended. > > Acked-by: David Hildenbrand (Red Hat) > Suggested-by: David Hildenbrand (Red Hat) > Suggested-by: Matthew Wilcox > Suggested-by: David Laight > Signed-off-by: Sahil Chandna > --- > mm/pagewalk.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > index 9f91cf85a5be..9fd59d517f37 100644 > --- a/mm/pagewalk.c > +++ 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. This patch does introduce functional changes and makes an incorrect assumption that the 'end' must be aligned to the hugepage size. However, this is not necessarily the case. For example, see how pagemap_read() calculates the 'end': " end = start_vaddr + ((count / PM_ENTRY_BYTES) << PAGE_SHIFT); " Revert this patch, mm selftests work well.