From patchwork Fri Nov 11 18:35:19 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: 18959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp905673wru; Fri, 11 Nov 2022 10:38:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Jo5GOwlnIR0j+IG80z/hOPfoAm0yo8P4Jv3YLMdqnCfflCiIL4iKyyslZ3qWwXzr3g5PQ X-Received: by 2002:a65:62c7:0:b0:434:1b1b:5706 with SMTP id m7-20020a6562c7000000b004341b1b5706mr2722067pgv.226.1668191932788; Fri, 11 Nov 2022 10:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668191932; cv=none; d=google.com; s=arc-20160816; b=rSSHuo17RPkR5oQlSEpFQF5vqkTMA6m6QuZjgymlYFFMlvV7SYwcoc8PaC2QyzvOhM i9cwk5lgy+4Rdm8uoPQqVWRR8n8Mv0Ie6N9z2lqbAfemvYlKmwF4bxu3eVrZFBS/q2ge PBECbJiAr1tdUld6HIEB7tC0+GnhAQZ8VU37iaICpYCvHUQK/51mge0J1VPnnCF1YnnK 27AD2wWpfFQ3DmFH5kc6tXUVI3Tn6NE/KOaCOdihphGq+gqJyiwzGEhRpMMLPRDQsYbY UhEc1xl1w5Pbo9rYfqr8FQMLchCZUxmIXhfw9L2P7lcvhPYUBrPmXndRGmncDSCbzWtv PtGA== 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=58MO8hTFdR8/HUtz7E/XwzojjsVZsjWAl1ouTvNGJlg=; b=vA33rn1QiGti/EZDu1Nefob8xtqQw1K3FluxQzE91qhr/FwBMJYu/JyWaaKCUak7V9 UQkR+xkfN3v7JZ06aTl88WbczCpTgLRmE5J0in1mav1GU9rlBniebIdG+syC6AvBa4+0 jCduBX2jWFAjG1hGFyL5gBWhMGeYXn4j94zSMDjyShO5j6TcPctC+6e5Oo534Bt8Jws7 cQUFG1ER67ZscsnA35sXDKZ2zcmMB4Vw91tcb8yiB184/s8CDeRffiEoxTkEe6wYTVwi iHp1kw+riQlsGCCX8qAMqlrCTHnf7crFMAvZRR170mvb8WEfQZIY0mhmav8HXty71BMT qZ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RZUE1KX7; 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 a5-20020a170902ecc500b00186994f6e90si3473832plh.529.2022.11.11.10.38.39; Fri, 11 Nov 2022 10:38:52 -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=RZUE1KX7; 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 S234329AbiKKShP (ORCPT + 99 others); Fri, 11 Nov 2022 13:37:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbiKKSgH (ORCPT ); Fri, 11 Nov 2022 13:36:07 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D31814CF; Fri, 11 Nov 2022 10:36:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668191766; x=1699727766; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9lDq2QGtdu+ipirjs6bxBHl2Vfzbdikl95QVLbAr5eU=; b=RZUE1KX7cUxej+1xwc5R2arogNp2qVojj/AJkjgbNgHM2knPfCFJWizI FsITFUyFWtiMwvkVWX+D9kyjH5h+TQUimvR7AEohr5Qy3ZNCA6GI+HZCY fRYIwKDuL3No5IKQqEmvCGmCsw1AfQyltFKx0BHTLFIZlCNpKLOIoG8E0 SaZqdr6z7GzVeVJeEHbsSG4RDiAQXkpnNkblNsi7GCdgGsWEo/d8y5WQT VgAU6RC4YLdBWhu1GLqDoVVW85cGNmyE+0ZRs/W5NroPDbHEptDD9cqWA aNsctRcAuopVWFjTExnM+VCrzymklAtKA5Xs6COMvFNashGEMd3ncJglH g==; X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="292050366" X-IronPort-AV: E=Sophos;i="5.96,157,1665471600"; d="scan'208";a="292050366" 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:36:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="640089309" X-IronPort-AV: E=Sophos;i="5.96,157,1665471600"; d="scan'208";a="640089309" 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:36:05 -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 14/26] x86/sgx: Expose sgx_reclaim_pages() for use by EPC cgroup Date: Fri, 11 Nov 2022 10:35:19 -0800 Message-Id: <20221111183532.3676646-15-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749226024092889448?= X-GMAIL-MSGID: =?utf-8?q?1749226024092889448?= From: Sean Christopherson Expose the top-level reclaim function as sgx_reclaim_epc_pages() for use by the upcoming EPC cgroup, which will initiate reclaim to enforce changes to high/max limits. Signed-off-by: Sean Christopherson Signed-off-by: Kristen Carlson Accardi Cc: Sean Christopherson --- arch/x86/kernel/cpu/sgx/main.c | 7 ++++--- arch/x86/kernel/cpu/sgx/sgx.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index b2c050fcc989..cb6f57caf24c 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -281,6 +281,7 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, /** * sgx_reclaim_pages() - Reclaim EPC pages from the consumers + * sgx_reclaim_epc_pages() - Reclaim EPC pages from the consumers * @nr_to_scan: Number of EPC pages to scan for reclaim * @ignore_age: Reclaim a page even if it is young * @@ -382,7 +383,7 @@ static int __sgx_reclaim_pages(int nr_to_scan, bool ignore_age) return i; } -static int sgx_reclaim_pages(int nr_to_scan, bool ignore_age) +int sgx_reclaim_epc_pages(int nr_to_scan, bool ignore_age) { int ret; @@ -438,7 +439,7 @@ static int ksgxd(void *p) sgx_should_reclaim(SGX_NR_HIGH_PAGES)); if (sgx_should_reclaim(SGX_NR_HIGH_PAGES)) - sgx_reclaim_pages(SGX_NR_TO_SCAN, false); + sgx_reclaim_epc_pages(SGX_NR_TO_SCAN, false); } return 0; @@ -617,7 +618,7 @@ struct sgx_epc_page *sgx_alloc_epc_page(void *owner, bool reclaim) break; } - sgx_reclaim_pages(SGX_NR_TO_SCAN, false); + sgx_reclaim_epc_pages(SGX_NR_TO_SCAN, false); } if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) diff --git a/arch/x86/kernel/cpu/sgx/sgx.h b/arch/x86/kernel/cpu/sgx/sgx.h index f3fc027f7cd0..ca51b3c7d905 100644 --- a/arch/x86/kernel/cpu/sgx/sgx.h +++ b/arch/x86/kernel/cpu/sgx/sgx.h @@ -181,6 +181,7 @@ void sgx_reclaim_direct(void); void sgx_record_epc_page(struct sgx_epc_page *page, unsigned long flags); int sgx_drop_epc_page(struct sgx_epc_page *page); struct sgx_epc_page *sgx_alloc_epc_page(void *owner, bool reclaim); +int sgx_reclaim_epc_pages(int nr_to_scan, bool ignore_age); void sgx_ipi_cb(void *info);