From: Kristen Carlson Accardi Subject: [PATCH 13/26] x86/sgx: Prepare for multiple LRUs Date: Fri, 11 Nov 2022 10:35:18 -0800 Message-ID: <20221111183532.3676646-14-kristen@linux.intel.com> References: <20221111183532.3676646-1-kristen@linux.intel.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668191765; x=1699727765; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tdinHlyyGqVYquaFqgcvC9rbRf2JmMok2HdQOnKfOO0=; b=kQNug6BumCzHV+Fz26lBnWpC6rlBPPrsDXL0pxOp5hB0JkA4jnJRgOPi kz5oxfnJZlMIuJDZ7wtPO3eJQe9LOWGnrrLi3DJxcUVMnyPrMuKh19BgB 55MrZUl7rjW065OKk+Lwcl/u0TivsHL7aNU6Em/pltOXyVl/MeMcJdB09 z7AmC0dEZier/ZCijcxdG5Fd37LF7ddD8lBuyosgD0h49oeqEWOuY66Pa 0tosQkA3HwIeb7Hgz4OSM8aqaNlmB2Fuwh4sXWn8AIkD3aj8sTIR4rSj5 dpWLe8XD1HH6rPfIw/1zn8ajBdYtFjtn4ZKYVs1e7sRgoEm/sNrzGtNJ+ g==; In-Reply-To: <20221111183532.3676646-1-kristen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" To: jarkko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, dave.hansen-CPWUtch7KCBzeIdxy0IIJw@public.gmane.org, tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-sgx-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, "H. Peter Anvin" Cc: zhiquan1.li-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, Kristen Carlson Accardi , Sean Christopherson From: Sean Christopherson Add sgx_can_reclaim() wrapper so that in a subsequent patch, multiple LRUs can be used cleanly. Signed-off-by: Sean Christopherson Signed-off-by: Kristen Carlson Accardi Cc: Sean Christopherson --- arch/x86/kernel/cpu/sgx/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index c33966eafab6..b2c050fcc989 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -391,10 +391,15 @@ static int sgx_reclaim_pages(int nr_to_scan, bool ignore_age) return ret; } +static bool sgx_can_reclaim(void) +{ + return !list_empty(&sgx_global_lru.reclaimable); +} + static bool sgx_should_reclaim(unsigned long watermark) { return atomic_long_read(&sgx_nr_free_pages) < watermark && - !list_empty(&sgx_global_lru.reclaimable); + sgx_can_reclaim(); } /* @@ -599,7 +604,7 @@ struct sgx_epc_page *sgx_alloc_epc_page(void *owner, bool reclaim) break; } - if (list_empty(&sgx_global_lru.reclaimable)) + if (!sgx_can_reclaim()) return ERR_PTR(-ENOMEM); if (!reclaim) { -- 2.37.3