linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Matthew Wilcox <willy@infradead.org>
Cc: David Hildenbrand <david@redhat.com>,
	lsf-pc@lists.linux-foundation.org,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Michal Hocko <mhocko@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>
Subject: Re: [LSF/MM/BPF TOPIC] MM: Mapcount Madness
Date: Thu, 1 Feb 2024 12:17:22 -0400	[thread overview]
Message-ID: <20240201161722.GH50608@ziepe.ca> (raw)
In-Reply-To: <Zbes6l0zn7gzu216@casper.infradead.org>

On Mon, Jan 29, 2024 at 01:49:30PM +0000, Matthew Wilcox wrote:

> What do VM_PFNMAP and VM_MIXEDMAP really imply?  The documentation here
> is a little sparse.  And that's sad, because I think we expect device
> driver writers to use them, and without clear documentation of what
> they actually do, they're going to be misused.

In many common driver cases the vm_* core code does set them when
installing pfns into a VMA..

PFNMAP means every PTE in a VMA is pure physical address and there is
no struct page refcount connected. In many, but not all, cases there
is no struct page at all.

MIXEDMAP means some PTEs are struct-pageless and others are not, but
if it has a struct page the the struct page is used.

I've had the feeling this is primarily to support arches that lack the
"special" bit CONFIG_ARCH_HAS_PTE_SPECIAL (badly named, but it means
the PTE does not have a struct page) and these flags help trigger some
guessing to fix it up.

The clearest documentation I've seen is in vm_normal_page().

In the majority of cases drivers want PFNMAP. MIXEDMAP is the weird
thing.

IIRC drivers get forced into MIXMAP if they want to prepopulate a VMA
instead of using the fault path, which is unfortunate if drivers are
actually working 100% with struct page backed memory (eg why does
binder set mixedmap? Does it work with struct-page-less PFNs, where
would it even get them from?). 

I believe this is due to missing driver facing APIs not anything
fundamental. Although I seem to recall there was some race inside mmap
if you try to prepopulate during the vma mmap op.. With zap, I think.

Jason


      parent reply	other threads:[~2024-02-01 16:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29 12:05 [LSF/MM/BPF TOPIC] MM: Mapcount Madness David Hildenbrand
2024-01-29 13:49 ` Matthew Wilcox
2024-01-29 14:09   ` David Hildenbrand
2024-02-01 16:17   ` Jason Gunthorpe [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=20240201161722.GH50608@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=lsf-pc@lists.linux-foundation.org \
    --cc=mhocko@kernel.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).