On Fri, Dec 02, 2022 at 10:36:49AM -0800, Kristen Carlson Accardi wrote: > From: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > > Move the isolation loop into a standalone helper, sgx_isolate_pages(), > in preparation for existence of multiple LRUs. Expose the helper to > other SGX code so that it can be called from the EPC cgroup code, e.g. > to isolate pages from a single cgroup LRU. Exposing the isolation loop > allows the cgroup iteration logic to be wholly encapsulated within the > cgroup code. > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > Signed-off-by: Kristen Carlson Accardi <kristen@xxxxxxxxxxxxxxx> > Cc: Sean Christopherson <seanjc@xxxxxxxxxx> > --- > arch/x86/kernel/cpu/sgx/main.c | 68 +++++++++++++++++++++------------- > arch/x86/kernel/cpu/sgx/sgx.h | 2 + > 2 files changed, 44 insertions(+), 26 deletions(-) > > diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c > index c947b4ae06f3..a59550fa150b 100644 > --- a/arch/x86/kernel/cpu/sgx/main.c > +++ b/arch/x86/kernel/cpu/sgx/main.c > @@ -280,7 +280,46 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, > } > > /** > - * sgx_reclaim_pages() - Reclaim EPC pages from the consumers > + * sgx_isolate_epc_pages() - Isolate pages from an LRU for reclaim > + * @lru: LRU from which to reclaim > + * @nr_to_scan: Number of pages to scan for reclaim > + * @dst: Destination list to hold the isolated pages > + */ > +void sgx_isolate_epc_pages(struct sgx_epc_lru_lists *lru, int *nr_to_scan, > + struct list_head *dst) Why not instead return the number of pages scanned, and pass 'int nr_to_scan'? That would just be more idiomatic choice. BR, Jarkko