From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE6562EDD63 for ; Wed, 24 Dec 2025 12:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766580390; cv=none; b=LiDkzfmTioXeHlNeyBUJL6EQXke7nLo8efVbnWBaVpHKOsjFO1KEamkZ0vrGKkwP7/Zt6rxH8NerhVWKIkD5YGdT8fDreV10Zjc9TWnJ/ixvdYeMpUoXT0b8GkKjzkMhWLvHcTULYnAVGkSECE3hQirOXBT0pq1WYbFnv0eV39o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766580390; c=relaxed/simple; bh=7cTCFV3fOkaKXLv6K8jaKL/32cgofyILXbZiNh1EMbQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jQ6U0XhIXa6GYZgyk5419eJmLrMZ1b6P5QsYbBLWLmAsLmhunALXXdRRt8QZaQ7m//mLs0hpstSQ1+IRsyPqn9egGzFKa1cjYZslJ2jBofu9iS0/wYFyMIffpdX9XftcsiBUN3CSD7Mpm4gXJJz22xvgCYB0tczkVqOgpnc0ChI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=djdXfB41; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="djdXfB41" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-34ca40c1213so4939741a91.0 for ; Wed, 24 Dec 2025 04:46:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766580388; x=1767185188; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9wlVlC9b/pS7CL+ANzn0zFPhFeVvWZnrVU3LuyWiWxg=; b=djdXfB410P9kjFxe+VyPeXE1viqCWuOW51VoNIu9LWSf+dqfGUWlhfUAkmbIQz76hS zuVD92A+8Eudr8/e337Gd1MsB9yJifYUsXeZgmEb0gw5sea4f6SVpbfMszOc7mfZuOQ/ KY0O0/jW7XZLtLSmpHyoRNgEhQrnwA5yA3NxAdd41tDcVdDoXqbPc1/jJMgUCUqKr3js dsl2FZg7DhjLTZsqUW82p2NxIPP3hph56N+SmOByE9UNxDG9iiqJ8jDR9FHN5BYHornc 5LI1es6PaQYPlBv1q2Vp5GTR8Vt706bi+s4MHp8J5nTmS25mbdQa4EKN3ih+QIW2ROiq FEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766580388; x=1767185188; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9wlVlC9b/pS7CL+ANzn0zFPhFeVvWZnrVU3LuyWiWxg=; b=uQh+V0ZNd1whCcc4Nu0QtY8opJYkflc9Tp8bsNqmvKETbfM4QF9L+Hktpao/vbJ92f 6dtcArIyBBO2BoO3YPbUFX9HLLAUn0xh/mftZ0MV/XF+m3TbfDa0/naf9A+e2Kphq8HF iT8BztqMdE5v3zcCpo9PkJQTNVKLiMy0RaOwIuon1f+j0PwxZqbOTxM+SgyzY72mflw1 FGHdGk6ELs8I601bp9xTyL6SGonHgQBykce+RbZqdco4fdsRN9pdAI6GA2XjMeGRh71J QsZvUkRyEjY9IJNbnI8NUR/bqeSiBWPdBgMXcqDmtKpBWA/bzPC53d3PRfs6DBT/anDR x37w== X-Forwarded-Encrypted: i=1; AJvYcCUspJ3ajAvA8ys6zVSQ3rOUNgBjKwJMhnEKAUliD/ryBBUGNlcjvHcyNV99wspt+Ywn0IWSdBPR0RXRG4s=@vger.kernel.org X-Gm-Message-State: AOJu0YwfyuyS7L0HDsKobwHRjSCC2n4/NjHSjU2iiKlLJANkxoZXbXYu Y4pq8lelRLa0DX8VrKmQWLy8OVurgCcKC8hdYjTBzCTB1t+H4Atx2qqY X-Gm-Gg: AY/fxX6oNt+8dU1652NKVkPmqzTmqCS2K4CCpvkoG5/sWjEMEvp8bxstd2/U3NPAzfE YHH0J4cvPcQm43bYkcMBZjLbYuotOqUyzuO+9lu0XXgBtxg2wMT23M/S8bvvDHmxsfjatMRe3OB cCH1SfguYbQnCVJoJxxda1PUr2xfBi+VbOand1KqQjZfP9SOarA1r9AFEuFHBJYaSC/LGlRKB/S u/i4ajbcgIJ2w+bAhfN+37fLch+nHbA7WwlE03aP7KheiFB6cUGYpKmiUmjWtGA7LqQxqnY+n71 JlGeP+lYpT43AWTQ+zsWuxBLSfw7Y8y65YsdiuQzQFchL/4DI018bORagc/hdl1RiJBS+QkfrQ0 taMJucbLP7PJvQcTKpTsGgBid57DQ28fQdep3o3A8OijoAwHIuf9Mmo0g44zR/vQI3/f31VRL9U 1kP77qhh0J6ans++a1WB74bLaG9xGa7M+hdz03sA== X-Google-Smtp-Source: AGHT+IHzxQX59o7stHR2OJF+G0uLgA9CwrTfMv5VBSkhhu2VDNJvhwxQrWWgIJkEvKUvhhxyE95gvw== X-Received: by 2002:a17:90b:5107:b0:34d:1d54:8bcf with SMTP id 98e67ed59e1d1-34e92142ab1mr14054539a91.9.1766580387869; Wed, 24 Dec 2025 04:46:27 -0800 (PST) Received: from chandna.localdomain ([106.222.230.223]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34e921b39dfsm15837892a91.8.2025.12.24.04.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Dec 2025 04:46:27 -0800 (PST) Date: Wed, 24 Dec 2025 18:16:05 +0530 From: Sahil Chandna To: akpm@linux-foundation.org, Lance Yang , baolin.wang@linux.alibaba.com Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org, axelrasmussen@google.com, chengming.zhou@linux.dev, david.laight.linux@gmail.com, 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, willy@infradead.org, yosry.ahmed@linux.dev, yuanchu@google.com, zhengqi.arch@bytedance.com 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> 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; format=flowed Content-Disposition: inline In-Reply-To: <20251224092332.53214-1-ioworker0@gmail.com> On Wed, Dec 24, 2025 at 05:23:32PM +0800, Lance Yang wrote: >From: Lance Yang > > >On Wed, 24 Dec 2025 15:50:34 +0800, Baolin Wang wrote: >> 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. > >Good catch! The problem is that ALIGN() returns addr itself when already >aligned, causing the infinite loop ... > >> >> This patch does introduce functional changes and makes an incorrect >> assumption that the 'end' must be aligned to the hugepage size. However, > >Yep. This patch is not equivalent to the original code when addr is >already aligned :) > >> 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. Hi Baolin, Lance, Andrew, Thanks for catching this, I understand why ALIGN() caused an infinite loop. Please drop this patch, or shall I submit the revert ? Apologies for this, I am setting up environment for running the selftest and will send out corrected patch once it successfully pass mm selftests. Regards, Sahil