From: Jarkko Sakkinen <jarkko@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Nathaniel McCallum <nathaniel@profian.com>,
Reinette Chatre <reinette.chatre@intel.com>,
linux-sgx@vger.kernel.org, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, codalist@coda.cs.cmu.edu,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH RFC] mm: Add f_ops->populate()
Date: Sun, 6 Mar 2022 06:25:52 +0200 [thread overview]
Message-ID: <YiQ30O/5LGh84z3t@iki.fi> (raw)
In-Reply-To: <YiQ2ThvkvnBBFRzD@casper.infradead.org>
On Sun, Mar 06, 2022 at 04:19:26AM +0000, Matthew Wilcox wrote:
> On Sun, Mar 06, 2022 at 06:11:21AM +0200, Jarkko Sakkinen wrote:
> > On Sun, Mar 06, 2022 at 03:52:12AM +0000, Matthew Wilcox wrote:
> > > On Sun, Mar 06, 2022 at 05:21:11AM +0200, Jarkko Sakkinen wrote:
> > > > On Sun, Mar 06, 2022 at 02:57:55AM +0000, Matthew Wilcox wrote:
> > > > > On Sun, Mar 06, 2022 at 04:15:33AM +0200, Jarkko Sakkinen wrote:
> > > > > > Sometimes you might want to use MAP_POPULATE to ask a device driver to
> > > > > > initialize the device memory in some specific manner. SGX driver can use
> > > > > > this to request more memory by issuing ENCLS[EAUG] x86 opcode for each
> > > > > > page in the address range.
> > > > > >
> > > > > > Add f_ops->populate() with the same parameters as f_ops->mmap() and make
> > > > > > it conditionally called inside call_mmap(). Update call sites
> > > > > > accodingly.
> > > > >
> > > > > Your device driver has a ->mmap operation. Why does it need another
> > > > > one? More explanation required here.
> > > >
> > > > f_ops->mmap() would require an additional parameter, which results
> > > > heavy refactoring.
> > > >
> > > > struct file_operations has 1125 references in the kernel tree, so I
> > > > decided to check this way around first.
> > >
> > > Are you saying that your device driver behaves differently if
> > > MAP_POPULATE is set versus if it isn't? That seems hideously broken.
> >
> > MAP_POPULATE does not do anything (according to __mm_populate in mm/gup.c)
> > with VMA's that have some sort of device/IO memory, i.e. vm_flags
> > intersecting with VM_PFNMAP | VM_IO.
> >
> > I can extend the guard obviously to:
> >
> > if (!ret && do_populate && file->f_op->populate &&
> > !!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
> > file->f_op->populate(file, vma);
>
> Are you deliberately avoiding the question? I'm not asking about
> implementation. I'm asking about the semantics of MAP_POPULATE with
> your driver.
No. I just noticed a bug in the guard from your comment that I wanted
point out.
With the next version I post the corresponding change to the driver,
in order to see this in context.
BR, Jarkko
next prev parent reply other threads:[~2022-03-06 4:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 2:15 [PATCH RFC] mm: Add f_ops->populate() Jarkko Sakkinen
2022-03-06 2:57 ` Matthew Wilcox
2022-03-06 3:21 ` Jarkko Sakkinen
2022-03-06 3:52 ` Matthew Wilcox
2022-03-06 4:11 ` Jarkko Sakkinen
2022-03-06 4:19 ` Matthew Wilcox
2022-03-06 4:25 ` Jarkko Sakkinen [this message]
2022-03-06 4:36 ` Matthew Wilcox
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=YiQ30O/5LGh84z3t@iki.fi \
--to=jarkko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=codalist@coda.cs.cmu.edu \
--cc=dave.hansen@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-sgx@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=nathaniel@profian.com \
--cc=reinette.chatre@intel.com \
--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).