On Wed Aug 21, 2024 at 4:53 AM EEST, Haitao Huang wrote: > To support the per-cgroup reclamation, each cgroup will have its own > "per-cgroup LRU" and EPC pages will be in its owner cgroup's LRU instead > of the global LRU. Abstract the code that is directly working with the > global LRU into functions reusable with per-cgroup LRUs. > > Currently the basic reclamation procedure, sgx_reclaim_pages() directly > reclaims pages from the global LRU. Change it to take in an LRU. > > Note the global EPC reclamation will still be needed when the total EPC > usage reaches the system capacity while usages of some cgroups are below > their respective limits. Create a separate wrapper for the global > reclamation, sgx_reclaim_pages_global(), passing in the global LRU to > the new sgx_reclaim_pages() now. Later it will be revised to reclaim > from multiple LRUs from all EPC cgroups instead of a single global LRU. > > Wrap the existing emptiness check of the global LRU with a helper so > that it can be changed later to work with multiple LRUs when per-cgroup > LRU comes to play. > > Also the per-cgroup EPC reclaim and global EPC reclaim will have > different check on whether they should be done. Rename the existing > sgx_should_reclaim() to sgx_should_reclaim_global() to separate the two > cases. > > Co-developed-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > Co-developed-by: Kristen Carlson Accardi <kristen@xxxxxxxxxxxxxxx> > Signed-off-by: Kristen Carlson Accardi <kristen@xxxxxxxxxxxxxxx> > Signed-off-by: Haitao Huang <haitao.huang@xxxxxxxxxxxxxxx> Reviewed-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx> BR, Jarkko