Re: [PATCH] mm: khugepaged: simplify scanning progress in pmd

From: David Hildenbrand (Arm)

Date: Thu Feb 26 2026 - 05:01:16 EST


>>
>> static int khugepaged_has_work(void)
>> @@ -2545,13 +2555,14 @@ static int khugepaged_wait_event(void)
>>
>> static void khugepaged_do_scan(struct collapse_control *cc)
>> {
>> - unsigned int progress = 0, pass_through_head = 0;
>> - unsigned int pages = READ_ONCE(khugepaged_pages_to_scan);
>> + const unsigned int progress_max = READ_ONCE(khugepaged_pages_to_scan);
>> + unsigned int pass_through_head = 0;
>> bool wait = true;
>> enum scan_result result = SCAN_SUCCEED;
>>
>> lru_add_drain_all();
>>
>> + cc->progress = 0;
>
> madvise(MADV_COLLAPSE) is missing the initialization of "cc->progress"
> because "cc = kmalloc_obj(*cc)". We need to manually initialize it in
> madvise_collapse().

Right, although it wouldn't matter right now, because nobody would be
reading the value.

It's really weird that cc is not simply completely zeroed out in
madvise_collapse().

--
Cheers,

David