From: Alex Shi <seakeel@gmail.com>
To: David Hildenbrand <david@redhat.com>,
alexs@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
izik.eidus@ravellosystems.com, willy@infradead.org,
aarcange@redhat.com, chrisw@sous-sol.org, hughd@google.com
Subject: Re: [RFC 1/3] mm/ksm: add anonymous check in find_mergeable_vma
Date: Fri, 7 Jun 2024 17:33:44 +0800 [thread overview]
Message-ID: <6b39db70-70ee-4370-acc3-86050562e343@gmail.com> (raw)
In-Reply-To: <353d4f6c-ed3d-4afe-82ab-8c0b22a0178f@redhat.com>
On 6/5/24 5:56 PM, David Hildenbrand wrote:
> On 05.06.24 11:53, alexs@kernel.org wrote:
>> From: "Alex Shi (tencent)" <alexs@kernel.org>
>>
>> We do vma_set_anonyous in do_mmap(), and then vma_is_anonymous()
>> checking workable, use it as a extra check since ksm only care anonymous
>> pages.
>>
>> Signed-off-by: Alex Shi (tencent) <alexs@kernel.org>
>> ---
>> mm/ksm.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/ksm.c b/mm/ksm.c
>> index f5138f43f0d2..088bce39cd33 100644
>> --- a/mm/ksm.c
>> +++ b/mm/ksm.c
>> @@ -742,7 +742,8 @@ static struct vm_area_struct *find_mergeable_vma(struct mm_struct *mm,
>> if (ksm_test_exit(mm))
>> return NULL;
>> vma = vma_lookup(mm, addr);
>> - if (!vma || !(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
>> + if (!vma || !(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma ||
>> + !vma_is_anonymous(vma))
>
> Doesn't KSM also apply to COW'ed pages in !anon mappings? At least that's what I recall.
I didn't a evidence for this. :(
In write_protect_page(), "PageAnonExclusive(&folio->page);" has a "VM_BUG_ON_PGFLAGS(!PageAnon(page), page);"
So is this hints the vma also need to be anonymous one?
Thanks a lot!
Alex
>
next prev parent reply other threads:[~2024-06-07 9:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 9:53 alexs
2024-06-05 9:53 ` [RFC 2/3] mm/ksm: jump out early if vma out of date in cmp_and_merge_page alexs
2024-06-05 9:53 ` [RFC 3/3] mm/ksm: move flush_anon_page before checksum calculation alexs
2024-06-05 10:04 ` Alex Shi
[not found] ` <353d4f6c-ed3d-4afe-82ab-8c0b22a0178f@redhat.com>
2024-06-07 9:33 ` Alex Shi [this message]
2024-06-07 10:13 ` [RFC 1/3] mm/ksm: add anonymous check in find_mergeable_vma David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b39db70-70ee-4370-acc3-86050562e343@gmail.com \
--to=seakeel@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alexs@kernel.org \
--cc=chrisw@sous-sol.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=izik.eidus@ravellosystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox