From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 EF54E220F2C for ; Fri, 30 Jan 2026 12:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769775715; cv=none; b=kEVuDSQm42uZxiKiJAkLzNIlVWEp3lGeZ0io+nT5JGxZClXacy8ljK6yMBiA3WaU5LFB6Ka8syFpP5LqZGA+19vU1WFNiTX9fgyCoXmRaMyATvWAyK9xsbkO/9FqYEG3il+ggN9iv9n4D8brc0jZ0cJUQrdHRuLmWZ/cNGzoz2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769775715; c=relaxed/simple; bh=j6kBgo6AI+HEDcPEthLOre6Q40q3/5TvcKHhuhgQuIQ=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OI+wPDE+VKVG12HiVeYR5/mcLP9QbuQZFdZ/PBo0u6fYOLI69C5LKQ7YAIS7GVRq5Z58BxetGAJfvgD5IQZisyBbjVfHghZnefAmPn6wZoc0IU3pWJ85834QETQuClZIIXOY3IYk5zL3tvWHVqoBDMh8N7bmqs8S7uLkgRqcn0Q= 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=gXv/QwEi; arc=none smtp.client-ip=209.85.167.178 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="gXv/QwEi" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-45ee8823e2aso1306364b6e.0 for ; Fri, 30 Jan 2026 04:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769775713; x=1770380513; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=47z33Oj/PlPITytQF5BZ//P3DDU1FR4d5O8MCvqsW8U=; b=gXv/QwEilJjzHWuSkxbP+Jnr8/yQq4DKLZYAk9lVOKvwJVQ0GWANOAqUExszenERg/ EfOsjQa/Ip4boPpvc81mtnFlhVfsd2egBPx/g4VPODqtW+sljPrlXqpFgZVqKmb46jHE EumS31PhxU5NnnEVU3UwA8TqhU7NeIwsBW0onTzUVRGc6Q74+sw9b+Rr7X830GT4GaYx dGy9GnIOG30IBI5U0JgJKq3mnLRC31Dl4dRmnKZgSfGA9Q+Ir4P/R9kYP/h9UFuEvYK8 au7ykjClyFDrAN4flHlgL9XL3PXPrOp1zj4Brpj/7oa1GH4sttt73lAETiqjw4P7kxqt GOcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769775713; x=1770380513; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=47z33Oj/PlPITytQF5BZ//P3DDU1FR4d5O8MCvqsW8U=; b=kQohpTwHT2zA4uisO4fOjapKT3/Zr071EyF3PiJ88ZTULYr5mpvZRPD0G0oHrLLPtL J6hUpGuyQx05My+juXPehVWUsARzMjZcAKhflK0VfZmR+9VP13JOMvJ9RXxZXpCtbwnx 7LaCRQxq8a5YL9We1KPDznRIJj3+8Ws/O5P15T9Nb/tcXy2CRpNJEhYpcQBsCk3GHfea BUPl9QSvQEGKHf2b6WI/Hf9cHMWrwFCzHr8u5PPCCljLaiUm2NvE+SH+1DYOrcgOAfqA 8qj7voZe2k3m94VyRLZfs/Vs7OBLTpZX8nn3wY7etGCKGN7CFHrbS3C6DzpdbYCQT9X/ sMYg== X-Forwarded-Encrypted: i=1; AJvYcCWhd8PwJbI4iJbSUd5jl+y/1vh+IheKu7vPqqlWj/F9sHfb/QrSJoPvj/Gr4wsUqIkNIRksQaIXbfbIQ6o=@vger.kernel.org X-Gm-Message-State: AOJu0YwqaXxGluznr6DSjjcfGpThwbck2wT0UqEmpWdfeb4YFbi254bd wTRAKAXg6c59tN98jfLqADEaWYEO6s6B5xptiUct5Z+kE7+If57/zCogKzNK2A== X-Gm-Gg: AZuq6aIGaQ0pdKhYyKCDGNl0kgZFAgJPcm6oob/yEgwrSxHSmHY2S4t2MN5GeKfyNo+ 5oftkoe+fif9YH2qCpTfBTWt0lEEKs6fYSMMntAfl8Rdlwnc8uJTkui2wKyQ8/mOtz/zqpQ3tvN NpOMP64tqVKD8tiGmFhFODcrV+PaR1xGz0Z4GnLjmaJ1KXBEPnuNKjhnoifXW0kvpI+h6YW3U52 Ra72Giad1mHcrqCY2DQnEI8O1uRHEKHGgwbPngnlMDcEGsiKTC7xKXmphrgug1pJoGmawhv9I+x fZJwMeA2DJaqz7sVsvYX85d9ELJn7yAkCmTNRGu4RMq0ro8UcNk5Shtr+DBRQyrrC5YVGMWN7Ak jwBqJr/R4NG1VUvDyVjfc6zyKHbyD6O7EAskGC1zkUCKI0OlveoiOL0kBxjAmr50xSQjBnhL409 CuJXO/eCrCXpDmL2frboIH+6Kn+5Q= X-Received: by 2002:a17:90b:4b02:b0:343:6a79:6c75 with SMTP id 98e67ed59e1d1-3543b3a5b50mr2569583a91.29.1769769261142; Fri, 30 Jan 2026 02:34:21 -0800 (PST) Received: from chandna.localdomain ([106.222.232.101]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-353f6103e25sm11900806a91.1.2026.01.30.02.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 02:34:20 -0800 (PST) Date: Fri, 30 Jan 2026 16:04:10 +0530 From: Sahil Chandna To: 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, david@kernel.org, Sahil Chandna , Matthew Wilcox , David Laight 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> <20251225100106.53e03519@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; format=flowed Content-Disposition: inline In-Reply-To: <20251225100106.53e03519@pumpkin> On Thu, Dec 25, 2025 at 10:01:06AM +0000, David Laight wrote: >On Thu, 25 Dec 2025 10:32:46 +0100 >"David Hildenbrand (Red Hat)" wrote: > >> 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 :) >> > >Maybe 'we' should stop checkpatch (etc) suggesting min() in trivial >cases. It doesn't really make the code better. > > David Thank you for feedback, I dropped this patch this has been resubmitted [1]. This next two patches in this series were also dropped due to error in this patch. Requesting feedback, if I can re-submit the other 2 patches which use the "%pe" printk format specifier ? Sharing reference to patches [2] and [3] below. Thanks, Sahil [1] https://lore.kernel.org/all/39f4490a-d713-44a8-a1d7-3568b01b3dc2@kernel.org/ [2] https://lore.kernel.org/all/2c842a64fddeb0fe0cac087783aaedd97edc3191.1764312627.git.chandna.sahil@gmail.com/ [3] https://lore.kernel.org/all/6d729a60eb71baade3670e5bb609a068683af3eb.1764312627.git.chandna.sahil@gmail.com/