Re: [PATCH v16 10/16] x86/sgx: Implement async reclamation for cgroup

From
Jarkko Sakkinen <jarkko@kernel.org>
Date
2024-08-27 18:16:02
Also in
lkml
Reply to
Haitao Huang, 2024-08-21
On Wed Aug 21, 2024 at 4:53 AM EEST, Haitao Huang wrote:
From: Kristen Carlson Accardi <redacted>

In cases EPC pages need be allocated during a page fault and the cgroup
usage is near its limit, an asynchronous reclamation needs to be
triggered to avoid blocking the page fault handling.

To keep implementation simple, use a workqueue instead of kthread to
schedule the asynchronous reclamation work. Add corresponding work item and
function definitions for EPC cgroup.

In sgx_cgroup_try_charge(), if caller does not allow synchronous
reclamation, queue an asynchronous work into the workqueue.

The current global reclaimer, ksgxd, maintains a threshold for the
minimal free EPC pages to avoid thrashing when allocating EPC pages.
Similarly, only reclaiming EPC pages from the current cgroup when its
usage actually reaches limit could also cause thrashing.  To avoid that,
define a similar "per-cgroup usage threshold" and actively trigger
asynchronous per-cgroup EPC reclamation when the usage reaches the
threshold after try_charge() is successful.

Co-developed-by: Sean Christopherson <redacted>
Signed-off-by: Sean Christopherson <redacted>
Signed-off-by: Kristen Carlson Accardi <redacted>
Co-developed-by: Haitao Huang <redacted>
Signed-off-by: Haitao Huang <redacted>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko
Thread (42 messages) 42 messages, 4 authors, last reply 2024-08-29
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help