From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 26A2E2D592C for ; Thu, 25 Dec 2025 11:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766662938; cv=none; b=mq9KytGJwi03WhpnMhFlO6YC3gdq/8yAiomskDhOsbx+Ubni5Dq2LAPaQlKOAzTYC1dFLvoF9PBWbkjgyTxZxY6rNTN013HVQLp17/k8LIwibZWI1AxvjC2rKmAf0E7O77U7fKJIhp4PmtnsoGSS/R9yPYp16mjfKY817wDMSFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766662938; c=relaxed/simple; bh=EfVKi6WXhLhNZyq+FolpjsaIL8SVk8mFBw+4V+8UhKk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RgSGncaKvE+4APDsS6PLUMItV+RCabh+/1Li8DPJjJKdzpbLRWiq8fPfBBLQU/t7fMohVGhyJrB5KmWAhRSVCEoq8Q2shOTggw6v1SkpQW6R1cmsBqPzAaCVHJMCAKMFLS3cvY9CTolUahZj1RgCbFHPynp/E67D1NdVWiCaLZ0= 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=iSxwALKM; arc=none smtp.client-ip=209.85.167.52 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="iSxwALKM" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5957db5bdedso7629945e87.2 for ; Thu, 25 Dec 2025 03:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766662935; x=1767267735; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=bJNXgeUnmBlVzib85vhCp/zOF7QDvNN+6JzrDWT84Ew=; b=iSxwALKMYk8ANUd6RdbMJKroAxCxFnGx/k+33zDWB3tVne2q8k6ZAJvTP5E23/XT10 IiJ9Z2lfihebzpNVO4oWFqSI4ey1mJg1XDdM6X8AXxw60ejwx/TVlt2/2m1ho8Ko7EEw F6nI3BiRQddxNzpwk1UmFOcPXaYktxTRA4P6YwxSLuR7DJh5AG4UeQ0D34tlwhkafHKl YkziWM5mv+NhB7dziN7Tt3yX96yxBUOND3Ia8vXWRlDMwxnPAtHApuyncDgFo9sTb/l9 gsqjJvdQBJhh/GvzVbqtOJ7rZ7x1c1GvJlXIyWoosUi9l0eM03DGl/mL6jP7UqRj0r9o zloQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766662935; x=1767267735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bJNXgeUnmBlVzib85vhCp/zOF7QDvNN+6JzrDWT84Ew=; b=rc7aKxHO8BxSxlRWptCVBcpdU2P/uvc8R74i6JCe4kDMnuH8nt2fPoKJNjATsMjvfk Qab6hztQ+o+bX7KTEFcyk1h6T6fq8Lypp4CvNyjpDcVp4cZ8MmvXSkos78wsctLhL2Tb kWEAPiNUf//5umDEl5H75AUleEJckIVkZqSB9Ujf6+DkRYJiaenQeJT2mWglh8HdPxtb 67LV8l/fcgSnUjXc3jbYTv+NLb9P2kJsUM5D0z9QtaNbo54w8/9wJxql0INoAyTKqgc4 q587zPCUcoO3vtMcnyi/CKri0y3uTOBvczFUwJ3gsVNtJ5FSVuy/oHLNX42UWu7fAafe shSQ== X-Forwarded-Encrypted: i=1; AJvYcCWUaeoCdXDqISKB12bUvHCaPTUOU/HzsSAjFto90LiNNhbgxkcpX/8Doa1xoows7ipFiA1+GREow5nN2rg=@vger.kernel.org X-Gm-Message-State: AOJu0YwlcpCVtk1ZoTxe8py42c6lW5+s0RXZSUtd5FRSIyJ4pjozMITp ejl1MjL7xTFfKBSWUIWspqTNHcIm3P1pO/n2oA++GEdRhe7Kit2578tZi4Uk8w== X-Gm-Gg: AY/fxX6yqxor1WuGpMReu/wtt4dVAuUzF8EYTzVdzLrGln6bPk3yKBZLV09psvY6Cwj n/ubx704da9qdJF3sspgt0tU1ZKqLUg2v02E9uv8ioLAM/JoSTS3cHw684Nq1DpWKHUcIlaoPAI b4rtPg/TYhSNbwS8IVI5mvjB2N8TL9zrYPuVUWOQ6FPjCWq1jwwwLc4dpo+5q3Tk2y6gMYCCPJO AV20arePCHQxn2D8ZG/ViK0vjuIeQwpZ6DMv2aDdkiceTw6u9iA2jpTzOc/TU0X4CSFYm6JLnNL mxiQRIqjz+3LaaXtFdA5K+7BXylTIA8Z9oosM11Pcgyu+wsrDH9K8bsd3bYMw0uC3cHU1XXmGN/ Ole4fH2BQHoF+TL0LGrrxBYKV+F1GHc7pwW4o9nMNW9V8anHRMiKwXkTqxx+q/0UpIAIe3hBHMA Zrg0Mxw0tgMW+cJDjA7FySmQkzcvxiUc28wAVItxY+1XdOKOa1aaI= X-Google-Smtp-Source: AGHT+IHOom56Z1I9znTT8GQOWzOtEMMo18aa48rdUzp7lDUJXyKKxD9GjcmJyzFsWfIZQUseGnf7Zg== X-Received: by 2002:a05:600c:6299:b0:477:73e9:dbe7 with SMTP id 5b1f17b1804b1-47d1959ae49mr234180245e9.35.1766656869005; Thu, 25 Dec 2025 02:01:09 -0800 (PST) Received: from pumpkin (host-2-103-239-165.as13285.net. [2.103.239.165]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be27c2260sm380489825e9.15.2025.12.25.02.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Dec 2025 02:01:08 -0800 (PST) Date: Thu, 25 Dec 2025 10:01:06 +0000 From: David Laight To: "David Hildenbrand (Red Hat)" Cc: Matthew Wilcox , 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 Subject: Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary Message-ID: <20251225100106.53e03519@pumpkin> In-Reply-To: References: <62a2d7ba-e7c3-4153-b227-c08802ca9e1c@linux.alibaba.com> <20251224092332.53214-1-ioworker0@gmail.com> <20251224140829.2ec7bbae@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit 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