Re: [PATCH 05/12] mm/collapse: state what a collapse may do in the policy
From: Baolin Wang
Date: Mon Sep 07 2026 - 21:48:54 EST
On 9/7/26 6:56 PM, Kiryl Shutsemau wrote:
On Mon, Sep 07, 2026 at 05:05:19PM +0800, Baolin Wang wrote:
+/* What a collapse is allowed to do, decided by the caller that asks for it */
+struct collapse_policy {
+ /* Limits, stated per PMD; HPAGE_PMD_NR means "no limit" */
+ unsigned int max_ptes_none;
+ unsigned int max_ptes_swap;
+ unsigned int max_ptes_shared;
+
+ /*
+ * Hold a sub-PMD window to a stricter rule than a PMD: no swapped-out
+ * and no shared PTEs at all, and max_ptes_none as
+ * collapse_max_ptes_none() scales it.
+ */
+ bool strict_sub_pmd;
This is a bit confusing to me. Actually, the check for mTHP collapse is
stricter.
How about naming it 'allow_mthp_collapse'? That way we can keep the most
original comments for the collapse_max_ptes_xxx() functions, which is
clearer to me.
If others have a better name, please ignore my comment.
I would rather keep strict_sub_pmd.
Which orders a caller asks for is already decided elsewhere:
collapse_possible_orders() hands khugepaged every anonymous order and
MADV_COLLAPSE the PMD order only, from tva_type.
A flag called allow_mthp_collapse next to that would read as
a second place deciding the same thing, and flipping it would not change
which orders get collapsed. What it does change is how a sub-PMD window
is judged once one is asked for, and it is read at exactly the three
places that judge one.
I will do:
/* Take no swapped-out or shared PTE into a sub-PMD collapse */
bool strict_sub_pmd;
OK. Fair enough. Thanks.