From: Jarkko Sakkinen <jarkko@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-mm@kvack.org, "Dave Hansen" <dave.hansen@linux.intel.com>,
"Nathaniel McCallum" <nathaniel@profian.com>,
"Reinette Chatre" <reinette.chatre@intel.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"Matthew Auld" <matthew.auld@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Jason Ekstrand" <jason@jlekstrand.net>,
"Chris Wilson" <chris@chris-wilson.co.uk>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Tvrtko Ursulin" <tvrtko.ursulin@intel.com>,
"Shakeel Butt" <shakeelb@google.com>,
"Vasily Averin" <vvs@virtuozzo.com>,
zhangyiru <zhangyiru3@huawei.com>,
"Alexander Mikhalitsyn" <alexander.mikhalitsyn@virtuozzo.com>,
"Alexey Gladkov" <legion@kernel.org>,
linux-mips@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
Subject: Re: [PATCH RFC 1/3] mm: Add f_ops->populate()
Date: Mon, 7 Mar 2022 15:26:11 +0200 [thread overview]
Message-ID: <YiYH88wJQzCMvSPC@iki.fi> (raw)
In-Reply-To: <YiYFxq87p2WVkZcz@iki.fi>
On Mon, Mar 07, 2022 at 03:16:57PM +0200, Jarkko Sakkinen wrote:
> On Sun, Mar 06, 2022 at 10:43:31PM +0000, Matthew Wilcox wrote:
> > On Sun, Mar 06, 2022 at 07:02:57PM +0200, Jarkko Sakkinen wrote:
> > > So can I conclude from this that in general having populate available for
> > > device memory is something horrid, or just the implementation path?
> >
> > You haven't even attempted to explain what the problem is you're trying
> > to solve. You've shown up with some terrible code and said "Hey, is
> > this a good idea". No, no, it's not.
>
> The problem is that in order to include memory to enclave, which is
> essentially a reserved address range processes virtual address space
> there's two steps into it:
>
> 1. Host side (kernel) does ENCLS[EAUG] to request a new page to be
> added to the enclave.
> 2. Enclave accepts request with ENCLU[EACCEPT] or ENCLU[EACCEPTCOPY].
>
> In the current SGX2 patch set this taken care by the page fault
> handler. I.e. the enclave calls ENCLU[EACCEPT] for an empty address
> and the #PF handler then does EAUG for a single page.
>
> So if you want to process a batch of pages this generates O(n)
> round-trips.
>
> So if there was a way pre-do a batch of EAUG's, that would allow
> to load data to the enclave without causing page faults happening
> constantly.
>
> One solution for this simply add ioctl:
>
> https://lore.kernel.org/linux-sgx/YiLRBglTEbu8cHP9@iki.fi/T/#m195ec84bf85614a140abeee245c5118c22ace8f3
>
> But in practice when you wanted to use it, you would setup the
> parameters so that they match the mmap() range. So for pratical
> user space API having mmap() take care of this would be much more
> lean option.
For something like Graphene [1] the lazy #PF based option is probably
a way to go. For wasm runtime that we're doing in Enarx [2] we get better
performance by having something like this. I.e. we most of the time take
as much as we use.
[1] https://github.com/gramineproject/graphene
[2] https://enarx.dev/
BR, Jarkko
next prev parent reply other threads:[~2022-03-07 13:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 5:32 [PATCH RFC 0/3] MAP_POPULATE for device memory Jarkko Sakkinen
2022-03-06 5:32 ` [PATCH RFC 1/3] mm: Add f_ops->populate() Jarkko Sakkinen
2022-03-06 10:01 ` Greg Kroah-Hartman
2022-03-06 17:02 ` Jarkko Sakkinen
2022-03-06 17:03 ` Jarkko Sakkinen
2022-03-06 22:43 ` Matthew Wilcox
2022-03-07 13:16 ` Jarkko Sakkinen
2022-03-07 13:26 ` Jarkko Sakkinen [this message]
2022-03-06 5:32 ` [PATCH RFC 2/3] x86/sgx: Export sgx_encl_page_alloc() Jarkko Sakkinen
2022-03-06 5:32 ` [PATCH RFC 3/3] x86/sgx: Implement EAUG population with MAP_POPULATE Jarkko Sakkinen
2022-03-06 8:30 ` [PATCH RFC 0/3] MAP_POPULATE for device memory David Laight
2022-03-06 16:52 ` 'Jarkko Sakkinen'
2022-03-06 11:33 ` Matthew Wilcox
2022-03-07 7:48 ` Christoph Hellwig
2022-03-07 13:29 ` Jarkko Sakkinen
2022-03-07 15:56 ` Christoph Hellwig
2022-03-07 15:58 ` Jarkko Sakkinen
2022-03-07 22:11 ` David Laight
2022-03-08 10:10 ` Jarkko Sakkinen
2022-03-07 10:12 ` David Hildenbrand
2022-03-07 14:22 ` Jarkko Sakkinen
2022-03-07 14:33 ` David Hildenbrand
2022-03-07 15:49 ` Jarkko Sakkinen
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=YiYH88wJQzCMvSPC@iki.fi \
--to=jarkko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.mikhalitsyn@virtuozzo.com \
--cc=chris@chris-wilson.co.uk \
--cc=codalist@coda.cs.cmu.edu \
--cc=daniel.vetter@ffwll.ch \
--cc=dave.hansen@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jason@jlekstrand.net \
--cc=legion@kernel.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=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=nathaniel@profian.com \
--cc=reinette.chatre@intel.com \
--cc=shakeelb@google.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tsbogend@alpha.franken.de \
--cc=tvrtko.ursulin@intel.com \
--cc=vvs@virtuozzo.com \
--cc=willy@infradead.org \
--cc=zhangyiru3@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;
as well as URLs for NNTP newsgroup(s).