Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1134997rwb; Thu, 22 Sep 2022 10:32:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ws1386X50zQvYMtArpZGQsXHYjzoGZZ2m+HzKitWL/qtguNMPgshvvY9Z4orM5Ex06lvJ X-Received: by 2002:a17:902:8c81:b0:178:a33f:8b8f with SMTP id t1-20020a1709028c8100b00178a33f8b8fmr4327810plo.50.1663867921339; Thu, 22 Sep 2022 10:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663867921; cv=none; d=google.com; s=arc-20160816; b=ZysV1/hsIxpMPVb/DYJ76bTauFnYYB7smRVX5jTxxr9gO2L1VHEaUDMoNeCwb1NsT0 QYgk9GIkafB+XkC/gAbYRps5Je7aP+4qPacgif7Q7QDMbhLfH3cqerKSa/AYcep5sV74 0z/ca4H7mxqKxI/JwtYMkpXWl2j5wbx9q3p+2H6CoKEPqV9vNJ2MJtY2DVuAAQUzmt8t 2Zx5WIRgHwqwy/qBjus262TlVt7bjNcFAZpC/OetllEVacr8qkF/ny/+uhPn2fBpXs58 l7XNSES7/yjE66rG/m3sMCR9h0O5CflUwJ4Yjp5SajDtQngMH+Q7ZMQ/sX9rNpenu+Mw 4NCw== 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=H2FadOpOJQV2ib5LtvYdZv4pNWsglgX+pBn3kw7BLzw=; b=wSmHiaNMVVocb8k9HLR6psDEeB2UYQDAF2ww2h0fLzOFFyaPbmZ3nXlIfI00ENmnJe H9Qh9+BFJSEATN1c/rzssIDHw5QzZIGrx6pWyGuiSy8+k2Pk/VXzAzyVnFTphMiraEy2 /IP/EPgaa5fs9qWhC24oy/j9WgIDCjJUmr6voCPAhOAGmlL5jibnKeoJLP/DOz3/4Szf EJOjA27itGdEa+2Of7bL9ZeLZootGmI/iIZ5TJc5jgT69rlEWCIPbQnPeaj+sP5e3Hns 6YYrPMYQb1FTKBRtPfUcuKa3SfU9sPdEgNISUD/tf3HcAghGAgLyVaxV9Z7PleKDKYC5 DSkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jynNwmPx; 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 r13-20020a170902c7cd00b0017854cfd6b3si305960pla.317.2022.09.22.10.31.46; Thu, 22 Sep 2022 10:32:01 -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=jynNwmPx; 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 S231855AbiIVRN0 (ORCPT + 99 others); Thu, 22 Sep 2022 13:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbiIVRNH (ORCPT ); Thu, 22 Sep 2022 13:13:07 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0CF4F8FAF; Thu, 22 Sep 2022 10:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663866786; x=1695402786; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9bTNtbUwu0kZhlILKHr0tCSy+BWIa2iLIfhpMM9AQno=; b=jynNwmPx9NL7ypLTViDkhkpeMfvtxMYIPJBeskfqrC6lypCE3UxYZY+S iLfYO7GioUP6k+hoeqjOtIZmobHM/5KwN/6iUyl8QPCDf11vgY8j5ABjq wbNzN1Dl7Nmi/7qh1XvcNuS6rW/F8ES+Zz3tpSdi8RM3MG/aQQQOVGg/d 3xPqXVfOl0O8rTWRyxoVkjJle3OjTvXKVTaj3T6Go7PLtMZaHYFElWfr0 VR9vyj58ukH88drGLm4BTGCCWzeUbqgkUhu5YYt67zxWAOp/0bqKm+xCV Vdik5I7sOF4K/lw+vqqbqsBX7vfMaqGL38tch93DcuKTEp0Up1Gac5JbY w==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="283421386" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="283421386" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 10:11:49 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="762270162" Received: from sknaidu-mobl1.amr.corp.intel.com (HELO kcaccard-desk.amr.corp.intel.com) ([10.212.165.187]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 10:11:38 -0700 From: Kristen Carlson Accardi To: linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: Kristen Carlson Accardi , Sean Christopherson Subject: [RFC PATCH 14/20] x86/sgx: Expose sgx_reclaim_pages() for use by EPC cgroup Date: Thu, 22 Sep 2022 10:10:51 -0700 Message-Id: <20220922171057.1236139-15-kristen@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220922171057.1236139-1-kristen@linux.intel.com> References: <20220922171057.1236139-1-kristen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 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 | 9 +++++---- arch/x86/kernel/cpu/sgx/sgx.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index ac49346302ed..1791881aa1b1 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 * @@ -298,7 +299,7 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, * * Return: number of EPC pages reclaimed */ -static int sgx_reclaim_pages(int nr_to_scan, bool ignore_age) +int sgx_reclaim_epc_pages(int nr_to_scan, bool ignore_age) { struct sgx_backing backing[SGX_MAX_NR_TO_RECLAIM]; struct sgx_encl_page *encl_page; @@ -405,7 +406,7 @@ static bool sgx_should_reclaim(unsigned long watermark) void sgx_reclaim_direct(void) { if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) - sgx_reclaim_pages(SGX_NR_TO_SCAN, false); + sgx_reclaim_epc_pages(SGX_NR_TO_SCAN, false); } static int ksgxd(void *p) @@ -431,7 +432,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; @@ -606,7 +607,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 76eae4ecbf87..a2042303a666 100644 --- a/arch/x86/kernel/cpu/sgx/sgx.h +++ b/arch/x86/kernel/cpu/sgx/sgx.h @@ -113,6 +113,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); -- 2.37.3