Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2529284rwb; Fri, 2 Dec 2022 11:01:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7zSjwCl5LNiwB44aTDuxBgf89rBaV1uwI9O83x2SqvjLZx3rmh3FkxvW/jov4bqIQxo02v X-Received: by 2002:a17:907:c08a:b0:7c0:7b21:c5e4 with SMTP id st10-20020a170907c08a00b007c07b21c5e4mr19369795ejc.317.1670007715920; Fri, 02 Dec 2022 11:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670007715; cv=none; d=google.com; s=arc-20160816; b=E1eXfiPI5u2VRexSBnKUX8AH/HwhrwidDk+smmnMHpqvgy3HpTooBCKtxdXq9tAqI1 LKsZCBHM7H2K8et3s+3WS/vtOC5C1D+1sk1p5ylMZ/bNzSwokyfjdQcdihCKgNuFkUhV oKnC69zR4jSgLCn+r323mPRwI5YJ7I4OaDmWXQhUuujDmegg02EUCdpcDhLoIlu2M+ZH 0kLw9KDruIv1PlauFfDFqqy7zsAl6Kg/WPTk6TqHqzcjdt1DY7N4vOsYtx7a/bV7FKxg Ujj9AR2tpRd6EyZ4swnuiRmwopn+thWwGh5Pr6UCq5KwQlBXsjE3KlFJExIAcKozPcem gKDg== 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=iw0IaPN4ukMOF3yP3ZWIhgA/VHeerJymFIqAp+GFOR0=; b=U1ZIkHSVcrJV+BI0WJ2hKVo9FyK0UwkjfgnNZK5Y8+FpZ6qwYs7Ll3l5WLBwQZ6klN QejyDjwKrD5/xdU1LOFqW+kScgdxp9fmf/0O00R6ehpKs3KGATVoJbRejx0VlMJv4iyI vJQpfcWSGYSEZ7wl3HasgDpGLlDcKuYjEOK77iU2Puhl9I26lU687mWiabHBjHxlN5d7 SncS8ILv2w5kJzR0GuonBfEqmiwn6xjkA0kaSc4yNxyubemv9t4Nn8wmA3kRCavTMaNT o/11uYoe/C146nt2/9vD14Ya+cBfUSb8IRpxS/C1Pn6nFbx88j+PcAaCVzTWj3vMNNgS s1iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BUBH2Kb9; 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 dm13-20020a05640222cd00b004614f376c2fsi6235274edb.88.2022.12.02.11.01.34; Fri, 02 Dec 2022 11:01:55 -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=BUBH2Kb9; 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 S234573AbiLBSiK (ORCPT + 82 others); Fri, 2 Dec 2022 13:38:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234525AbiLBSht (ORCPT ); Fri, 2 Dec 2022 13:37:49 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2848EBCA1; Fri, 2 Dec 2022 10:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670006242; x=1701542242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sBuJld5YfAr7cCiwad4f37JGGvCzkKs+++hBvxzdEeQ=; b=BUBH2Kb9edTv0TDLFqvCIPZfU/2JcMinQ6u2aag+SXBL+F2a1iJpszrE 5ymdgwcwl/zebtSfZuPhncwccRWZxeL2at616gxQy97BjWfuOhJ2oH+tz gRVh35LaroYVPxKW9kzaNsThhYLkEE0Qg283PoAulCveIZxQEInzUFEoY wnswhoqyByx8+6Zotq2PxVQE/67XTCkTPi81D7Md1uua4uaPyG+qxZkPU 59hgpy1ttwlRZnMAVZdzONxffaUXaPFCENXowcdv23E0PYP7pQPjlS3I1 voeKhtbHpYDuoSstFNvyy8FSPx8AICAXbllt59Jjq2KWGnVKKSNZe9QMp A==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="314724594" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="314724594" 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:22 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="713717489" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="713717489" 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:21 -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 09/18] x86/sgx: Return the number of EPC pages that were successfully reclaimed Date: Fri, 2 Dec 2022 10:36:45 -0800 Message-Id: <20221202183655.3767674-10-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 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 f201ca85212f..a4a65eadfb79 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) { @@ -374,12 +374,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) -- 2.38.1