[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9e51630d0a376a2df426eace5c25b94641e69306.camel@intel.com>
Date: Wed, 16 Apr 2025 10:33:06 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "Reshetova, Elena" <elena.reshetova@...el.com>, "Hansen, Dave"
<dave.hansen@...el.com>
CC: "linux-sgx@...r.kernel.org" <linux-sgx@...r.kernel.org>, "Scarlata,
Vincent R" <vincent.r.scarlata@...el.com>, "x86@...nel.org" <x86@...nel.org>,
"jarkko@...nel.org" <jarkko@...nel.org>, "Annapurve, Vishal"
<vannapurve@...gle.com>, "Cai, Chong" <chongc@...gle.com>, "Mallick, Asit K"
<asit.k.mallick@...el.com>, "Aktas, Erdem" <erdemaktas@...gle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"bondarn@...gle.com" <bondarn@...gle.com>, "dionnaglaze@...gle.com"
<dionnaglaze@...gle.com>, "Raynor, Scott" <scott.raynor@...el.com>
Subject: Re: [PATCH v3 1/2] x86/sgx: Use sgx_nr_used_pages for EPC page count
instead of sgx_nr_free_pages
On Tue, 2025-04-15 at 14:51 +0300, Elena Reshetova wrote:
> sgx_nr_free_pages is an atomic that is used to keep track of
> free EPC pages and detect whenever page reclaiming should start.
> Since successful execution of ENCLS[EUPDATESVN] requires empty
The mentioning of ENCLS[EUPDATESVN] is kinda out of blue here. It's better to
introduce it first like the next patch does.
> EPC and preferably a fast lockless way of checking for this
> condition in all code paths where EPC is already used, change the
> reclaiming code to track the number of used pages via
> sgx_nr_used_pages instead of sgx_nr_free_pages.
> For this change to work in the page reclamation code, add a new
> variable, sgx_nr_total_pages, that will keep track of total
> number of EPC pages.
>
> It would have been possible to implement ENCLS[EUPDATESVN] using
> existing sgx_nr_free_pages counter and a new sgx_nr_total_pages
> counter, but it won't be possible to avoid taking a lock *every time*
> a new EPC page is being allocated. The conversion of sgx_nr_free_pages
> into sgx_nr_used_pages allows avoiding the lock in all cases except
> when it is the first EPC page being allocated via a quick
> atomic_long_inc_not_zero check.
>
> Note: The serialization for sgx_nr_total_pages is not needed because
> the variable is only updated during the initialization and there's no
> concurrent access.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@...el.com>
Reviewed-by: Kai Huang <kai.huang@...el.com>
Powered by blists - more mailing lists