On 7/18/23 13:32, Haitao Huang wrote: ... > Ignore VA pages for now. Say for a system with 10 page EPC, 2 enclaves, > each needs 5 pages non-SECS so total demand would be 12 pages. The ksgxd > would only need to swap out 2 pages at the most to get one enclave fully > loaded with 6 pages, and the other one with 4 pages. There is no chance > the ksgxd would swap any one of two SECS pages. > > We would need at least one enclave A of 10 pages total to squeeze out > the other B completely. For that to happen B pretty much has to be > sleeping all the time so the LRU based reclaiming would hit it but not > pages of A. So no chance to hit #PF on pages of B still. > > So some minimal pressure is needed to ensure SECS swapped. The higher > the pressure the higher the chance to hit #PF while SECS is swapped. What would the second-to-last non-SECS page be? A thread control page? VA page? As long as *that* page can generate a page fault, then you only need two pages for this scenario to happen: 1. Reclaimer takes encl->lock 2. #PF occurs from another thread, blocks on encl->lock 3. SECS is reclaimed 4. encl->lock released 5. #PF sees reclaimed SECS