linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: 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: Wed, 5 Jun 2024 11:56:10 +0200	[thread overview]
Message-ID: <353d4f6c-ed3d-4afe-82ab-8c0b22a0178f@redhat.com> (raw)
In-Reply-To: <20240605095304.66389-1-alexs@kernel.org>

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.

-- 
Cheers,

David / dhildenb


  parent reply	other threads:[~2024-06-05  9:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  9:53 [RFC 1/3] mm/ksm: add anonymous check in find_mergeable_vma 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
2024-06-05  9:56 ` David Hildenbrand [this message]
2024-06-07  9:33   ` [RFC 1/3] mm/ksm: add anonymous check in find_mergeable_vma Alex Shi
2024-06-07 10:13     ` 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=353d4f6c-ed3d-4afe-82ab-8c0b22a0178f@redhat.com \
    --to=david@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexs@kernel.org \
    --cc=chrisw@sous-sol.org \
    --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;
as well as URLs for NNTP newsgroup(s).