lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRyOWrARRlUCeEz6@casper.infradead.org>
Date: Tue, 18 Nov 2025 15:18:50 +0000
From: Matthew Wilcox <willy@...radead.org>
To: David Laight <david.laight.linux@...il.com>
Cc: Sahil Chandna <chandna.sahil@...il.com>, akpm@...ux-foundation.org,
	david@...hat.com, lorenzo.stoakes@...cle.com, mhocko@...e.com,
	vbabka@...e.cz, rppt@...nel.org, surenb@...gle.com,
	hannes@...xchg.org, shakeel.butt@...ux.dev,
	zhengqi.arch@...edance.com, Liam.Howlett@...cle.com,
	weixugc@...gle.com, axelrasmussen@...gle.com, yuanchu@...gle.com,
	yosry.ahmed@...ux.dev, nphamcs@...il.com, chengming.zhou@...ux.dev,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] mm/pagewalk: use min() macro instead of manual
 ternary

On Tue, Nov 18, 2025 at 10:45:37AM +0000, David Laight wrote:
> On Tue, 18 Nov 2025 11:38:49 +0530
> Sahil Chandna <chandna.sahil@...il.com> wrote:
> > +++ b/mm/pagewalk.c
> > @@ -313,7 +313,7 @@ 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(boundary, end);
> 
> You can remove the temporary:
> 	return min((addr & huge_page_mask(h)) + huge_page_size(h), end);

You can, but I'm not sure that's better.  What would be better is:

	unsigned long boundary = (addr | ~huge_page_mask(h)) + 1;
	return min(boundary, end);

if you insist, we could do:

	return min((addr | ~huge_page_mask(h)) + 1, end);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ