From patchwork Wed Jun 14 17:37:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 9787111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 940526038F for ; Wed, 14 Jun 2017 17:38:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7931FF13 for ; Wed, 14 Jun 2017 17:38:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 725EF27813; Wed, 14 Jun 2017 17:38:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2DED91FF13 for ; Wed, 14 Jun 2017 17:38:03 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4486D21A16ED1; Wed, 14 Jun 2017 10:36:47 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AD99421A16EC1 for ; Wed, 14 Jun 2017 10:36:44 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jun 2017 10:37:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,341,1493708400"; d="scan'208";a="113210034" Received: from sjchrist-ts.jf.intel.com ([10.54.74.20]) by orsmga005.jf.intel.com with ESMTP; 14 Jun 2017 10:37:45 -0700 From: Sean Christopherson To: intel-sgx-kernel-dev@lists.01.org Date: Wed, 14 Jun 2017 10:37:34 -0700 Message-Id: <1497461858-20309-9-git-send-email-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497461858-20309-1-git-send-email-sean.j.christopherson@intel.com> References: <1497461858-20309-1-git-send-email-sean.j.christopherson@intel.com> Subject: [intel-sgx-kernel-dev] [RFC][PATCH 08/12] intel_sgx: declare struct sgx_epc_cgroup and sgx_swap_pages param X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Project: Intel® Software Guard Extensions for Linux*: https://01.org/intel-software-guard-extensions" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-sgx-kernel-dev-bounces@lists.01.org Sender: "intel-sgx-kernel-dev" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 --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(); }