From: Dave Hansen <dave.hansen@intel.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: linux-sgx@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/5] x86/sgx: Add a basic NUMA allocation scheme to sgx_alloc_epc_page()
Date: Wed, 10 Mar 2021 07:44:39 -0800 [thread overview]
Message-ID: <c710eea8-a0ea-70b6-6521-0dd685adbb06@intel.com> (raw)
In-Reply-To: <YEitzCiXd02/Pxy1@kernel.org>
>>> + * node.
>>> + */
>>> +static struct sgx_numa_node *sgx_numa_nodes;
>>> +
>>> +/*
>>> + * sgx_free_epc_page() uses this to find out the correct struct sgx_numa_node,
>>> + * to put the page in.
>>> + */
>>> +static int sgx_section_to_numa_node_id[SGX_MAX_EPC_SECTIONS];
>>
>> If this is per-section, why not put it in struct sgx_epc_section?
>
> Because struct sgx_epc_page does not contain a pointer to
> struct sgx_epc_section.
Currently, we have epc_page->section. That's not changing. But, with
the free list moving from sgx_epc_section to sgx_numa_node, we need a
way to get from page->node, not just page->section.
We can either add that to:
struct sgx_epc_section {
...
+ struct sgx_numa_node *node;
}
so we can do epc_page->section->node to find the epc_page's free list,
or we could just do:
struct sgx_epc_page {
- unsigned int section;
+ unsigned int node;
unsigned int flags;
struct sgx_encl_page *owner;
struct list_head list;
struct list_head numa_list;
};
and go from page->node directly.
>>> page = list_first_entry(&sgx_free_page_list, struct sgx_epc_page, list);
>>> + list_del_init(&page->numa_list);
>>> list_del_init(&page->list);
>>> sgx_nr_free_pages--;
>>
>> I would much rather prefer that this does what the real page allocator
>> does: kep the page on a single list. That list is maintained
>> per-NUMA-node. Allocations try local NUMA node structures, then fall
>> back to other structures (hopefully in a locality-aware fashion).
>>
>> I wrote you the loop that I want to see this implement in an earlier
>> review. This, basically:
>>
>> page = NULL;
>> nid = numa_node_id();
>> while (true) {
>> page = __sgx_alloc_epc_page_from_node(nid);
>> if (page)
>> break;
>>
>> nid = // ... some search here, next_node_in()...
>> // check if we wrapped around:
>> if (nid == numa_node_id())
>> break;
>> }
>>
>> There's no global list. You just walk around nodes trying to find one
>> with space. If you wrap around, you stop.
>>
>> Please implement this. If you think it's a bad idea, or can't, let's
>> talk about it in advance. Right now, it appears that my review comments
>> aren't being incorporated into newer versions.
>
> How I interpreted your earlier comments is that the fallback is unfair and
> this patch set version does fix that.
>
> I can buy the above allocation scheme, but I don't think this patch set
> version is a step backwards. The things done to struct sgx_epc_section
> are exactly what should be done to it.
To me, it's a step backwards. It regresses in that it falls back to an
entirely non-NUMA aware allocation mechanism. The global list is
actually likely to be even worse than the per-section searches because
it has a global lock as opposed to the at per-section locks. It also
has the overhead of managing two lists instead of one.
So, yes, it is *fair* in terms of NUMA node pressure. But being fair in
a NUMA-aware allocator by simply not doing NUMA at all is a regression.
> Implementation-wise you are asking me to squash 4/5 and 5/5 into a single
> patch, and remove global list. It's a tiny iteration from this patch
> version and I can do it.
Sounds good.
next prev parent reply other threads:[~2021-03-10 15:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210303150323.433207-1-jarkko@kernel.org>
2021-03-03 15:03 ` [PATCH v3 1/5] x86/sgx: Fix a resource leak in sgx_init() Jarkko Sakkinen
2021-03-03 16:56 ` Dave Hansen
2021-03-10 15:00 ` Jarkko Sakkinen
2021-03-10 15:49 ` Sean Christopherson
2021-03-10 21:52 ` Jarkko Sakkinen
2021-03-03 15:03 ` [PATCH v3 2/5] x86/sgx: Use sgx_free_epc_page() in sgx_reclaim_pages() Jarkko Sakkinen
2021-03-03 16:59 ` Dave Hansen
2021-03-10 15:11 ` Jarkko Sakkinen
2021-03-10 15:55 ` Dave Hansen
2021-03-10 21:56 ` Jarkko Sakkinen
2021-03-10 20:36 ` Kai Huang
2021-03-10 22:10 ` Jarkko Sakkinen
2021-03-10 22:12 ` Jarkko Sakkinen
2021-03-10 22:35 ` Jarkko Sakkinen
2021-03-10 22:43 ` Kai Huang
2021-03-10 22:52 ` Kai Huang
2021-03-03 15:03 ` [PATCH v3 3/5] x86/sgx: Replace section->init_laundry_list with a temp list Jarkko Sakkinen
2021-03-03 18:02 ` Dave Hansen
2021-03-10 14:50 ` Jarkko Sakkinen
2021-03-03 15:03 ` [PATCH v3 4/5] x86/sgx: Replace section->page_list with a global free page list Jarkko Sakkinen
2021-03-03 23:48 ` Dave Hansen
2021-03-10 10:54 ` Jarkko Sakkinen
2021-03-03 15:03 ` [PATCH v3 5/5] x86/sgx: Add a basic NUMA allocation scheme to sgx_alloc_epc_page() Jarkko Sakkinen
2021-03-04 0:20 ` Dave Hansen
2021-03-10 11:30 ` Jarkko Sakkinen
2021-03-10 15:44 ` Dave Hansen [this message]
2021-03-10 21:48 ` 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=c710eea8-a0ea-70b6-6521-0dd685adbb06@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®