From: Dave Hansen <dave.hansen@intel.com>
To: "Reshetova, Elena" <elena.reshetova@intel.com>
Cc: "jarkko@kernel.org" <jarkko@kernel.org>,
"seanjc@google.com" <seanjc@google.com>,
"Huang, Kai" <kai.huang@intel.com>,
"mingo@kernel.org" <mingo@kernel.org>,
"linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"Mallick, Asit K" <asit.k.mallick@intel.com>,
"Scarlata, Vincent R" <vincent.r.scarlata@intel.com>,
"Cai, Chong" <chongc@google.com>,
"Aktas, Erdem" <erdemaktas@google.com>,
"Annapurve, Vishal" <vannapurve@google.com>,
"dionnaglaze@google.com" <dionnaglaze@google.com>,
"Bondarevska, Nataliia" <bondarn@google.com>,
"Raynor, Scott" <scott.raynor@intel.com>
Subject: Re: [PATCH v7 5/5] x86/sgx: Enable automatic SVN updates for SGX enclaves
Date: Mon, 14 Jul 2025 08:37:50 -0700 [thread overview]
Message-ID: <c1421f42-4107-4a6a-80f3-c46d915b40a6@intel.com> (raw)
In-Reply-To: <2cd81800-12ba-460e-ac28-4532d0be1ec9@intel.com>
On 7/14/25 06:54, Dave Hansen wrote:
> On 7/14/25 00:35, Reshetova, Elena wrote:
>> I think you put it: this would require a spinlock in the fast path and
>> *in theory* if we are running many many concurrent enclaves can create
>> contention
> FWIW, my mental model is that spinlocks that are held for short periods
> of time are pretty much the same cost as an atomic under contention.
>
> If there are lots of users, the cost of moving the cacheline for the
> atomic or the spinlock dominates everything else. It doesn't matter
> whether that cacheline is an atomic_t or spinlock_t.
>
> The only difference is that there is _visible_ spinning for a spinlock.
Oh, and I had a brain fart on this one. You've got a mutex, not a spinlock.
But the concept still applies: for small critical sections, the cost of
moving the cacheline dominates the cost of everything else, no matter if
it's a mutex, spinlock or atomic.
Never add complexity unless you're getting actual, real-world
performance out of it. In this case, the only thing you'd _maybe_
improve with added complexity is an open()/close() loop on /dev/sgx,
which is completely unrealistic.
prev parent reply other threads:[~2025-07-14 15:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 16:50 [PATCH v7 0/5] " Elena Reshetova
2025-07-11 16:50 ` [PATCH v7 1/5] x86/sgx: Introduce a counter to count the sgx_(vepc_)open() Elena Reshetova
2025-07-11 16:50 ` [PATCH v7 2/5] x86/cpufeatures: Add X86_FEATURE_SGX_EUPDATESVN feature flag Elena Reshetova
2025-07-11 16:50 ` [PATCH v7 3/5] x86/sgx: Define error codes for use by ENCLS[EUPDATESVN] Elena Reshetova
2025-07-11 16:50 ` [PATCH v7 4/5] x86/sgx: Implement ENCLS[EUPDATESVN] Elena Reshetova
2025-07-11 16:50 ` [PATCH v7 5/5] x86/sgx: Enable automatic SVN updates for SGX enclaves Elena Reshetova
2025-07-11 17:54 ` Dave Hansen
2025-07-14 7:35 ` Reshetova, Elena
2025-07-14 13:54 ` Dave Hansen
2025-07-14 15:37 ` Dave Hansen [this message]
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=c1421f42-4107-4a6a-80f3-c46d915b40a6@intel.com \
--to=dave.hansen@intel.com \
--cc=asit.k.mallick@intel.com \
--cc=bondarn@google.com \
--cc=chongc@google.com \
--cc=dionnaglaze@google.com \
--cc=elena.reshetova@intel.com \
--cc=erdemaktas@google.com \
--cc=jarkko@kernel.org \
--cc=kai.huang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=scott.raynor@intel.com \
--cc=seanjc@google.com \
--cc=vannapurve@google.com \
--cc=vincent.r.scarlata@intel.com \
--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®