Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2526488rwb; Fri, 2 Dec 2022 11:00:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7SblKOu7k7J0zbasKHPnoBwZUwzWXXvV/cPPqC8kK5PVbL6y2CvoeUem+Gv6NNTnEUbRKh X-Received: by 2002:a05:6402:5021:b0:460:5340:d522 with SMTP id p33-20020a056402502100b004605340d522mr53413450eda.87.1670007608640; Fri, 02 Dec 2022 11:00:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670007608; cv=none; d=google.com; s=arc-20160816; b=g+RAFlg5++aQAWlZ2Dfa75jZJPpeBT0h0Hc4zS7kVKZg0FHlg68/7he8zG86yCmhMa 5IFl3YHEfyvRmzmfYw1VPuS5yXC10Q00L7HLA8H1rI6rVD+2ZgJ6tsZFtbe4RnDu61W9 KA3LtCnQPmqB8b/y6gYZcYWWZ/1165rrFqVmRHk+rQBuV+3ux1oc7kK32jbAPJBy6jqD zPJ2WvCOdXlLlXERSivXrgYshc9j5+aCtG28h7ZaztI5ZZn7rNzIOr08MDMi4SuR9T/6 RiHIo4pf85NGwKZBoswLWPxbJM/Omfu/48urlwlhvkWdgj/QQDvT3y4tcFAxFcsEgJfb A4nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mY214QnNK6FoyLzDfPbVjB9mniryc0WmkrrNwJniIbU=; b=FHtnrPEysDR0MA04V1P3B1HrtLd9bgoSU7uqTlxEL0HyN2Ba+zThgEGp3b8XKLexZ7 vIiZYkyhGUNiocgWZzwo4fX4Mnm0GTstdvGhJQzTl41gJthiNZ5oTbKebqQarH15cBWP TTspRrZIFcN6ODcVbKG/jEA0Z4c7DdQDpNRqTufNJ77F3CllZjCO7y8CJT21zmZNV1dn ISBP7Tc8LC+2LWWcp+EwoxMAU+jAU5FmvVKUPe5xO8DUvoD5vHLOjlE7bX7Y82vLxXhQ 97znT2TwwD+rDCmQJLBgU+MzSgwmJcr+U6HaKhs4HLtQQQ5ALzFW+iEYmdLQ9C22O6Qm mprA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XbcsOr+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020aa7d992000000b0046ab57f617bsi5766487eds.633.2022.12.02.10.59.48; Fri, 02 Dec 2022 11:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XbcsOr+W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234584AbiLBSi1 (ORCPT + 82 others); Fri, 2 Dec 2022 13:38:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbiLBShv (ORCPT ); Fri, 2 Dec 2022 13:37:51 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6466EBCBF; Fri, 2 Dec 2022 10:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670006246; x=1701542246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UYpUlq+6H1OK5zNVWPbJu6ZZ/ARyRWJyKUaDzZw64U4=; b=XbcsOr+W7KNHyshrAEZOusqAx5gaBk4z2MtzqvNjf6HLhjwk5n678+Gk 9tnmKoaopQFpGbB6UZg/RAnD2bQmmBSZPBbKkhryB2t3j8soUeYs15B1R z2PZUgXCTaz2V6IBtbh/14jVofCds1X5aQ+zAkR4w/b22Y8j9dwur1rAy hPA5GOlwnA7Lt1Z4d/K6lqy9HMTo5FsuAE4aSWkJyz//igtdb+vZtGxTX pl5J28hGUD7z+cVl1xHvZc2+bc94Xm09k4ymHMvdt+5alrAVSwFCKQJIj oGG0iiA3ROdhWGhfLRZxhgNCwiBvi5EJj/VGuQ7kBiX+4YUllAgQnSdRl w==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="314724623" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="314724623" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 10:37:25 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="713717527" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="713717527" Received: from kcaskeyx-mobl1.amr.corp.intel.com (HELO kcaccard-desk.amr.corp.intel.com) ([10.251.1.207]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 10:37:24 -0800 From: Kristen Carlson Accardi To: jarkko@kernel.org, dave.hansen@linux.intel.com, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: zhiquan1.li@intel.com, Kristen Carlson Accardi , Sean Christopherson Subject: [PATCH v2 11/18] x86/sgx: Prepare for multiple LRUs Date: Fri, 2 Dec 2022 10:36:47 -0800 Message-Id: <20221202183655.3767674-12-kristen@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202183655.3767674-1-kristen@linux.intel.com> References: <20221202183655.3767674-1-kristen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 db96483e2e74..96399e2016a8 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -394,10 +394,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(); } /* @@ -606,7 +611,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.38.1