[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2f6d9541-8083-4d3c-a9c1-cba0d5bf98a0@linux.alibaba.com>
Date: Fri, 4 Jul 2025 14:11:13 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Nico Pache <npache@...hat.com>, linux-mm@...ck.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Cc: david@...hat.com, ziy@...dia.com, lorenzo.stoakes@...cle.com,
Liam.Howlett@...cle.com, ryan.roberts@....com, dev.jain@....com,
corbet@....net, rostedt@...dmis.org, mhiramat@...nel.org,
mathieu.desnoyers@...icios.com, akpm@...ux-foundation.org,
baohua@...nel.org, willy@...radead.org, peterx@...hat.com,
wangkefeng.wang@...wei.com, usamaarif642@...il.com, sunnanyong@...wei.com,
vishal.moola@...il.com, thomas.hellstrom@...ux.intel.com,
yang@...amperecomputing.com, kirill.shutemov@...ux.intel.com,
aarcange@...hat.com, raquini@...hat.com, anshuman.khandual@....com,
catalin.marinas@....com, tiwai@...e.de, will@...nel.org,
dave.hansen@...ux.intel.com, jack@...e.cz, cl@...two.org,
jglisse@...gle.com, surenb@...gle.com, zokeefe@...gle.com,
hannes@...xchg.org, rientjes@...gle.com, mhocko@...e.com,
rdunlap@...radead.org
Subject: Re: [PATCH v8 11/15] khugepaged: allow madvise_collapse to check all
anonymous mTHP orders
On 2025/7/2 13:57, Nico Pache wrote:
> Allow madvise_collapse to scan/collapse all mTHP orders without the
> strict requirement of needing the PMD-order enabled.
>
> Signed-off-by: Nico Pache <npache@...hat.com>
I am afraid we should drop this patch from the series, since Hugh
explicitly opposed my modification of the madvise_collapse control logic
in this thread[1].
Moreover, since we have not yet clarified how to handle the conflict
between the semantics of madvise_collapse and the THP interfaces, we
should keep the current logic[2] (means madvise_collapse still only
allows PMD collapse).
If madvise_collapse is to support mTHP collapse, there will be more
semantic conflicts to discuss.
[1]
https://lore.kernel.org/all/cover.1750815384.git.baolin.wang@linux.alibaba.com/
[2]
https://lore.kernel.org/all/23b8ad10-cd1f-45df-a25c-78d01c8af44f@redhat.com/
> ---
> mm/khugepaged.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index b96a7327b9c0..6ea681b81647 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2930,11 +2930,13 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> unsigned long hstart, hend, addr;
> int thps = 0, last_fail = SCAN_FAIL;
> bool mmap_locked = true;
> + unsigned long orders = vma_is_anonymous(vma) ?
> + THP_ORDERS_ALL_ANON : BIT(PMD_ORDER);
>
> BUG_ON(vma->vm_start > start);
> BUG_ON(vma->vm_end < end);
>
> - if (!thp_vma_allowable_order(vma, vma->vm_flags, 0, PMD_ORDER))
> + if (!thp_vma_allowable_orders(vma, vma->vm_flags, 0, orders))
> return -EINVAL;
>
> cc = kmalloc(sizeof(*cc), GFP_KERNEL);
> @@ -2956,7 +2958,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> mmap_read_lock(mm);
> mmap_locked = true;
> result = hugepage_vma_revalidate(mm, addr, false, &vma,
> - cc, BIT(HPAGE_PMD_ORDER));
> + cc, orders);
> if (result != SCAN_SUCCEED) {
> last_fail = result;
> goto out_nolock;
Powered by blists - more mailing lists