linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Tiberiu A Georgescu <tiberiu.georgescu@nutanix.com>,
	corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org
Cc: peter.xu@redhat.com, ivan.teterevkov@nutanix.com,
	florian.schmidt@nutanix.com, carl.waldspurger@nutanix.com,
	jonathan.davies@nutanix.com
Subject: Re: [PATCH] Documentation: update pagemap with SOFT_DIRTY & UFFD_WP shmem issue
Date: Wed, 18 Aug 2021 21:14:54 +0200	[thread overview]
Message-ID: <8f7d6856-7bcd-dedf-663b-cd7ef2d0827f@redhat.com> (raw)
In-Reply-To: <20210812155843.236919-1-tiberiu.georgescu@nutanix.com>

On 12.08.21 17:58, Tiberiu A Georgescu wrote:
> Mentioning the current missing functionality of the pagemap, in case
> someone stumbles upon unexpected behaviour.
> 
> Signed-off-by: Tiberiu A Georgescu <tiberiu.georgescu@nutanix.com>
> Reviewed-by: Ivan Teterevkov <ivan.teterevkov@nutanix.com>
> Reviewed-by: Florian Schmidt <florian.schmidt@nutanix.com>
> Reviewed-by: Carl Waldspurger <carl.waldspurger@nutanix.com>
> Reviewed-by: Jonathan Davies <jonathan.davies@nutanix.com>
> ---
>   Documentation/admin-guide/mm/pagemap.rst | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst
> index fb578fbbb76c..627f3832b3a2 100644
> --- a/Documentation/admin-guide/mm/pagemap.rst
> +++ b/Documentation/admin-guide/mm/pagemap.rst
> @@ -207,3 +207,9 @@ Before Linux 3.11 pagemap bits 55-60 were used for "page-shift" (which is
>   always 12 at most architectures). Since Linux 3.11 their meaning changes
>   after first clear of soft-dirty bits. Since Linux 4.2 they are used for
>   flags unconditionally.
> +
> +Note that the page table entries for swappable and non-syncable pages are
> +cleared when those pages are zapped or swapped out. This makes information
> +about the page disappear from the pagemap.  The location of the swapped
> +page can still be retrieved from the page cache, but flags like SOFT_DIRTY
> +and UFFD_WP are lost irretrievably.
> 

UFFD_WP is currently only supported for private anonymous memory, where 
it should just work (a swap entry with a uffd-wp marker). So can we even 
end up with UFFD_WP bits on shmem and such? (Peter is up-streaming that 
right now, but there, I think he's intending to handle it properly 
without these bits getting lost using pte_markers and such).

So regarding upstream Linux, your note regarding UFFD_WP should not be 
applicable, right?


On a related note: if we start thinking about the pagemap expressing 
which pages are currently mapped into the page tables ("state of the 
process page tables") mostly all starts making sense. We document this 
as "to examine the page tables" already.

We only get swapped information if there is a swap PTE -- which only 
makes sense for anonymous pages, because there, the page table holds the 
state ("single source of truth"). For shmem, we don't have it, because 
the page cache is the single source of truth.

We only get presence information if there is a page mapped into the page 
tables -- which, for anonymous pages, specifies if there is anything 
present at all. For shmem we only have it if it's currently mapped into 
the page table.

Losing softdirt is a bad side effect of, what you describe, just setting 
a PTE to none and not syncing back that state back to some central place 
where it could be observed even without the PTE at hand.


Maybe we should document more clearly, especially what to expect for 
anonymous pages and what to expect for shared memory etc from the 
pagemap. Once we figured out which other interfaces we have to deal with 
shared memory (minore(), lseek() as we learned), we might want to 
document that as well, to safe people some time when exploring this area.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2021-08-18 19:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 15:58 [PATCH] Documentation: update pagemap with SOFT_DIRTY & UFFD_WP shmem issue Tiberiu A Georgescu
2021-08-18 19:14 ` David Hildenbrand [this message]
2021-08-20 17:10   ` Tiberiu Georgescu
2021-08-20 20:25     ` Peter Xu
2021-08-23  8:40       ` David Hildenbrand
2021-08-23  8:52     ` David Hildenbrand
2021-08-25 15:48       ` Tiberiu Georgescu

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=8f7d6856-7bcd-dedf-663b-cd7ef2d0827f@redhat.com \
    --to=david@redhat.com \
    --cc=carl.waldspurger@nutanix.com \
    --cc=corbet@lwn.net \
    --cc=florian.schmidt@nutanix.com \
    --cc=ivan.teterevkov@nutanix.com \
    --cc=jonathan.davies@nutanix.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peter.xu@redhat.com \
    --cc=tiberiu.georgescu@nutanix.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;
as well as URLs for NNTP newsgroup(s).