[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <28917c0a-a58c-4d19-bcc3-aef1c1969e8c@linux.alibaba.com>
Date: Fri, 4 Jul 2025 13:51:29 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Nico Pache <npache@...hat.com>, akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
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, 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 02/15] introduce khugepaged_collapse_single_pmd to
unify khugepaged and madvise_collapse
On 2025/7/4 12:20, Nico Pache wrote:
> On Thu, Jul 3, 2025 at 9:51 PM Baolin Wang
> <baolin.wang@...ux.alibaba.com> wrote:
>>
>>
>>
>> On 2025/7/2 13:57, Nico Pache wrote:
>>> The khugepaged daemon and madvise_collapse have two different
>>> implementations that do almost the same thing.
>>>
>>> Create khugepaged_collapse_single_pmd to increase code reuse and create an
>>> entry point these two users.
>>>
>>> Refactor madvise_collapse and khugepaged_scan_mm_slot to use the new
>>> khugepaged_collapse_single_pmd function. This introduces a minor
>>> behavioral change that is most likely an undiscovered bug. The current
>>> implementation of khugepaged tests khugepaged_test_exit_or_disable
>>> before calling khugepaged_pte_mapped_thp, but we weren't doing it in the
>>> madvise_collapse case. By unifying these two callers madvise_collapse
>>> now also performs this check.
>>>
>>> Reviewed-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
>>> Signed-off-by: Nico Pache <npache@...hat.com>
>>> ---
>>> mm/khugepaged.c | 95 +++++++++++++++++++++++++------------------------
>>> 1 file changed, 49 insertions(+), 46 deletions(-)
>>>
>>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>>> index f27fe7ca9b86..bf69e81a3d82 100644
>>> --- a/mm/khugepaged.c
>>> +++ b/mm/khugepaged.c
>>> @@ -2354,6 +2354,50 @@ static int khugepaged_scan_file(struct mm_struct *mm, unsigned long addr,
>>> return result;
>>> }
>>>
>>> +/*
>>> + * Try to collapse a single PMD starting at a PMD aligned addr, and return
>>> + * the results.
>>> + */
>>> +static int khugepaged_collapse_single_pmd(unsigned long addr,
>>> + struct vm_area_struct *vma, bool *mmap_locked,
>>> + struct collapse_control *cc)
>>> +{
>>> + int result = SCAN_FAIL;
>>> + struct mm_struct *mm = vma->vm_mm;
>>> +
>>> + if (IS_ENABLED(CONFIG_SHMEM) && !vma_is_anonymous(vma)) {
>>
>> Seems you still forgot to drop 'IS_ENABLED(CONFIG_SHMEM)' :)
> Hi Baolin,
>
> You had me questioning my sanity for a moment because I SWEAR I did do
> this! but now I see the issue, I accidentally merged the fixup into
> patch 6 (not entirely sure how or why I would have done that given my
> notes say it belongs in this patch...)
Ah, yes.
> I'm sorry about that :< I'll see if I can work with Andrew to get some
> fixups into mm-new (this was merged a few hours ago) for this patch
> and patch 6.
OK. Thanks.
Powered by blists - more mailing lists