[v3,11/28] x85/sgx: Return the number of EPC pages that were successfully reclaimed
Message ID | 20230712230202.47929-12-haitao.huang@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1477645vqm; Wed, 12 Jul 2023 16:27:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlEu8ynI/FDajo8rXyFEE1J7tnnQkGinw43Are8KQrqA3wqEMlYnMGuY3s2OZOx9SZ5m5d93 X-Received: by 2002:a17:907:3f0b:b0:98e:2423:708 with SMTP id hq11-20020a1709073f0b00b0098e24230708mr26423611ejc.62.1689204437642; Wed, 12 Jul 2023 16:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689204437; cv=none; d=google.com; s=arc-20160816; b=t6Bt7ss0plmqOpbbX+PK23Pj2cwu6gvCOf191PIBYSCrlJx+Np+62OYE9WvVMl6WpV pHKz2tKok3dFlu2WVtcJXOr3Zd11jWeEGXNihcMK4a/oeBzcKS8Jh/sx3X6CGGlSeN1V uTxf5aESYLaXE6vR3iYuKd3D8XI8J38g6P7lNbejaiOFvkGApGaBMsVGXOflfxG65Wo4 Z9C73i9Q0gsCJaoR/jrNLWSmkSQGVmEiFwGOyXh/b0kjwBDbrOGoxs5fHOSdebtYQp3J vhsLF9Yeefg/TQ4MMAaL0ACiodkVg3mxOpoR0sIR3Y3PetFfgNiyRR7tVfcAo08gyUXn cIhg== 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=jftUwg68c2zBXhtc+RhBzOUc4qvlZMeAdt3SnrL0ZEI=; fh=yb4uG0y4asZWHqlPLNfXLnkT1yMR9ApbW5Mi8ElCAYw=; b=hjUMgPZecj74HseGAPwmuui+aAIDI6QqpcGSnCobiizvtEFm/UE9u177kuGG0mmhNy pTa2lvE8oWn3VaDqd9BqdX0S6sMPwYmi3A2229RfAqH/sPIXMw7g4UrG0HD3gxjU+vxV cts/YMh5QeJwr92sHApj4LfYGwTXQP/7KvTzEkWXOdS83iFLzLlI9Nh0VjJDoeO3h/4/ Ny6lDbjer1dB8lcrz+iFyac2N0l2C8CvgI3RkgM9oHVI81s6eZqy3sG/8O6x0uTriT+3 juBaKFviQEW6gylrCGAqkE9wK8bUd6v33xqIC3A0B5p+fj+pl1u5I4u8r+86COc8/gMn ZAuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JB7IdPOr; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a1709064dd100b009893fe84e74si5984395ejw.484.2023.07.12.16.26.53; Wed, 12 Jul 2023 16:27:17 -0700 (PDT) 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=JB7IdPOr; 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 S232817AbjGLXC4 (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Wed, 12 Jul 2023 19:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232424AbjGLXCO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 12 Jul 2023 19:02:14 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D1E12E; Wed, 12 Jul 2023 16:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689202933; x=1720738933; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fJtlT/xQbGuqifSvzspe+hCOxY7ihArgj6I6Qvo1HZE=; b=JB7IdPOrpTpeHYj1zlQuFbeN7nZEXzgZLxLb9TGoq49s2ys7RwHSmj81 r7st3YpFI4mKcgDbehEUF3XjzCPD/p7cea427vlK03IWoVg/3OUybDTtT jRXm4XMVEmbpPMkg5Mj89IBkd5qLK1IN7gwPaG8wxt3S39HRjuU5N5x16 9J1BoW7bpRKoFgNUbwoiKtNWoxcCv2X0M1sYbvFLScUxm/RYcl6DhpCHJ /kAHonVL0jTR5rAULM+/mkQgrxZhi2qSpAZpoLPBIfMiCTVvVybiqJmQv f7bvkrKBaa3zUSw3K8o8Udj1vbP2q1Vr619j7RM/pupouZa00uyfKMojb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10769"; a="428774104" X-IronPort-AV: E=Sophos;i="6.01,200,1684825200"; d="scan'208";a="428774104" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 16:02:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10769"; a="835338621" X-IronPort-AV: E=Sophos;i="6.01,200,1684825200"; d="scan'208";a="835338621" Received: from b4969161e530.jf.intel.com ([10.165.56.46]) by fmsmga002.fm.intel.com with ESMTP; 12 Jul 2023 16:02:10 -0700 From: Haitao Huang <haitao.huang@linux.intel.com> 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 <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com> Cc: kai.huang@intel.com, reinette.chatre@intel.com, Sean Christopherson <sean.j.christopherson@intel.com>, zhiquan1.li@intel.com, kristen@linux.intel.com, seanjc@google.com Subject: [PATCH v3 11/28] x85/sgx: Return the number of EPC pages that were successfully reclaimed Date: Wed, 12 Jul 2023 16:01:45 -0700 Message-Id: <20230712230202.47929-12-haitao.huang@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230712230202.47929-1-haitao.huang@linux.intel.com> References: <20230712230202.47929-1-haitao.huang@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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771259232772695822 X-GMAIL-MSGID: 1771259232772695822 |
Series |
Add Cgroup support for SGX EPC memory
|
|
Commit Message
Haitao Huang
July 12, 2023, 11:01 p.m. UTC
From: Sean Christopherson <sean.j.christopherson@intel.com> 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 <sean.j.christopherson@intel.com> Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com> Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com> Cc: Sean Christopherson <seanjc@google.com> --- arch/x86/kernel/cpu/sgx/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Comments
Hi! > From: Sean Christopherson <sean.j.christopherson@intel.com> > > 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. Subject says x85. While some would love to see support of Linux on Intel 8085, I guess it should be x86. Best regards, Pavel
On Sat Jul 29, 2023 at 12:47 PM UTC, Pavel Machek wrote: > Hi! > > > From: Sean Christopherson <sean.j.christopherson@intel.com> > > > > 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. > > Subject says x85. While some would love to see support of Linux on > Intel 8085, I guess it should be x86. hmm... that could potentially be also a step towards also to zilog z80 compatibility :-) BR, Jarkko
diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index cd5e5517866a..4fc931156972 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -299,15 +299,15 @@ 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 size_t sgx_reclaim_pages(size_t nr_to_scan) { struct sgx_backing backing[SGX_NR_TO_SCAN_MAX]; struct sgx_epc_page *epc_page, *tmp; struct sgx_encl_page *encl_page; pgoff_t page_index; LIST_HEAD(iso); - int ret; - int i; + size_t ret; + size_t i; spin_lock(&sgx_global_lru.lock); for (i = 0; i < SGX_NR_TO_SCAN; i++) { @@ -333,7 +333,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) { @@ -378,6 +378,7 @@ static void sgx_reclaim_pages(int nr_to_scan) sgx_free_epc_page(epc_page); } + return i; } static bool sgx_should_reclaim(unsigned long watermark)