From: "Huang, Kai" <kai.huang@intel.com>
To: Haitao Huang <haitao.huang@linux.intel.com>, <jarkko@kernel.org>,
<dave.hansen@linux.intel.com>, <tj@kernel.org>,
<mkoutny@suse.com>, <chenridong@huawei.com>,
<linux-kernel@vger.kernel.org>, <linux-sgx@vger.kernel.org>,
<x86@kernel.org>, <cgroups@vger.kernel.org>, <tglx@linutronix.de>,
<mingo@redhat.com>, <bp@alien8.de>, <hpa@zytor.com>,
<sohil.mehta@intel.com>, <tim.c.chen@linux.intel.com>
Cc: <zhiquan1.li@intel.com>, <kristen@linux.intel.com>,
<seanjc@google.com>, <zhanb@microsoft.com>,
<anakrish@microsoft.com>, <mikko.ylinen@linux.intel.com>,
<yangjie@microsoft.com>, <chrisyan@microsoft.com>
Subject: Re: [PATCH v16 05/16] x86/sgx: Implement basic EPC misc cgroup functionality
Date: Wed, 28 Aug 2024 12:01:57 +1200 [thread overview]
Message-ID: <41ac0f4d-064c-4ece-9c23-3618f1a7bdf5@intel.com> (raw)
In-Reply-To: <f25c789f-e7af-4a6e-8c49-f5e9bbc386d0@intel.com>
On 28/08/2024 11:11 am, Huang, Kai wrote:
>> +static void sgx_cgroup_misc_init(struct misc_cg *cg, struct
>> sgx_cgroup *sgx_cg)
>> +{
>> + cg->res[MISC_CG_RES_SGX_EPC].priv = sgx_cg;
>> + sgx_cg->cg = cg;
>> +}
>> +
>
> [...]
>
>> +int __init sgx_cgroup_init(void)
>> +{
>> + sgx_cgroup_misc_init(misc_cg_root(), &sgx_cg_root);
>> +
>> + return 0;
>> +} > +
>> +/**
>> + * Register capacity and ops for SGX cgroup.
>> + * Only called at the end of sgx_init() when SGX is ready to handle
>> the ops
>> + * callbacks.
>> + */
>> +void __init sgx_cgroup_register(void)
>> +{
>> + unsigned int nid = first_node(sgx_numa_mask);
>> + unsigned int first = nid;
>> + u64 capacity = 0;
>> +
>> + misc_cg_set_ops(MISC_CG_RES_SGX_EPC, &sgx_cgroup_ops);
>> +
>> + /* sgx_numa_mask is not empty when this is called */
>> + do {
>> + capacity += sgx_numa_nodes[nid].size;
>> + nid = next_node_in(nid, sgx_numa_mask);
>> + } while (nid != first);
>> + misc_cg_set_capacity(MISC_CG_RES_SGX_EPC, capacity);
>> +}
>
> [...]
>
>> @@ -930,6 +961,9 @@ static int __init sgx_init(void)
>> if (ret)
>> goto err_kthread;
>> + ret = sgx_cgroup_init();
>> + if (ret)
>> + goto err_provision;
>> /*
>> * Always try to initialize the native *and* KVM drivers.
>> * The KVM driver is less picky than the native one and
>> @@ -943,6 +977,8 @@ static int __init sgx_init(void)
>> if (sgx_vepc_init() && ret)
>> goto err_provision;
>
> In sgx_cgroup_init():
>
> sgx_cgroup_misc_init(misc_cg_root(), &sgx_cg_root);
>
> .. also cannot fail.
>
> I think it should be moved to the sgx_cgroup_register(). Otherwise, if
> any step after sgx_cgroup_init() fails, there's no unwind for the above
> operation.
>
> The consequence is the misc_cg_root()->res[EPC].priv will remain
> pointing to the SGX root cgroup.
>
> It shouldn't cause any real issue for now, but it's weird to have that
> set, and can potentially cause problem in the future.
>
>> + sgx_cgroup_register();
>> +
>> return 0;
>> err_provision:
>
> So, I think we should do:
>
> 1) Rename sgx_cgroup_register() -> sgx_cgroup_init(), and move the
>
> sgx_cgroup_misc_init(misc_cg_root(), &sgx_cg_root);
>
> to it. All operations in the (new) sgx_cgroup_init() won't fail.
>
> 2) Remove (existing) sgx_cgroup_init() form this patch, but introduce it
> in the patch "x86/sgx: Implement async reclamation for cgroup" and
> rename it to sgx_cgroup_prepare() or something. It just allocates
> workqueue inside. And sgx_cgroup_deinit() -> sgx_cgroup_cleanup().
>
> Makes sense?
>
>
With the above addressed, and the k-doc warning fixed:
Reviewed-by: Kai Huang <kai.huang@intel.com>
next prev parent reply other threads:[~2024-08-28 0:02 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 1:53 [PATCH v16 00/16] Add Cgroup support for SGX EPC memory Haitao Huang
2024-08-21 1:53 ` [PATCH v16 01/16] x86/sgx: Replace boolean parameters with enums Haitao Huang
2024-08-21 1:53 ` [PATCH v16 02/16] cgroup/misc: Add per resource callbacks for CSS events Haitao Huang
2024-08-27 10:45 ` Huang, Kai
2024-08-29 9:25 ` Huang, Kai
2024-08-21 1:53 ` [PATCH v16 03/16] cgroup/misc: Export APIs for SGX driver Haitao Huang
2024-08-27 10:25 ` Huang, Kai
2024-08-21 1:53 ` [PATCH v16 04/16] cgroup/misc: Add SGX EPC resource type Haitao Huang
2024-08-21 1:53 ` [PATCH v16 05/16] x86/sgx: Implement basic EPC misc cgroup functionality Haitao Huang
2024-08-27 10:21 ` Huang, Kai
2024-08-27 23:11 ` Huang, Kai
2024-08-28 0:01 ` Huang, Kai [this message]
2024-08-21 1:53 ` [PATCH v16 06/16] x86/sgx: Add sgx_epc_lru_list to encapsulate LRU list Haitao Huang
2024-08-21 1:53 ` [PATCH v16 07/16] x86/sgx: Abstract tracking reclaimable pages in LRU Haitao Huang
2024-08-21 1:53 ` [PATCH v16 08/16] x86/sgx: Encapsulate uses of the global LRU Haitao Huang
2024-08-27 11:13 ` Huang, Kai
2024-08-27 23:58 ` Huang, Kai
2024-08-27 18:15 ` Jarkko Sakkinen
2024-08-21 1:53 ` [PATCH v16 09/16] x86/sgx: Add basic EPC reclamation flow for cgroup Haitao Huang
2024-08-22 4:00 ` Haitao Huang
2024-08-27 18:15 ` Jarkko Sakkinen
2024-08-27 23:42 ` Huang, Kai
2024-08-21 1:53 ` [PATCH v16 10/16] x86/sgx: Implement async reclamation " Haitao Huang
2024-08-27 10:22 ` Huang, Kai
2024-08-27 23:46 ` Huang, Kai
2024-08-27 18:15 ` Jarkko Sakkinen
2024-08-21 1:53 ` [PATCH v16 11/16] x86/sgx: Charge mem_cgroup for per-cgroup reclamation Haitao Huang
2024-08-21 1:54 ` [PATCH v16 12/16] x86/sgx: Revise global reclamation for EPC cgroups Haitao Huang
2024-08-27 11:32 ` Huang, Kai
2024-08-27 23:29 ` Huang, Kai
2024-08-27 18:16 ` Jarkko Sakkinen
2024-08-21 1:54 ` [PATCH v16 13/16] x86/sgx: implement direct reclamation for cgroups Haitao Huang
2024-08-27 18:16 ` Jarkko Sakkinen
2024-08-27 23:55 ` Huang, Kai
2024-08-29 9:34 ` Huang, Kai
2024-08-21 1:54 ` [PATCH v16 14/16] x86/sgx: Turn on per-cgroup EPC reclamation Haitao Huang
2024-08-27 23:25 ` Huang, Kai
2024-08-21 1:54 ` [PATCH v16 15/16] Docs/x86/sgx: Add description for cgroup support Haitao Huang
2024-08-21 1:54 ` [PATCH v16 16/16] selftests/sgx: Add scripts for EPC cgroup testing Haitao Huang
2024-08-27 23:26 ` Huang, Kai
2024-08-26 10:57 ` [PATCH v16 00/16] Add Cgroup support for SGX EPC memory Mikko Ylinen
2024-08-27 18:18 ` 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=41ac0f4d-064c-4ece-9c23-3618f1a7bdf5@intel.com \
--to=kai.huang@intel.com \
--cc=anakrish@microsoft.com \
--cc=bp@alien8.de \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=chrisyan@microsoft.com \
--cc=dave.hansen@linux.intel.com \
--cc=haitao.huang@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mikko.ylinen@linux.intel.com \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=seanjc@google.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=tj@kernel.org \
--cc=x86@kernel.org \
--cc=yangjie@microsoft.com \
--cc=zhanb@microsoft.com \
--cc=zhiquan1.li@intel.com \
/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