@@ -255,6 +255,18 @@ void sgx_cgroup_reclaim_direct(void)
sgx_put_cg(sgx_cg);
}
+/**
+ * sgx_cgroup_reclaim_pages_global() - Perform one round of global reclamation.
+ *
+ * @charge_mm: The mm to be charged for the backing store of reclaimed pages.
+ *
+ * Try to scan and attempt reclamation from root cgroup for %SGX_NR_TO_SCAN pages.
+ */
+void sgx_cgroup_reclaim_pages_global(struct mm_struct *charge_mm)
+{
+ sgx_cgroup_reclaim_pages(&sgx_cg_root, charge_mm, SGX_NR_TO_SCAN);
+}
+
/*
* Asynchronous work flow to reclaim pages from the cgroup when the cgroup is
* at/near its maximum capacity.
@@ -36,6 +36,7 @@ static inline int __init sgx_cgroup_wq_init(void)
static inline void __init sgx_cgroup_wq_deinit(void) { }
static inline void sgx_cgroup_reclaim_direct(void) { }
+static inline void sgx_cgroup_reclaim_pages_global(struct mm_struct *charge_mm) { }
#else /* CONFIG_CGROUP_MISC */
@@ -89,6 +90,7 @@ static inline void sgx_put_cg(struct sgx_cgroup *sgx_cg)
int sgx_cgroup_try_charge(struct sgx_cgroup *sgx_cg, enum sgx_reclaim reclaim);
void sgx_cgroup_uncharge(struct sgx_cgroup *sgx_cg);
void sgx_cgroup_reclaim_direct(void);
+void sgx_cgroup_reclaim_pages_global(struct mm_struct *charge_mm);
void __init sgx_cgroup_init(void);
int __init sgx_cgroup_wq_init(void);
void __init sgx_cgroup_wq_deinit(void);
@@ -42,6 +42,13 @@ static inline struct sgx_epc_lru_list *sgx_epc_page_lru(struct sgx_epc_page *epc
*/
static inline bool sgx_can_reclaim_global(void)
{
+ /*
+ * Now all EPC pages are still tracked in the @sgx_global_lru, so only
+ * check @sgx_global_lru.
+ *
+ * When EPC pages are tracked in the actual per-cgroup LRUs,
+ * replace with sgx_cgroup_lru_empty(misc_cg_root()).
+ */
return !list_empty(&sgx_global_lru.reclaimable);
}
@@ -404,6 +411,13 @@ static bool sgx_should_reclaim_global(unsigned long watermark)
static void sgx_reclaim_pages_global(struct mm_struct *charge_mm)
{
+ /*
+ * Now all EPC pages are still tracked in the @sgx_global_lru.
+ * Still reclaim from it.
+ *
+ * When EPC pages are tracked in the actual per-cgroup LRUs,
+ * sgx_cgroup_reclaim_pages_global() will be called.
+ */
sgx_reclaim_pages(&sgx_global_lru, charge_mm);
}