Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-22 Thread Haitao Huang
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

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-19 Thread Haitao Huang
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 !epc

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-17 Thread Michal Koutný
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 !epc_cg since the misc controller implementation in misc_cg_a

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-10 Thread Huang, Kai
On Fri, 2023-09-22 at 20:06 -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 system memory, e.g. must be reserved at boot from RAM

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-10 Thread Huang, Kai
> + > +static inline struct sgx_epc_cgroup *sgx_epc_cgroup_from_misc_cg(struct > misc_cg *cg) > +{ > + if (cg) > + return (struct sgx_epc_cgroup > *)(cg->res[MISC_CG_RES_SGX_EPC].priv); > + > + return NULL; > +} > + > Is it good idea to allow passing a NULL @cg to this basi

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-09 Thread Huang, Kai
> @@ -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 > * @ignore_age: Reclaim a page even i

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-09 Thread Huang, Kai
> +static inline struct sgx_epc_lru_lists *epc_cg_lru(struct sgx_epc_cgroup > *epc_cg) > +{ > + if (epc_cg) > + return &epc_cg->lru; > + return NULL; > +} > It's legal to return NULL EPC cgroup for a given EPC page, i.e., when the enclave isn't assigned to any cgroup. But .

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-09 Thread Huang, Kai
> +/** > + * sgx_epc_cgroup_lru_empty() - check if a cgroup tree has no pages on its > lrus > + * @root:root of the tree to check > + * > + * Return: %true if all cgroups under the specified root have empty LRU > lists. > + * Used to avoid livelocks due to a cgroup having a non-zero charge c

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-10-05 Thread Huang, Kai
> --- > arch/x86/Kconfig | 13 + > arch/x86/kernel/cpu/sgx/Makefile | 1 + > arch/x86/kernel/cpu/sgx/epc_cgroup.c | 415 +++ > arch/x86/kernel/cpu/sgx/epc_cgroup.h | 59 > arch/x86/kernel/cpu/sgx/main.c | 68 - > arch/x86/kernel/

Re: [PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-09-25 Thread Jarkko Sakkinen
On Sat Sep 23, 2023 at 6:06 AM EEST, 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 system memory, e.g. must be reserved at boot from RAM