From: Dave Hansen <dave.hansen@intel.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: linux-sgx@vger.kernel.org,
Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] x86/sgx: Replace section local dirty page lists with a global list
Date: Mon, 15 Mar 2021 12:47:29 -0700 [thread overview]
Message-ID: <c98549d4-22f3-d279-52b2-c2383829e688@intel.com> (raw)
In-Reply-To: <YE+x+lhDYnKZ1933@kernel.org>
On 3/15/21 12:14 PM, Jarkko Sakkinen wrote:
> On Mon, Mar 15, 2021 at 09:03:21AM -0700, Dave Hansen wrote:
>> On 3/13/21 8:01 AM, Jarkko Sakkinen wrote:
>>> Reset initialized EPC pages in sgx_dirty_page_list to uninitialized state,
>>> and free them using sgx_free_epc_page(). Do two passes, as for SECS pages
>>> the first round can fail, if all child pages have not yet been removed.
>>> The driver puts all pages on startup first to sgx_dirty_page_list, as the
>>> initialization could be triggered by kexec(), meaning that pages have been
>>> reserved for active enclaves before the operation.
>>>
>>> The section local lists are redundant, as sgx_free_epc_page() figures
>>> out the correction by using epc_page->section.
>>
>> During normal runtime, the "ksgxd" daemon behaves like a version of
>> kswapd just for SGX. But, its first job is to initialize enclave
>> memory. This is done in a a separate thread because this initialization
>> can be quite slow.
>>
>> Currently, the SGX boot code places each enclave page on a
>> sgx_section-local list (init_laundry_list). Once it starts up, the
>> ksgxd code walks over that list and populates the actual SGX page allocator.
>>
>> However, the per-section structures are going away to make way for the
>> SGX NUMA allocator. There's also little need to have a per-section
>> structure; the enclave pages are all treated identically, and they can
>> be placed on the correct allocator list from metadata stoered in the
>> enclave page itself.
>>
> Is this a suggestion how to rephrase the commit message? :-)
Yep.
>>> static int ksgxd(void *p)
>>> {
>>> - int i;
>>> + struct sgx_epc_page *page;
>>> + LIST_HEAD(dirty);
>>> + int i, ret;
>>>
>>> set_freezable();
>>>
>>> /*
>>> - * Sanitize pages in order to recover from kexec(). The 2nd pass is
>>> - * required for SECS pages, whose child pages blocked EREMOVE.
>>> + * Reset initialized EPC pages in sgx_dirty_page_list to uninitialized state,
>>> + * and free them using sgx_free_epc_page().
>>
>> I'm not a fan of comments that tell us verbatim what the code does.
>
> So, what are you suggesting? Remove the whole comment or parts of it? I'm
> presuming that you suggest removing the "top-level" part.
Just please make it more relevant and informative. I can tell this is
processing 'sgx_dirty_page_list' and calling sgx_free_epc_page() from
the code. I don't need a comment to tell me that.
A better comment would say:
Take enclave pages from the init code, ensure they are clean,
and free the back into the main SGX page allocator
That tells what *role* this code plays (connecting init code to the
allocator) in a way that just verbatim telling what code is called does not.
next prev parent reply other threads:[~2021-03-15 19:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210313160119.1318533-1-jarkko@kernel.org>
2021-03-13 16:01 ` [PATCH v4 1/3] x86/sgx: Use sgx_free_epc_page() in sgx_reclaim_pages() Jarkko Sakkinen
2021-03-15 15:32 ` Dave Hansen
2021-03-15 19:06 ` Jarkko Sakkinen
2021-03-15 19:27 ` Jarkko Sakkinen
2021-03-16 12:50 ` Jarkko Sakkinen
2021-03-13 16:01 ` [PATCH v4 2/3] x86/sgx: Replace section local dirty page lists with a global list Jarkko Sakkinen
2021-03-15 16:03 ` Dave Hansen
2021-03-15 19:14 ` Jarkko Sakkinen
2021-03-15 19:47 ` Dave Hansen [this message]
2021-03-13 16:01 ` [PATCH v4 3/3] x86/sgx: Add a basic NUMA allocation scheme to sgx_alloc_epc_page() Jarkko Sakkinen
2021-03-14 11:56 ` Jarkko Sakkinen
2021-03-15 16:35 ` Dave Hansen
2021-03-15 19:23 ` 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=c98549d4-22f3-d279-52b2-c2383829e688@intel.com \
--to=dave.hansen@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®