[v2,09/18] x86/sgx: Return the number of EPC pages that were successfully reclaimed
Message ID | 20221202183655.3767674-10-kristen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1016340wrr; Fri, 2 Dec 2022 10:44:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf41j4DF5cjWixJ/DoQAl8lM2Z1dI7tiYx0BlqAOxXhi1Olh0coziEjcl3CtVupWffSN16Mv X-Received: by 2002:a17:906:3ac1:b0:78d:36d8:1814 with SMTP id z1-20020a1709063ac100b0078d36d81814mr59591285ejd.99.1670006657349; Fri, 02 Dec 2022 10:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670006657; cv=none; d=google.com; s=arc-20160816; b=vkHN2o82s5V1NWX/AVyO8TfNKoHuNIK7XZuZOAp7MaleB475bPttIt+J11GqPyrTxL YnfAhSLfQwxj7/crHXqwj4dozk3qN7CIGleni5H1seAQpyH4onxcBb8V5hhPbs6xyX9n qjHu1MM+WPXJNrgcdj2ugyBEMK/ALG03qB9lkmzQphYKZCyBarttsp4+tGTNsOPEdqcc wSL9hqEdv1nZwyLczgR5YMaLXROko/uHOWLLAqcDafzJv6fX2cB5JzeUGz9vViIhZOIm vRHQHmCDDrSGkB84AgO0TOPx/6MjHRWVCXhZGKIO+NhFeRNWL8k45dzXrdvkfTEWMiai l4Gw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020aa7de0c000000b0046c0ff54c7csi2861190edv.189.2022.12.02.10.43.53; Fri, 02 Dec 2022 10:44:17 -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 <rfc822;lhua1029@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <kristen@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: zhiquan1.li@intel.com, Kristen Carlson Accardi <kristen@linux.intel.com>, Sean Christopherson <seanjc@google.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751128900623310698?= X-GMAIL-MSGID: =?utf-8?q?1751128900623310698?= |
Series |
Add Cgroup support for SGX EPC memory
|
|
Commit Message
Kristen Carlson Accardi
Dec. 2, 2022, 6:36 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> Cc: Sean Christopherson <seanjc@google.com> --- arch/x86/kernel/cpu/sgx/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Comments
On Fri, Dec 02, 2022 at 10:36:45AM -0800, Kristen Carlson Accardi wrote: > 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> > Cc: Sean Christopherson <seanjc@google.com> > --- > 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) Nit: I wonder if we should use ssize_t here? If nothing else, it would document better than 'int'. BR, Jarkko
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)