diff mbox

[intel-sgx-kernel-dev,RFC,08/12] intel_sgx: declare struct sgx_epc_cgroup and sgx_swap_pages param

Message ID 1497461858-20309-9-git-send-email-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Christopherson June 14, 2017, 5:37 p.m. UTC
Declare struct sgx_epc_cgroup and add an EPC cgroup parameter to
sgx_swap_pages so that the EPC cgroup controller code can be added
without any concurrent changes to the core SGX code.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 drivers/platform/x86/intel_sgx/sgx.h            | 5 ++++-
 drivers/platform/x86/intel_sgx/sgx_page_cache.c | 7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/platform/x86/intel_sgx/sgx.h b/drivers/platform/x86/intel_sgx/sgx.h
index cfd22e4..a9b1bbc 100644
--- a/drivers/platform/x86/intel_sgx/sgx.h
+++ b/drivers/platform/x86/intel_sgx/sgx.h
@@ -158,6 +158,8 @@  static inline void sgx_lru_init(struct sgx_epc_lru *lru)
 	INIT_LIST_HEAD(&lru->active_lru);
 }
 
+struct sgx_epc_cgroup;
+
 extern struct workqueue_struct *sgx_add_page_wq;
 extern struct sgx_epc_bank sgx_epc_banks[];
 extern int sgx_nr_epc_banks;
@@ -237,6 +239,7 @@  enum sgx_swap_flags {
 	SGX_SWAP_IGNORE_LRU	= BIT(0),
 };
 unsigned long sgx_swap_pages(unsigned long nr_to_scan,
-			     unsigned int flags);
+			     unsigned int flags,
+			     struct sgx_epc_cgroup *epc_cg);
 
 #endif /* __ARCH_X86_INTEL_SGX_H__ */
diff --git a/drivers/platform/x86/intel_sgx/sgx_page_cache.c b/drivers/platform/x86/intel_sgx/sgx_page_cache.c
index 6c899cd..86685c1 100644
--- a/drivers/platform/x86/intel_sgx/sgx_page_cache.c
+++ b/drivers/platform/x86/intel_sgx/sgx_page_cache.c
@@ -343,7 +343,8 @@  static inline void sgx_lru_putback(struct list_head *src)
 }
 
 unsigned long sgx_swap_pages(unsigned long nr_to_scan,
-			     unsigned int flags)
+			     unsigned int flags,
+			     struct sgx_epc_cgroup *epc_cg)
 {
 	struct sgx_epc_page *entry, *tmp;
 	struct sgx_encl *encl;
@@ -401,7 +402,7 @@  int ksgxswapd(void *p)
 					 sgx_nr_free_pages < sgx_nr_high_pages);
 
 		if (sgx_nr_free_pages < sgx_nr_high_pages)
-			sgx_swap_pages(SGX_NR_SWAP_CLUSTER_MAX, 0);
+			sgx_swap_pages(SGX_NR_SWAP_CLUSTER_MAX, 0, NULL);
 	}
 
 	pr_info("%s: done\n", __func__);
@@ -514,7 +515,7 @@  struct sgx_epc_page *sgx_alloc_page(unsigned int flags)
 			break;
 		}
 
-		sgx_swap_pages(SGX_NR_SWAP_CLUSTER_MAX, 0);
+		sgx_swap_pages(SGX_NR_SWAP_CLUSTER_MAX, 0, NULL);
 		schedule();
 	}