From patchwork Thu Sep 22 17:10:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristen Carlson Accardi X-Patchwork-Id: 12985590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90E18C6FA91 for ; Thu, 22 Sep 2022 17:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231872AbiIVRNG (ORCPT ); Thu, 22 Sep 2022 13:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbiIVRNE (ORCPT ); Thu, 22 Sep 2022 13:13:04 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CFCFF8FAF; Thu, 22 Sep 2022 10:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663866784; x=1695402784; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IRVYENCJ7yHBfO6uy21g2daHEDZv9zK8fsTrdOaM4yM=; b=EXxjT2XZLxuD5xD8eD5nTCvlL5NCtCt28zOQLTSRdUbrqH4D/ha+lf7J Oml4nU0ZmmzBymmEDjw0L1f7cydWSZn8bqbSV95VQNL1b0jJ89at3KDY6 V1HXjL0sTGgifDMRBjXRNveDaIsxZN8QMWF+v30He/La0OcvQCjKbNZZL W0XcdBdg0UfkgvVE6mRzQ2BYcyfxusV3NPkAGlaGcEnQhdDK42XS8wNUF NeNn/Un0mhyRBsoMFm+JRxAF0g1RBAljbLxPc8VgtPPJWxdEhX31IPVrM DAY+EHNUg3FQeoXrPYFNsVwJpxQiplZZ/j3G6dB0iyyh9Hy2XbEUlaBoy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="283421362" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="283421362" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 10:11:48 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="762270126" Received: from sknaidu-mobl1.amr.corp.intel.com (HELO kcaccard-desk.amr.corp.intel.com) ([10.212.165.187]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 10:11:31 -0700 From: Kristen Carlson Accardi To: linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: Kristen Carlson Accardi , Sean Christopherson Subject: [RFC PATCH 10/20] x86/sgx: Return the number of EPC pages that were successfully reclaimed Date: Thu, 22 Sep 2022 10:10:47 -0700 Message-Id: <20220922171057.1236139-11-kristen@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220922171057.1236139-1-kristen@linux.intel.com> References: <20220922171057.1236139-1-kristen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org From: Sean Christopherson Return the number of reclaimed pages from sgx_reclaim_pages(), the EPC cgroup will use the result to track the success rate of its reclaim calls, e.g. to escalate to a more forceful reclaiming mode if necessary. Signed-off-by: Sean Christopherson Signed-off-by: Kristen Carlson Accardi Cc: Sean Christopherson --- arch/x86/kernel/cpu/sgx/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index 0010ed1b2e98..fc5aed813834 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -290,8 +290,10 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, * + EWB) but not sufficiently. Reclaiming one page at a time would also be * problematic as it would increase the lock contention too much, which would * halt forward progress. + * + * Return: number of EPC pages reclaimed */ -static void sgx_reclaim_pages(int nr_to_scan) +static int sgx_reclaim_pages(int nr_to_scan) { struct sgx_backing backing[SGX_MAX_NR_TO_RECLAIM]; struct sgx_encl_page *encl_page; @@ -373,6 +375,7 @@ static void sgx_reclaim_pages(int nr_to_scan) } out: cond_resched(); + return i; } static bool sgx_should_reclaim(unsigned long watermark)