mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Lorenzo Stoakes <ljs@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Peter Xu <peterx@redhat.com>,
	Alex Williamson <alex@shazbot.org>,
	Anthony Pighin <anthony.pighin@nokia.com>,
	linux-kernel@vger.kernel.org,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	kvm@vger.kernel.org, linux-mm@kvack.org,
	"Liam R. Howlett" <liam@infradead.org>,
	Ryan Roberts <ryan.roberts@arm.com>
Subject: Re: [PATCH] vfio: Request THP-aligned mmap for device fds
Date: Thu, 18 Jun 2026 16:04:06 +0100	[thread overview]
Message-ID: <ajQI5jMJpxyNZCLN@casper.infradead.org> (raw)
In-Reply-To: <ajQDVAu9b-LX8gUQ@lucifer>

On Thu, Jun 18, 2026 at 03:55:58PM +0100, Lorenzo Stoakes wrote:
> On Wed, Jun 17, 2026 at 04:29:28PM -0300, Jason Gunthorpe wrote:
> > On Wed, Jun 17, 2026 at 07:34:06PM +0100, Matthew Wilcox wrote:
> >
> > > I don't see this as being something that drivers should be involved with
> > > at all.  The MM should be able to get this right without any hints from
> > > the file-provider.  Yes, that means I also want to get rid of the setting
> > > of get_unmapped_area in ext4/xfs/other filesystems.
> > >
> > > Looking at generic_get_unmapped_area_topdown(), I think we can do this by
> > > making an additional call to vm_unmapped_area() before the existing two,
> > > setting info.align_mask and info.align_offset appropriately.
> > >
> > > Now, what's "appropriately"?  I think it's based on length (>= PMD_SIZE,
> > > then >= PUD_SIZE), but we should also take CONTPTE architectures into
> > > account.
> >
> > The info.align_mask and info.align_offset do need information from the
> > driver based on what it intends to map into the VMA that is being
> > created.

What you're saying is that offset 0 of the opened file might correspond
to a PFN that is not aligned in any way?  I had assumed that when trying
to do the mapping of (2MB+4KiB to 64MB), that the offset specified to
mmap was 2MB+4KiB.  But you seem to be saying that the offset in that
case would be 0 and someone needs to know that it corresponds to a PFN
that is misaligned?

> > Filesystems probably have quite different requirements than drivers
> > using remap_pfn() or vmf_insert_pfn() that have locked down pfn's.
> 
> I think part of the problem here is that we don't differentiate between
> drivers and filesystems, and what might be sensible for one is perhaps not
> sensible for another.
> 
> We're too generic really.
> 
> With mmap_prepare we have a lot of flexibility as to what we do. That
> callback is idempotent and as limited as possible, and actions like remap
> are achieved through calling a kernel function like mmap-action_remap().

mmap_prepare() is called too late.  We've already assigned the virtual
address range before we call __mmap_region(), and there's no attempt to
adjust 'addr' in __mmap_region() after calling mmap_prepare().


  reply	other threads:[~2026-06-18 15:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 18:01 Anthony Pighin
2026-06-16 22:30 ` Alex Williamson
2026-06-17 14:21   ` Peter Xu
2026-06-17 18:34     ` Matthew Wilcox
2026-06-17 19:29       ` Jason Gunthorpe
2026-06-18 14:55         ` Lorenzo Stoakes
2026-06-18 15:04           ` Matthew Wilcox [this message]
2026-06-18 15:30             ` Jason Gunthorpe
2026-06-18 15:56               ` Lorenzo Stoakes
2026-06-19 13:16                 ` Jason Gunthorpe
2026-06-22 16:54                   ` Lorenzo Stoakes
2026-06-30 12:46                     ` Jason Gunthorpe
2026-07-11  8:37                       ` Lorenzo Stoakes
2026-06-18 15:28           ` Jason Gunthorpe
2026-06-19 16:11             ` Matthew Wilcox
2026-06-19 17:07               ` Jason Gunthorpe
2026-06-22 15:42                 ` Lorenzo Stoakes
2026-06-30 12:51                   ` Jason Gunthorpe
2026-06-22 15:44               ` Lorenzo Stoakes
2026-06-19 15:04           ` Ryan Roberts
2026-06-22 15:48             ` Lorenzo Stoakes

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=ajQI5jMJpxyNZCLN@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=alex@shazbot.org \
    --cc=anthony.pighin@nokia.com \
    --cc=jgg@ziepe.ca \
    --cc=kvm@vger.kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=peterx@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=wangkefeng.wang@huawei.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

all inboxes | Powered by JetHome®