From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Haitao Huang" <haitao.huang@linux.intel.com>,
<dave.hansen@linux.intel.com>, <kai.huang@intel.com>,
<tj@kernel.org>, <mkoutny@suse.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 v14 14/14] selftests/sgx: Add scripts for EPC cgroup testing
Date: Wed, 05 Jun 2024 01:00:34 +0300 [thread overview]
Message-ID: <D1RKK8CENNXI.1KMNDADV9C1YM@kernel.org> (raw)
In-Reply-To: <20240531222630.4634-15-haitao.huang@linux.intel.com>
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 unclobbered_vdso_oversubscribed
> test case, which loads an enclave of EPC size equal to the EPC capacity
> available on the platform. The script checks results against the
> expectation set for each cgroup and reports success or failure.
>
> The script creates 3 different cgroups at the beginning with following
> expectations:
>
> 1) small - intentionally small enough to fail the test loading an
> enclave of size equal to the capacity.
> 2) large - large enough to run up to 4 concurrent tests but fail some if
> more than 4 concurrent tests are run. The script starts 4 expecting at
> least one test to pass, and then starts 5 expecting at least one test
> to fail.
> 3) larger - limit is the same as the capacity, large enough to run lots of
> concurrent tests. The script starts 8 of them and expects all pass.
> Then it reruns the same test with one process randomly killed and
> usage checked to be zero after all processes exit.
>
> The script also includes a test with low mem_cg limit and large sgx_epc
> limit to verify that the RAM used for per-cgroup reclamation is charged
> to a proper mem_cg. For this test, 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 <haitao.huang@linux.intel.com>
> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Reorg:
void sgx_cgroup_init(void)
{
struct workqueue_struct *wq;
/* eagerly allocate the workqueue: */
wq = alloc_workqueue("sgx_cg_wq", wq_unbound | wq_freezable, wq_unbound_max_active);
if (!wq) {
pr_warn("sgx_cg_wq creation failed\n");
return;
}
misc_cg_set_ops(MISC_CG_RES_SGX_EPC, &sgx_cgroup_ops);
sgx_cgroup_misc_init(misc_cg_root(), &sgx_cg_root);
/* Depending on misc state, keep or destory the workqueue: */
if (cgroup_subsys_enabled(misc_cgrp_subsys))
sgx_cg_wq = wq;
else
destroy_workqueue(wq);
}
BTW, why two previous operations are performed if subsystem is not
enabled?
I.e. why not instead:
void sgx_cgroup_init(void)
{
struct workqueue_struct *wq;
/* Eagerly allocate the workqueue: */
wq = alloc_workqueue("sgx_cg_wq", wq_unbound | wq_freezable, wq_unbound_max_active);
if (!wq) {
pr_warn("sgx_cg_wq creation failed\n");
return;
}
if (!cgroup_subsys_enabled(misc_cgrp_subsys)) {
destroy_workqueue(wq);
return;
}
misc_cg_set_ops(MISC_CG_RES_SGX_EPC, &sgx_cgroup_ops);
sgx_cgroup_misc_init(misc_cg_root(), &sgx_cg_root);
sgx_cg_wq = wq;
}
Finally, why this does not have __init? And neither sgx_cgroup_misc_init().
The names for these are also somewhat confusing, maybe something like:
* __sgx_cgroups_misc_init()
* sgx_cgroups_misc_init()
And both with __init.
I just made a trivial checkpatch run as a final check, and spotted the
warning on BUG_ON(), and noticed that this can't be right as it is but
please comment and correct where I might have gotten something wrong.
With "--strict" flag I also catched these:
CHECK: spinlock_t definition without comment
#1308: FILE: arch/x86/kernel/cpu/sgx/sgx.h:122:
+ spinlock_t lock;
CHECK: multiple assignments should be avoided
#444: FILE: kernel/cgroup/misc.c:450:
+ parent_cg = cg = &root_cg;
BR, Jarkko
next prev parent reply other threads:[~2024-06-04 22:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 22:26 [PATCH v14 00/14] Add Cgroup support for SGX EPC memory Haitao Huang
2024-05-31 22:26 ` [PATCH v14 01/14] x86/sgx: Replace boolean parameters with enums Haitao Huang
2024-05-31 22:26 ` [PATCH v14 02/14] cgroup/misc: Add per resource callbacks for CSS events Haitao Huang
[not found] ` <eeb1f936-2989-4de0-8353-b2373ce47474@huawei.com>
2024-06-06 14:51 ` Haitao Huang
2024-06-07 1:53 ` chenridong
2024-06-07 14:23 ` Haitao Huang
2024-05-31 22:26 ` [PATCH v14 03/14] cgroup/misc: Export APIs for SGX driver Haitao Huang
2024-05-31 22:26 ` [PATCH v14 04/14] cgroup/misc: Add SGX EPC resource type Haitao Huang
2024-05-31 22:26 ` [PATCH v14 05/14] x86/sgx: Implement basic EPC misc cgroup functionality Haitao Huang
2024-05-31 22:26 ` [PATCH v14 06/14] x86/sgx: Add sgx_epc_lru_list to encapsulate LRU list Haitao Huang
2024-05-31 22:26 ` [PATCH v14 07/14] x86/sgx: Abstract tracking reclaimable pages in LRU Haitao Huang
2024-05-31 22:26 ` [PATCH v14 08/14] x86/sgx: Add basic EPC reclamation flow for cgroup Haitao Huang
2024-05-31 22:26 ` [PATCH v14 09/14] x86/sgx: Abstract check for global reclaimable pages Haitao Huang
2024-05-31 22:26 ` [PATCH v14 10/14] x86/sgx: Implement async reclamation for cgroup Haitao Huang
2024-05-31 22:26 ` [PATCH v14 11/14] x86/sgx: Charge mem_cgroup for per-cgroup reclamation Haitao Huang
2024-05-31 22:26 ` [PATCH v14 12/14] x86/sgx: Turn on per-cgroup EPC reclamation Haitao Huang
2024-05-31 22:26 ` [PATCH v14 13/14] Docs/x86/sgx: Add description for cgroup support Haitao Huang
2024-05-31 22:26 ` [PATCH v14 14/14] selftests/sgx: Add scripts for EPC cgroup testing Haitao Huang
2024-06-04 22:00 ` Jarkko Sakkinen [this message]
2024-06-05 15:33 ` Haitao Huang
2024-06-05 22:30 ` Huang, Kai
2024-06-06 6:20 ` Jarkko Sakkinen
2024-06-06 6:23 ` Jarkko Sakkinen
2024-06-06 5:32 ` Jarkko Sakkinen
2024-06-06 13:13 ` Haitao Huang
2024-06-10 22:39 ` Huang, Kai
2024-06-11 12:57 ` Haitao Huang
2024-06-11 21:56 ` Huang, Kai
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=D1RKK8CENNXI.1KMNDADV9C1YM@kernel.org \
--to=jarkko@kernel.org \
--cc=anakrish@microsoft.com \
--cc=bp@alien8.de \
--cc=cgroups@vger.kernel.org \
--cc=chrisyan@microsoft.com \
--cc=dave.hansen@linux.intel.com \
--cc=haitao.huang@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--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