linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nadav Amit <namit@vmware.com>
To: Peter Xu <peterx@redhat.com>
Cc: Linux MM <linux-mm@kvack.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	David Hildenbrand <david@redhat.com>,
	Mike Rapoport <rppt@linux.ibm.com>
Subject: Re: [PATCH v1 2/5] userfaultfd: introduce access-likely mode for common operations
Date: Sat, 25 Jun 2022 07:49:54 +0000	[thread overview]
Message-ID: <07B65135-CA6D-4839-BAC0-6D63A94F50C2@vmware.com> (raw)
In-Reply-To: <YrY34IXlU656kCzE@xz-m1.local>



> On Jun 24, 2022, at 3:17 PM, Peter Xu <peterx@redhat.com> wrote:
> 
> On Fri, Jun 24, 2022 at 05:58:17PM -0400, Peter Xu wrote:
>> [Sorry for replying late]
>> 
>> Said that, I think it doesn't really necessary need to be that complex,
>> since make_huge_pte() already sets dirty bit when "writable=1", so IIUC
>> what you need to do is simply make sure dirty bit set when write_hint=1.
>> 
>> Does it sounds correct to you?
> 
> Hmm, hold on...  I failed to figure out how that write-likely hint could
> help us for either huge or non-huge pages, since:
> 
>  (1) Old code always set dirty, so no perf degrade anyway with/without the
>      hint
> 
>  (2) If we want to rework dirty bit (which I'm totally fine with..), then
>      we don't apply it when we shouldn't, and afaict we should set D bit
>      whenever we should...  if the user assumes this page is likely to be
>      written but made it read-only, say, with UFFDIO_COPY(wp_mode=1),
>      setting D bit will not help, instead, the user should simply use an
>      UFFDIO_COPY(wp_mode=0) then the dirty will be set with write=1..
> 
> It'll be helpful but only helpful for UFFDIO_ZEROCOPY because it avoids one
> COW.  But that seems to be it.
> 
> In short: I'm wondering whether we only really need the ACCESS_LIKELY hint
> as you proposed earlier.  We may want UFFDIO_ZEROPAGE_MODE_ALLOCATE
> separately, but keep that only for zeropage op (and it shouldn't really be
> called WRITE_LIKELY)?  Or did I miss something?

Let’s see if I get you correctly. I am not sure whether we had this
discussion before.

We are talking about a scenario in which WP=0. You argue that if the page
is already set as dirty, what is the benefit of not setting the dirty-bit,
right?

So first, IIUC, there are cases in which the page would not be set as
dirty, e.g., UFFDIO_CONTINUE. [ I am admittedly not too familiar with this
use-case, so I say it based on the comments. ]

Second, even if the page is dirty (e.g., following UFFDIO_COPY), but it
is not written by the user after UFFDI_COPY, marking the PTE as dirty
when it is mapped would induce overhead, as we discussed before, since
if/when the PTE is unmapped, TLB flush batching might not be possible.

So I don’t think there is a problem in having WRITE_LIKELY hint. Moreover,
I would reiterate my position (which you guys convinced me in!) that
having hints that indicate what the user does (WRITE_LIKELY) is a better
API than something that indicates directly what the kernel should do
(e.g., UFFDIO_ZEROPAGE_MODE_ALLOCATE).


But this discussion made me think that there are two somewhat related
matters that we may want to address:

1. mwriteprotect_range() should use MM_CP_TRY_CHANGE_WRITABLE when !wp
to proactively make entries writable and save .

2. The WRITE_LIKELY hint should be propagated from mwriteprotect_range()
to change_pte_range() through cp_flags, and the entry should be set
dirty accordingly.

With that, and with leaving hugetlbfs as it is (I meant before - leaving
it as it is in the patchset that I sent), would it be ok with you?


  reply	other threads:[~2022-06-25  7:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 18:50 [PATCH v1 0/5] userfaultfd: support access/write hints Nadav Amit
2022-06-22 18:50 ` [PATCH v1 1/5] userfaultfd: introduce uffd_flags Nadav Amit
2022-06-23 21:57   ` Peter Xu
2022-06-23 22:04     ` Nadav Amit
2022-06-22 18:50 ` [PATCH v1 2/5] userfaultfd: introduce access-likely mode for common operations Nadav Amit
2022-06-23 23:24   ` Peter Xu
2022-06-23 23:35     ` Nadav Amit
2022-06-23 23:49       ` Peter Xu
2022-06-24  0:03         ` Nadav Amit
2022-06-24  2:05           ` Peter Xu
2022-06-24  2:42             ` Nadav Amit
2022-06-24 21:58               ` Peter Xu
2022-06-24 22:17                 ` Peter Xu
2022-06-25  7:49                   ` Nadav Amit [this message]
2022-06-27 13:12                     ` Peter Xu
2022-06-27 13:27                       ` David Hildenbrand
2022-06-27 14:59                         ` Peter Xu
2022-06-27 23:37                       ` Nadav Amit
2022-06-28 10:55                         ` David Hildenbrand
2022-06-28 19:15                         ` Peter Xu
2022-06-28 20:30                           ` Nadav Amit
2022-06-28 20:56                             ` Peter Xu
2022-06-28 21:03                               ` Nadav Amit
2022-06-28 21:12                                 ` Peter Xu
2022-06-28 21:15                                   ` Nadav Amit
2022-07-12  6:19   ` Nadav Amit
2022-07-12 14:56     ` Peter Xu
2022-07-13  1:09       ` Nadav Amit
2022-07-13 16:02         ` Peter Xu
2022-07-13 16:49           ` Nadav Amit
2022-06-22 18:50 ` [PATCH v1 3/5] userfaultfd: introduce write-likely mode for uffd operations Nadav Amit
2022-06-22 18:50 ` [PATCH v1 4/5] userfaultfd: zero access/write hints Nadav Amit
2022-06-23 23:34   ` Peter Xu
2022-06-22 18:50 ` [PATCH v1 5/5] selftest/userfaultfd: test read/write hints Nadav Amit

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=07B65135-CA6D-4839-BAC0-6D63A94F50C2@vmware.com \
    --to=namit@vmware.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=peterx@redhat.com \
    --cc=rppt@linux.ibm.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