linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Barry Song <21cnbao@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Barry Song <v-songbaohua@oppo.com>,
	Chuanhua Han <hanchuanhua@oppo.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Zi Yan <ziy@nvidia.com>,
	Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
	Kalesh Singh <kaleshsingh@google.com>,
	Suren Baghdasaryan <surenb@google.com>
Subject: Re: [PATCH RFC] mm: entirely reuse the whole anon mTHP in do_wp_page
Date: Sat, 31 Aug 2024 12:14:38 +0200	[thread overview]
Message-ID: <5d0b6380-833d-449e-a6b2-e9b023832832@redhat.com> (raw)
In-Reply-To: <CAGsJ_4z=wHXa4Mug8RZJa4zULndPA0k9dw+OC41Lbv4nJUw3Ww@mail.gmail.com>

On 31.08.24 12:09, Barry Song wrote:
> On Sat, Aug 31, 2024 at 9:59 PM David Hildenbrand <david@redhat.com> wrote:
>>
>>
>>> +             idx = folio_page_idx(folio, vmf->page);
>>> +             folio_start = address - idx * PAGE_SIZE;
>>> +             folio_end = folio_start + nr * PAGE_SIZE;
>>> +
>>> +             if (unlikely(folio_start < max(address & PMD_MASK, vma->vm_start)))
>>> +                     return false;
>>> +             if (unlikely(folio_end > pmd_addr_end(address, vma->vm_end)))
>>> +                     return false;
>>> +             folio_ptep = vmf->pte - idx;
>>> +             folio_pte = ptep_get(folio_ptep);
>>> +             if (!pte_present(folio_pte) || pte_pfn(folio_pte) != folio_pfn(folio))
>>> +                     return false;
>>> +             if (folio_pte_batch(folio, folio_start, folio_ptep, folio_pte, nr, 0,
>>> +                             NULL, NULL, NULL) != nr)
>>> +                     return false;
>>> +             if (folio_mapcount(folio) != nr)
>>> +                     return false;
>>
>> BTW, you're not checking against the refcount (and it's all a bit racy
>> on concurrent unmapping!). So you're re-introducing the vmsplice
>> child->parent attak.
> 
> i don't quite understand this, you mean the below is not enough?
> 

Ah! You use the fallthrough, sorry I missed that!

You're not handling the swapcache references "correctly" (would have one 
reference per page), but the final check would be correct.

Yes, that should not allow for false positives here.

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2024-08-31 10:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-31  9:23 Barry Song
2024-08-31  9:44 ` David Hildenbrand
2024-08-31  9:55   ` Barry Song
2024-08-31 10:07     ` David Hildenbrand
2024-08-31 10:21       ` Barry Song
2024-08-31 10:29         ` David Hildenbrand
2024-08-31 10:49           ` Barry Song
2024-08-31 11:02             ` David Hildenbrand
2024-08-31  9:59 ` David Hildenbrand
2024-08-31 10:09   ` Barry Song
2024-08-31 10:14     ` David Hildenbrand [this message]

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=5d0b6380-833d-449e-a6b2-e9b023832832@redhat.com \
    --to=david@redhat.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chrisl@kernel.org \
    --cc=hanchuanhua@oppo.com \
    --cc=kaleshsingh@google.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=v-songbaohua@oppo.com \
    --cc=ziy@nvidia.com \
    /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