From patchwork Fri Nov 11 18:35:15 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: 13040701 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 9CF6EC433FE for ; Fri, 11 Nov 2022 18:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234389AbiKKSga (ORCPT ); Fri, 11 Nov 2022 13:36:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234057AbiKKSgB (ORCPT ); Fri, 11 Nov 2022 13:36:01 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DC567879A; Fri, 11 Nov 2022 10:36:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668191760; x=1699727760; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=auEkniWHXFa2fE8QomwYSOXBkMl7XCSjIOySc76haUo=; b=moE5q5ze8HRfh2Io/10CiATX4QuLtmCZ9WUGz5eTpMe6kB/wOIsPq+WB U/UmBWrsSRMys87dGMDh24avstK8wJ5z6a4ZT079FDDoyyinPiX+Fe+0F sP98tgIkmDERihHKBVt/odKR2/Wz3h6rWmsjg4xQlGf1maJ7tQnAw/4lh r40zxA1+d0apprXFTYBRK7vFqL+CNrIbv2jWcmj74x4iS6RmOBWus4hJr dOVHHOhbVR5fj631MvmkeP8sCUWKzc7JHtlH9a1aWlD4ElJeg4Ciz1z4Z BpRXTP9Yi+0RoU9YqYu8jvGo/Oyi82Xp0EIoPZwomsjVu7aDPb9eacr8D A==; X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="292050354" X-IronPort-AV: E=Sophos;i="5.96,157,1665471600"; d="scan'208";a="292050354" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 10:35:59 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="640089258" X-IronPort-AV: E=Sophos;i="5.96,157,1665471600"; d="scan'208";a="640089258" Received: from hermesli-mobl.amr.corp.intel.com (HELO kcaccard-desk.amr.corp.intel.com) ([10.212.218.5]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 10:35:58 -0800 From: Kristen Carlson Accardi To: jarkko@kernel.org, dave.hansen@linux.kernel.org, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: zhiquan1.li@intel.com, Kristen Carlson Accardi , Sean Christopherson Subject: [PATCH 10/26] x86/sgx: Return the number of EPC pages that were successfully reclaimed Date: Fri, 11 Nov 2022 10:35:15 -0800 Message-Id: <20221111183532.3676646-11-kristen@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221111183532.3676646-1-kristen@linux.intel.com> References: <20221111183532.3676646-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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index 02b9eafa90a2..dfd76c605ef2 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -291,7 +291,7 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, * problematic as it would increase the lock contention too much, which would * halt forward progress. */ -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_epc_page *epc_page, *tmp; @@ -326,7 +326,7 @@ static void __sgx_reclaim_pages(int nr_to_scan) spin_unlock(&sgx_global_lru.lock); if (list_empty(&iso)) - return; + return 0; i = 0; list_for_each_entry_safe(epc_page, tmp, &iso, list) { @@ -371,12 +371,16 @@ static void __sgx_reclaim_pages(int nr_to_scan) sgx_free_epc_page(epc_page); } + return i; } -static void sgx_reclaim_pages(int nr_to_scan) +static int sgx_reclaim_pages(int nr_to_scan) { - __sgx_reclaim_pages(nr_to_scan); + int ret; + + ret = __sgx_reclaim_pages(nr_to_scan); cond_resched(); + return ret; } static bool sgx_should_reclaim(unsigned long watermark)