Re: [PATCH v2] mm: folio_zero_user: open code range computation in folio_zero_user()

From: David Hildenbrand (Arm)

Date: Fri Feb 06 2026 - 03:59:17 EST


On 2/6/26 06:42, Ankur Arora wrote:

David Hildenbrand (Arm) <david@xxxxxxxxxx> writes:

On 2/5/26 06:48, Ankur Arora wrote:
Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> writes:

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.

That makes sense to me.

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.

But the non-silent truncation is no better? IOW, it doesn't matter.

I never seem to get them but I thought we had some kconfig option that
makes gcc give a warning to that effect.

I think we do it all the time :)


I can update this patch to just implicitly truncate.


Yeah, I think the implicit once can just be dropped.

You could just make clear_contig_highpages() consume an unsigned long ...

Unfortunately that'll be an even bigger mess. The clear_contig_highpages()
version in mm-stable uses the unsigned intness of nr_pages all over:

Right.

In any case, thanks and feel free to add

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David