Re: [RFC PATCH] mm: Enable khugepaged to operate on non-writable VMAs

From: David Hildenbrand
Date: Mon Sep 01 2025 - 09:44:01 EST


On 01.09.25 15:15, Kiryl Shutsemau wrote:
On Mon, Sep 01, 2025 at 10:32:34AM +0200, David Hildenbrand wrote:

@@ -676,9 +676,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
writable = true;
}
- if (unlikely(!writable)) {
- result = SCAN_PAGE_RO;
- } else if (unlikely(cc->is_khugepaged && !referenced)) {
+ if (unlikely(cc->is_khugepaged && !referenced)) {
result = SCAN_LACK_REFERENCED_PAGE;
} else {
result = SCAN_SUCCEED;
@@ -1421,9 +1419,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
mmu_notifier_test_young(vma->vm_mm, _address)))
referenced++;
}
- if (!writable) {
- result = SCAN_PAGE_RO;
- } else if (cc->is_khugepaged &&
+ if (cc->is_khugepaged &&

The only practical use of the writable is gone. The only other usage is
tracing which can be dropped to as it is not actionable anymore.

Could you drop writable? Maybe as a separate commit.

I think we should just do it in the same patch.

Change in trace_mm_collapse_huge_page_isolate() interface doesn't belong
to the same patch in my view.

We frequently adjust tracing code (which is specific to khugepaged in this case) in the same patch.

Anyhow, no strong opinion.

--
Cheers

David / dhildenb