On Tue, 26 Sep 2023 08:13:18 -0500, Jarkko Sakkinen
wrote:
...
> >> /**
> >> @@ -410,7 +429,14 @@ misc_cg_alloc(struct cgroup_subsys_state
> >> *parent_css)
> >> */
> >> static void misc_cg_free(struct cgroup_subsys_state *css)
> >> {
> >> - kfree(css_misc(css));
> >> + struct misc_cg *c
Hi Kai,
On Wed, 27 Sep 2023 06:14:20 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Sean Christopherson
In a later patch, when a cgroup has exceeded the max capacity for EPC
pages, it may need to identify and OOM kill a less active enclave to
make
On Wed, 27 Sep 2023 16:21:19 -0500, Huang, Kai wrote:
On Wed, 2023-09-27 at 10:35 -0500, Haitao Huang wrote:
> > +
> > + /* Possible owner types */
> > + union {
> > + struct sgx_encl_page *encl_page;
> > + struct sgx_encl *en
On Wed, 27 Sep 2023 05:28:36 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
Use the lower 3 bits in the flags field of sgx_epc_page struct to
track EPC states in its life cycle and define an enum for possible
states. More state(s) will be added later.
This
On Thu, 28 Sep 2023 04:28:34 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
@@ -314,18 +313,22 @@ static void sgx_reclaim_pages(void)
if (kref_get_unless_zero(&encl_page->encl->refcount) != 0) {
sgx_epc_page
On Thu, 28 Sep 2023 04:41:33 -0500, Huang, Kai wrote:
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -746,6 +746,7 @@ void sgx_encl_release(struct kref *ref)
xa_destroy(&encl->page_array);
if (!encl->secs_child_cnt && encl->secs.epc_page) {
+
On Wed, 27 Sep 2023 06:57:18 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Sean Christopherson
When an OOM event occurs, all pages associated with an enclave will need
to be freed, including pages that are not currently tracked by the
cgroup LRU lists
On Wed, 27 Sep 2023 06:35:57 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Sean Christopherson
In a later patch, when a cgroup has exceeded the max capacity for EPC
pages, it may need to identify and OOM kill a less active enclave to
make room for
On Wed, 27 Sep 2023 22:59:12 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Kristen Carlson Accardi
Add SGX EPC memory, MISC_CG_RES_SGX_EPC, to be a valid resource type
for the misc controller.
Add per resource type private data so that SGX can store
On Wed, 27 Sep 2023 04:20:55 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Kristen Carlson Accardi
The misc cgroup controller (subsystem) currently does not perform
resource type specific action for Cgroups Subsystem State (CSS) events:
the 'css_
On Tue, 03 Oct 2023 15:07:42 -0500, Huang, Kai wrote:
On Tue, 2023-10-03 at 01:45 -0500, Haitao Huang wrote:
>
> Btw, probably a dumb question:
>
> Theoretically if you only need to find a victim enclave you don't need
> to put VA
> pages to the unreclaimable list,
On Tue, 03 Oct 2023 15:03:48 -0500, Huang, Kai wrote:
On Mon, 2023-10-02 at 23:49 -0500, Haitao Huang wrote:
On Wed, 27 Sep 2023 05:28:36 -0500, Huang, Kai
wrote:
> On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
> > Use the lower 3 bits in the flags field of sgx_epc_page
Hi Jarkko
On Mon, 02 Oct 2023 17:55:14 -0500, Jarkko Sakkinen
wrote:
...
> >> I noticed this one later:
> >>
> >> It would better to create a separate ops struct and declare the
instance
> >> as const at minimum.
> >>
> >> Then there is no need for dynamic assigment of ops and all that is
On Wed, 04 Oct 2023 16:13:41 -0500, Huang, Kai wrote:
On Wed, 2023-10-04 at 10:03 -0500, Haitao Huang wrote:
On Tue, 03 Oct 2023 15:07:42 -0500, Huang, Kai
wrote:
> On Tue, 2023-10-03 at 01:45 -0500, Haitao Huang wrote:
> > >
> > > Btw, probably a dumb question:
>
On Thu, 05 Oct 2023 07:24:12 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Sean Christopherson
Adjust and expose the top-level reclaim function as
sgx_reclaim_epc_pages() for use by the upcoming EPC cgroup, which will
initiate reclaim to enforce the
On Thu, 05 Oct 2023 07:30:46 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
+static inline struct sgx_epc_lru_lists *sgx_lru_lists(struct
sgx_epc_page *epc_page)
+{
+ return &sgx_global_lru;
+}
+
+static inline bool sgx_can_reclaim(
On Mon, 09 Oct 2023 18:45:06 -0500, Huang, Kai wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
From: Sean Christopherson
Introduce the OOM path for killing an enclave with a reclaimer that is
no
longer able to reclaim enough EPC pages. Find a victim enclave, which
will be
On Mon, 09 Oct 2023 20:18:00 -0500, Huang, Kai wrote:
On Mon, 2023-10-09 at 20:04 -0500, Haitao Huang wrote:
On Mon, 09 Oct 2023 18:45:06 -0500, Huang, Kai
wrote:
> On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
> > From: Sean Christopherson
> >
> > Intro
Hi Sean
On Mon, 09 Oct 2023 19:23:04 -0500, Sean Christopherson
wrote:
On Mon, Oct 09, 2023, Kai Huang wrote:
On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote:
> +/**
> + * sgx_epc_oom() - invoke EPC out-of-memory handling on target LRU
> + * @lru: LRU that is low
> + *
On Mon, 09 Oct 2023 21:23:12 -0500, Huang, Kai wrote:
On Mon, 2023-10-09 at 20:42 -0500, Haitao Huang wrote:
Hi Sean
On Mon, 09 Oct 2023 19:23:04 -0500, Sean Christopherson
wrote:
> On Mon, Oct 09, 2023, Kai Huang wrote:
> > On Fri, 2023-09-22 at 20:06 -0700, Haitao Hu
On Mon, 09 Oct 2023 20:34:29 -0500, Huang, Kai wrote:
On Tue, 2023-10-10 at 00:50 +, Huang, Kai wrote:
On Mon, 2023-10-09 at 17:23 -0700, Sean Christopherson wrote:
> On Mon, Oct 09, 2023, Kai Huang wrote:
> > On Fri, 2023-09-22 at 20:06 -0700, Haitao Hu
On Mon, 09 Oct 2023 21:12:27 -0500, Huang, Kai wrote:
> > >
> > Later the hosting process could migrated/reassigned to another
cgroup?
> > What to do when the new cgroup is OOM?
> >
>
> You addressed in the documentation, no?
>
> +Migration
> +-
> +
> +Once an EPC page is charged t
On Tue, 10 Oct 2023 19:01:25 -0500, Sean Christopherson
wrote:
On Tue, Oct 10, 2023, Haitao Huang wrote:
On Mon, 09 Oct 2023 21:23:12 -0500, Huang, Kai
wrote:
> On Mon, 2023-10-09 at 20:42 -0500, Haitao Huang wrote:
> > Hi Sean
> >
> > On Mon, 09 Oct 2023
On Tue, 10 Oct 2023 19:31:19 -0500, Huang, Kai wrote:
On Tue, 2023-10-10 at 12:05 -0500, Haitao Huang wrote:
On Mon, 09 Oct 2023 21:12:27 -0500, Huang, Kai
wrote:
>
> > > > >
> > > > Later the hosting process could migrated/reassigned to another
> > cgr
On Tue, 10 Oct 2023 19:51:17 -0500, Huang, Kai wrote:
[...]
(btw, even you track VA/SECS pages in unreclaimable list, given they
both have
'enclave' as the owner, do you still need SGX_EPC_OWNER_ENCL and
SGX_EPC_OWNER_PAGE ?)
Let me think about it, there might be also a way just track encl
On Mon, 16 Oct 2023 05:57:36 -0500, Huang, Kai wrote:
On Thu, 2023-10-12 at 08:27 -0500, Haitao Huang wrote:
On Tue, 10 Oct 2023 19:51:17 -0500, Huang, Kai
wrote:
[...]
> (btw, even you track VA/SECS pages in unreclaimable list, given they
> both have
> 'enclave' as
Hi Sean
On Mon, 16 Oct 2023 16:32:31 -0500, Sean Christopherson
wrote:
On Mon, Oct 16, 2023, Haitao Huang wrote:
From this perspective, I think the current implementation is
"well-defined":
EPC cgroup limits for VMs are only enforced at VM launch time, not
runtime.
In practic
On Mon, 16 Oct 2023 16:09:52 -0500, Huang, Kai wrote:
[...]
still need to fix the bug mentioned above here.
I really think you should just go this simple way:
When you want to take EPC back from VM, kill the VM.
My only concern is that this is a compromise due to current limitation (no
o
On Mon, 16 Oct 2023 20:34:57 -0500, Huang, Kai wrote:
On Mon, 2023-10-16 at 19:10 -0500, Haitao Huang wrote:
On Mon, 16 Oct 2023 16:09:52 -0500, Huang, Kai
wrote:
[...]
> still need to fix the bug mentioned above here.
>
> I really think you should just go this simple way:
>
Hi Michal,
On Tue, 17 Oct 2023 13:54:46 -0500, Michal Koutný wrote:
Hello Haitao.
On Tue, Oct 17, 2023 at 07:58:02AM -0500, Haitao Huang
wrote:
AFAIK, before we introducing max_write() callback in this series, no
misc
controller would possibly enforce the limit when misc.max is reduced
On Tue, 17 Oct 2023 14:13:22 -0500, Michal Koutný wrote:
On Tue, Oct 17, 2023 at 08:54:48PM +0200, Michal Koutný
wrote:
Is this distinction between preemptability of EPC pages mandated by the
HW implementation? (host/"process" enclaves vs VM enclaves) Or do have
users an option to lock certa
On Wed, 18 Oct 2023 08:55:12 -0500, Dave Hansen
wrote:
On 10/17/23 21:37, Haitao Huang wrote:
Yes we can introduce misc.reclaim to give user a knob to forcefully
reducing usage if that is really needed in real usage. The semantics
would make force-kill VMs explicit to user.
Do any other
On Wed, 18 Oct 2023 10:52:23 -0500, Michal Koutný wrote:
On Wed, Oct 18, 2023 at 08:37:25AM -0700, Dave Hansen
wrote:
1. Admin sets a limit
2. Enclave is created
3. Enclave hits limit, allocation fails
I was actually about to suggest reorganizing the series to a part
implementing this simp
On Tue, 17 Oct 2023 13:54:54 -0500, Michal Koutný wrote:
On Fri, Sep 22, 2023 at 08:06:55PM -0700, Haitao Huang
wrote:
+static void sgx_epc_cgroup_free(struct misc_cg *cg)
+{
+ struct sgx_epc_cgroup *epc_cg;
+
+ epc_cg = sgx_epc_cgroup_from_misc_cg(cg);
It should check for
On Mon, 09 Oct 2023 19:26:01 -0500, Huang, Kai wrote:
@@ -332,6 +336,7 @@ void sgx_isolate_epc_pages(struct sgx_epc_lru_lists
*lru, size_t nr_to_scan,
* sgx_reclaim_epc_pages() - Reclaim EPC pages from the consumers
* @nr_to_scan: Number of EPC pages to scan for reclaim
916-1-haitao.hu...@linux.intel.com/
[9]https://lore.kernel.org/linux-sgx/20230728051024.33063-1-haitao.hu...@linux.intel.com/
[10]https://lore.kernel.org/all/20230923030657.16148-1-haitao.hu...@linux.intel.com/
Haitao Huang (2):
x86/sgx: Introduce EPC page states
selftests/sgx: Add scripts for
data.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
---
V6:
- Create ops struct for per resource callbacks (Jarkko)
- Drop max_write callback (Dave, Michal)
- Style fixes (Kai)
---
include/linux/misc_cgroup.h | 14 ++
kernel/cgrou
This requires a walk from the current
cgroup up to the root similar to misc_cg_try_charge(). Export
misc_cg_parent() to enable this walk.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
---
V6:
- Make commit messages more concise and split the original
From: Kristen Carlson Accardi
Add SGX EPC memory, MISC_CG_RES_SGX_EPC, to be a valid resource type
for the misc controller.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
---
V6:
- Split the original patch into this and the preceding one (Kai
Accardi
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
---
V5:
- Spelled out SECS, VA (Jarkko)
V4:
- No change, only reordered the patch.
V3:
- Remove usage of list wrapper
---
arch/x86/kernel/cpu/sgx/main.c | 39
cgroup reclaims pages
from the reclaimable list in this structure when its usage reaches near
its limit.
Signed-off-by: Sean Christopherson
Co-developed-by: Kristen Carlson Accardi
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean
count is lower than a threshold.
Later patches will reorganize the tracking and reclamation code in the
globale reclaimer and implement per-cgroup tracking and reclaiming.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed
son
Co-developed-by: Kristen Carlson Accardi
Signed-off-by: Kristen Carlson Accardi
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
---
V6:
- Drop UNRECLAIMABLE and use only 2 bits for states (Kai)
- Combine the patch for RECLAIM_IN_PROGRESS
- Style fixes (Jarkko and Kai)
---
arch/x86/kernel/
rward than using an array.
Signed-off-by: Sean Christopherson
Co-developed-by: Kristen Carlson Accardi
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
---
V6:
- Remove extra list_del_init and style fix (Kai)
V4:
- Changes
be done in LRUs in its children groups.
Signed-off-by: Sean Christopherson
Co-developed-by: Kristen Carlson Accardi
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
---
V6:
- Restructure patches to make it easier to
is enabled, also calling
sgx_epc_cgroup_reclaim_pages().
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
---
V6:
- Drop EPC OOM killer.(Dave, Michal)
- Patch restructuring: thi
ges during testing, run this in a
separate terminal:
./watch_misc_for_tests.sh current
[1] https://github.com/libcgroup/libcgroup/blob/main/README
Signed-off-by: Haitao Huang
---
V5:
- Added script with automatic results checking, remove the interactive
script.
- The script can run independen
-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
---
V6:
- Remove mentioning of VMM specific behavior on handling SIGBUS
- Remove statement of forced reclamation, add statement to specify
ENOMEM returned when no reclamation possible.
- Added statements on the non-preemptive
On Sun, 05 Nov 2023 21:26:44 -0600, Jarkko Sakkinen
wrote:
On Mon, 2023-10-30 at 11:20 -0700, Haitao Huang wrote:
SGX Enclave Page Cache (EPC) memory allocations are separate from
normal RAM allocations, and
are managed solely by the SGX subsystem. The existing cgroup memory
controller
, if the flag is true, switch the
active mem_cgroup to the one returned from sgx_encl_get_mem_cgroup(),
prior to any backing page allocation, in order to ensure that shmem page
allocations are charged to the enclave's cgroup.
Removed current_is_ksgxd() as it is no longer needed.
Signed-off-by: H
There is an issue WRT charging proper mem_cgroups for backing pages once
per-cgroup reclamation is implemented.
Please apply the fix-up patch [1] on top of this patch or the series.
Thanks
Haitao
[1]
https://lore.kernel.org/all/20231106155859.7251-1-haitao.hu...@linux.intel.com/
On Mon, 06 Nov 2023 06:09:45 -0600, Huang, Kai wrote:
On Mon, 2023-10-30 at 11:20 -0700, Haitao Huang wrote:
From: Kristen Carlson Accardi
Implement support for cgroup control of SGX Enclave Page Cache (EPC)
memory using the misc cgroup controller. EPC memory is independent
from normal
On Mon, 06 Nov 2023 16:18:30 -0600, Huang, Kai wrote:
> > +/**
> > + * sgx_epc_cgroup_try_charge() - hierarchically try to charge a
single
> > EPC page
> > + *
> > + * Returns EPC cgroup or NULL on success, -errno on failure.
> > + */
> > +struct sgx_epc_cgroup *sgx_epc_cgroup_try_charge(vo
On Mon, 06 Nov 2023 19:16:30 -0600, Haitao Huang
wrote:
On Mon, 06 Nov 2023 16:18:30 -0600, Huang, Kai
wrote:
> > +/**
> > + * sgx_epc_cgroup_try_charge() - hierarchically try to charge a
single
> > EPC page
> > + *
> > + * Returns EPC cgroup or NULL
On Mon, 06 Nov 2023 09:48:36 -0600, Haitao Huang
wrote:
On Sun, 05 Nov 2023 21:26:44 -0600, Jarkko Sakkinen
wrote:
On Mon, 2023-10-30 at 11:20 -0700, Haitao Huang wrote:
SGX Enclave Page Cache (EPC) memory allocations are separate from
normal RAM allocations, and
are managed solely by
+CG_ROOT=/sys/fs/cgroup
+if [ ! -d "/sys/fs/cgroup/misc" ]; then
+echo "# cgroup V2 is in use."
+else
+echo "# cgroup V1 is in use."
+CG_ROOT=/sys/fs/cgroup/misc
+fi
Does the test need to support v1 cgroups?
I thought some distro may still only support V1. I do my most work on
On Mon, 20 Nov 2023 11:16:42 +0800, Huang, Kai wrote:
> >
>
> That's true. I was thinking no need to have them done in separate
calls.
> The caller has to check the return value for epc_cg instance first,
then
> check result of try_charge. But there is really only one caller,
> sgx_alloc_e
On Mon, 20 Nov 2023 11:45:46 +0800, Huang, Kai wrote:
On Mon, 2023-10-30 at 11:20 -0700, Haitao Huang wrote:
From: Sean Christopherson
To prepare for per-cgroup reclamation, separate the top-level reclaim
function, sgx_reclaim_epc_pages(), into two separate functions
On Mon, 27 Nov 2023 00:01:56 +0800, Haitao Huang
wrote:
> > > > Then here we can have something like:
> > > >
> > > > void sgx_reclaim_pages(struct sgx_epc_cg *epc_cg)
> > > > {
> > > > struct sgx
Hi Kai
On Mon, 27 Nov 2023 03:57:03 -0600, Huang, Kai wrote:
On Mon, 2023-11-27 at 00:27 +0800, Haitao Huang wrote:
On Mon, 20 Nov 2023 11:45:46 +0800, Huang, Kai
wrote:
> On Mon, 2023-10-30 at 11:20 -0700, Haitao Huang wrote:
> > From: Sean Christopherson
> >
> &g
On Wed, 13 Dec 2023 05:17:11 -0600, Huang, Kai wrote:
On Mon, 2023-12-11 at 22:04 -0600, Haitao Huang wrote:
Hi Kai
On Mon, 27 Nov 2023 03:57:03 -0600, Huang, Kai
wrote:
> On Mon, 2023-11-27 at 00:27 +0800, Haitao Huang wrote:
> > On Mon, 20 Nov 2023 11:45:46 +0800, H
On Sun, 17 Dec 2023 19:44:56 -0600, Huang, Kai wrote:
>
> The point is, with or w/o this patch, you can only reclaim 16 EPC
pages
> in one
> function call (as you have said you are going to remove
> SGX_NR_TO_SCAN_MAX,
> which is a cipher to both of us). The only difference I can see is,
nel.org/lkml/20240416032011.58578-1-haitao.hu...@linux.intel.com/
[18]v13:
https://lore.kernel.org/lkml/20240430195108.5676-1-haitao.hu...@linux.intel.com/
Haitao Huang (3):
x86/sgx: Replace boolean parameters with enums
x86/sgx: Charge mem_cgroup for per-cgroup reclamation
selftests/sgx: Add scri
Replace boolean parameters for 'reclaim' in the function
sgx_alloc_epc_page() and its callers with an enum.
Also opportunistically remove non-static declaration of
__sgx_alloc_epc_page() and a typo
Signed-off-by: Haitao Huang
Suggested-by: Jarkko Sakkinen
Suggested-by: Dave Hansen
R
needs start a global level reclamation from the
root. Export misc_cg_root() for the SGX driver to access.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Tejun Heo
Reviewed-by: Kai Huang
Tested-by: J
sten Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Tejun Heo
Reviewed-by: Kai Huang
Tested-by: Jarkko Sakkinen
---
V12:
- Add comments in commit to clarify reason to pass in misc_cg, not
misc_res. (Kai)
- Remove unlikely (Kai)
From: Kristen Carlson Accardi
Add SGX EPC memory, MISC_CG_RES_SGX_EPC, to be a valid resource type
for the misc controller.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Kai Huang
Tested-by: Jarkko
shold.
Later patches will reorganize the tracking and reclamation code in the
global reclaimer and implement per-cgroup tracking and reclaiming.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-of
Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Kai Huang
Tested-by: Jarkko Sakkinen
---
V6:
- removed introduction to unreclaimables in commit message.
V4:
- Removed unneeded comments for the spinlock
ing to
the global LRU directly.
This allows EPC page being able to be tracked in "per-cgroup" LRU when
that becomes ready.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haita
s to
sgx_can_reclaim_global().
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Kai Huang
Tested-by: Jarkko Sakkinen
---
laimable EPC pages are still tracked in the global LRU thus
no per-cgroup reclamation is actually active at the moment. Per-cgroup
tracking and reclamation will be turned on in the end after all
necessary infrastructure is in place.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Tested-by: Jarkko Sakkinen
---
V13:
- Revert to BUG_ON() in case of workq allocation failure in init and
only alloc if misc is enabled.
V11:
- Print error
for an mm struct from enclave's mm_list.
Signed-off-by: Haitao Huang
Reported-by: Mikko Ylinen
Reviewed-by: Kai Huang
Reviewed-by: Jarkko Sakkinen
Tested-by: Mikko Ylinen
Tested-by: Jarkko Sakkinen
---
V10:
- Pass mm struct instead of a boolean 'indirect'. (Dave, Jarkko)
V9:
: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Tested-by: Mikko Ylinen
Tested-by: Jarkko Sakkinen
---
V14:
- Update global reclamation to use the new
-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
Reviewed-by: Bagas Sanjaya
Reviewed-by: Jarkko Sakkinen
Acked-by: Kai Huang
Tested-by: Mikko Ylinen
Tested-by: Jarkko Sakkinen
---
V8:
- Limit text width to 80 characters to be consistent.
V6:
- Remove mentioning of VMM
, it turns off swapping before start,
and turns swapping back on afterwards.
Add README to document how to run the tests.
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Tested-by: Jarkko Sakkinen
---
V13:
- More improvement on handling error cases and style fixes.
- Add settings file
On Tue, 28 May 2024 11:23:13 -0500, Dave Hansen
wrote:
On 5/17/24 04:06, Dmitrii Kuvaiskii wrote:
...
First, why is SGX so special here? How is the SGX problem different
than what the core mm code does?
--- a/arch/x86/kernel/cpu/sgx/encl.h
+++ b/arch/x86/kernel/cpu/sgx/encl.h
@@ -25,6 +25
Hi Jarkko
Thanks for your review.
On Tue, 04 Jun 2024 17:00:34 -0500, Jarkko Sakkinen
wrote:
On Sat Jun 1, 2024 at 1:26 AM EEST, Haitao Huang wrote:
With different cgroups, the script starts one or multiple concurrent SGX
selftests (test_sgx), each to run the
On Thu, 06 Jun 2024 00:32:55 -0500, Jarkko Sakkinen
wrote:
On Wed Jun 5, 2024 at 6:33 PM EEST, Haitao Huang wrote:
sgx_cgroup_try_charge() expects sgx_cg_wq, so it would break unless we
check and return 0 which was the initially implemented in v12. But then
Kai had some concern on that we
On Thu, 06 Jun 2024 08:37:31 -0500, chenridong
wrote:
If _misc_cg_res_alloc fails, maybe some types do not call ->alloc(), but
all types ->free() callback >will be called, is that ok?
Not sure I understand. Are you suggesting we ignore failures from
->alloc() callback in _misc_cg_r
, just call _misc_cg_res_free(cg, MISC_CG_RES_TYPES)
to free all.
That makes sense now, Will do that.
(BTW you need comment inline :-)
Thanks
Haitao
On 2024/6/6 22:51, Haitao Huang wrote:
On Thu, 06 Jun 2024 08:37:31 -0500, chenridong
wrote:
If _misc_cg_res_alloc fails, maybe some
On Mon, 10 Jun 2024 17:39:53 -0500, Huang, Kai wrote:
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -1045,7 +1045,7 @@ static int __init sgx_init(void)
if (!sgx_page_cache_init())
return -ENOMEM;
-if (!sgx_page_reclaimer_init()) {
+if
On Tue, 18 Jun 2024 06:31:09 -0500, Huang, Kai wrote:
@@ -921,7 +956,8 @@ static int __init sgx_init(void)
if (!sgx_page_cache_init())
return -ENOMEM;
- if (!sgx_page_reclaimer_init()) {
+ if (!sgx_page_reclaimer_init() || !sgx_cgroup_init()) {
+
On Tue, 18 Jun 2024 18:15:37 -0500, Huang, Kai wrote:
On Tue, 2024-06-18 at 07:56 -0500, Haitao Huang wrote:
On Tue, 18 Jun 2024 06:31:09 -0500, Huang, Kai
wrote:
>
> > @@ -921,7 +956,8 @@ static int __init sgx_init(void)
> > if (!sgx_page_cache_init())
> >
Hi Kai
On Thu, 20 Jun 2024 05:30:16 -0500, Huang, Kai wrote:
On 18/06/2024 12:53 am, Huang, Haitao wrote:
From: Kristen Carlson Accardi
Previous patches have implemented all infrastructure needed for
per-cgroup EPC page tracking and reclaiming. But all reclaimable EPC
pages are still track
+ if (cgroup_subsys_enabled(misc_cgrp_subsys)) {
+ sgx_cg_wq = alloc_workqueue("sgx_cg_wq", WQ_UNBOUND |
WQ_FREEZABLE,
+ WQ_UNBOUND_MAX_ACTIVE);
+ return -ENOMEM;
Argh, missing if(!sgx_cg_wq), sorry for the brain far
On Thu, 20 Jun 2024 08:28:57 -0500, Huang, Kai wrote:
On 18/06/2024 12:53 am, Huang, Haitao wrote:
From: Kristen Carlson Accardi
Currently in the EPC page allocation, the kernel simply fails the
allocation when the current EPC cgroup fails to charge due to its usage
reaching limit. This
reclaimed. A
future commit will introduce a new case when the enclave page is being
removed; this new case will set only the SGX_ENCL_PAGE_BUSY flag.
LGTM.
Reviewed-by: Haitao Huang
Thanks
Haitao
esc |= SGX_ENCL_PAGE_BUSY;
mutex_unlock(&encl->lock);
sgx_zap_enclave_ptes(encl, addr);
Reviewed-by: Haitao Huang
Thanks
Haitao
467-1-haitao.hu...@linux.intel.com/
[17]v12:
https://lore.kernel.org/lkml/20240416032011.58578-1-haitao.hu...@linux.intel.com/
[18]v13:
https://lore.kernel.org/lkml/20240430195108.5676-1-haitao.hu...@linux.intel.com/
[19]v14:
https://lore.kernel.org/linux-sgx/20240531222630.4634-1-haitao.hu...@l
Replace boolean parameters for 'reclaim' in the function
sgx_alloc_epc_page() and its callers with an enum.
Also opportunistically remove non-static declaration of
__sgx_alloc_epc_page() and a typo
Signed-off-by: Haitao Huang
Suggested-by: Jarkko Sakkinen
Suggested-by: Dave Hansen
R
sc_cg' to the callbacks but not the 'struct misc_res' because
the latter doesn't have a pointer pointing back to 'struct misc_cg'.
Link:
https://lore.kernel.org/lkml/op.2kdw36otwjv...@hhuan26-mobl.amr.corp.intel.com/
Signed-off-by: Kristen Carlson Accardi
Co-developed-b
needs start a global level reclamation from the
root. Export misc_cg_root() for the SGX driver to access.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Tejun Heo
Reviewed-by: Kai Huang
Tested-by: J
From: Kristen Carlson Accardi
Add SGX EPC memory, MISC_CG_RES_SGX_EPC, to be a valid resource type
for the misc controller.
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Kai Huang
Tested-by: Jarkko
shold.
Later patches will reorganize the tracking and reclamation code in the
global reclaimer and implement per-cgroup tracking and reclaiming.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-of
Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haitao Huang
Cc: Sean Christopherson
Reviewed-by: Jarkko Sakkinen
Reviewed-by: Kai Huang
Tested-by: Jarkko Sakkinen
---
V15:
- Add comment for spinlock. (Jarkko, Kai)
V6:
- removed introduction to unreclaimables in commit message.
V4
eparate the two
cases.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Co-developed-by: Kristen Carlson Accardi
Signed-off-by: Kristen Carlson Accardi
Signed-off-by: Haitao Huang
---
v16:
- Regroup all abstraction related to global LRU usage to this patch from
diffe
ing to
the global LRU directly.
This allows EPC page being able to be tracked in "per-cgroup" LRU when
that becomes ready.
Co-developed-by: Sean Christopherson
Signed-off-by: Sean Christopherson
Signed-off-by: Kristen Carlson Accardi
Co-developed-by: Haitao Huang
Signed-off-by: Haita
en Carlson Accardi
Signed-off-by: Kristen Carlson Accardi
Signed-off-by: Haitao Huang
---
V16:
- Revise commit log to define reclamation requirement and the design more
clearly. (Kai)
- Revise sgx_cgroup_reclaim_pages() to scan cgroups in subtree more
fairly, track next_cg in each sgx_cgroup and a
201 - 300 of 393 matches
Mail list logo