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: <87a4xneo5u.fsf@oracle.com>
Date: Wed, 04 Feb 2026 21:48:29 -0800
From: Ankur Arora <ankur.a.arora@...cle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: "David Hildenbrand (arm)" <david@...nel.org>,
        Ankur Arora
 <ankur.a.arora@...cle.com>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, x86@...nel.org, bp@...en8.de,
        dave.hansen@...ux.intel.com, hpa@...or.com, mingo@...hat.com,
        mjguzik@...il.com, luto@...nel.org, peterz@...radead.org,
        tglx@...utronix.de, willy@...radead.org, raghavendra.kt@....com,
        chleroy@...nel.org, ioworker0@...il.com, lizhe.67@...edance.com,
        boris.ostrovsky@...cle.com, konrad.wilk@...cle.com,
        kernel test robot
 <lkp@...el.com>
Subject: Re: [PATCH v2] mm: folio_zero_user: open code range computation in
 folio_zero_user()


Andrew Morton <akpm@...ux-foundation.org> writes:

> On Wed, 4 Feb 2026 22:01:42 +0100 "David Hildenbrand (arm)" <david@...nel.org> wrote:
>
>> > As David pointed out, the previous open coded version makes a few
>> > unnecessary changes. Could you queue this one instead?
>> >
>>
>> I'm late, maybe this is already upstream.
>
> It's in mm-unstable.  The second round of MM upstreaming is two weeks hence.
>
>> >
>> >   	/* Region to the left of the fault */
>> > -	r[1] = DEFINE_RANGE(pg.start,
>> > -			    clamp_t(s64, r[2].start - 1, pg.start - 1, r[2].start));
>> > +	r[1] = DEFINE_RANGE(pg.start, r[2].start - 1);
>> >
>> >   	/* Region to the right of the fault: always valid for the common fault_idx=0 case. */
>> > -	r[0] = DEFINE_RANGE(clamp_t(s64, r[2].end + 1, r[2].end, pg.end + 1),
>> > -			    pg.end);
>> > +	r[0] = DEFINE_RANGE(r[2].end + 1, pg.end);
>>
>> TBH, without the clamp that looks much more readable here.
>
> me too.
>
>> >
>> >   	for (i = 0; i < ARRAY_SIZE(r); i++) {
>> >   		const unsigned long addr = base_addr + r[i].start * PAGE_SIZE;
>> > -		const unsigned int nr_pages = range_len(&r[i]);
>> > +		const long nr_pages = (long)range_len(&r[i]);
>> >   		struct page *page = folio_page(folio, r[i].start);
>> >
>> >   		if (nr_pages > 0)
>> > -			clear_contig_highpages(page, addr, nr_pages);
>> > +			clear_contig_highpages(page, addr, (unsigned int)nr_pages);
>>
>> Is that cast really required?
>
> Seems not.  The types for nr_pages are a bit chaotic - u64->long->uint.

Yes agreed.

The first u64 is because currently struct range only supports that.
Then the cast to signed long is because the range can be negative
and the clear_contig_highpages() is only done if nr_pages > 0.

And, the third one is almost certainly unnecessary for any realistic
hugepage size but since nr_pages is being truncating, I wanted that
to be explicit.

--
ankur

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ