Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2660497rdb; Mon, 12 Feb 2024 11:58:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMbERl9hvrbdVT5kEKXhE9lclhIKHrWaSR9qrV/d8bzJKJaBf8S0ZOQTygSF6PNRC42OapzMtOW3z2Mdlq5tEsNfjmntXzgxjrdgX7VQ== X-Google-Smtp-Source: AGHT+IEAtFT5HQQE2DoI+28Yz/AYk/PbVBODiNMe4Vb6xlTW+XBrZuGzbtmMWIXtBGrIIrZEKvbv X-Received: by 2002:a05:6e02:1a09:b0:363:d96f:6850 with SMTP id s9-20020a056e021a0900b00363d96f6850mr11791987ild.12.1707767883631; Mon, 12 Feb 2024 11:58:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707767883; cv=pass; d=google.com; s=arc-20160816; b=GLyKHhwfFUl9Ugs+QOV72X3V4SB9wbXRpl56m7k8GES3SEIQvvnQ3LEMxk1vNIUNeh YtJTnLTh3kCP+AXH6yrJTqhN45k1ETQdClW6Z4sf1r2iBOzK1D9/X+rGaApcx1SVtT9S FFdRlsxQKD+n8GMm2m3VFNYvIUQenqbNg+Pl0EVo87/j30yq/6nyIsVNT/0cqDJlHI+K h/RppF3uM1Y+MGdR5/3/wqJkw74zGHDQg6C6E7GDXxNJGZ2uSmxKOBeGvgebHaocZnj6 xV0AHg5zKQUDOyxKTJG1b29Ht4E4Q1jq25/epVneiYSN9B5N8TP+Z3Z9jRpJ0YW/Ftk8 Q2cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=GKg6sqWUUheCd08ly1uYR5YLvIjYw42UpxqVh5xa+oo=; fh=19pwzlKLKdGjw9s/ib/akWOakovLqR9/vg86rRdBdoE=; b=xQe0MQ/obU/oSdNF5N5FmvLPZDMYfpxJO2SKgCkig22wTl1XtYXw04BhSkFCiR4KGL DEHXYHxfYG9/FLElfhAdZUAL5l2Mu4Cmqp99ZhIrpxew8vUpTFFi0JLXhqQYBlVNXHp/ gp+/nSHam3QZbkgBuWvDA7VfDI5YmxqF+bGadimnyHoKEB1jSk4n7ZPZjxcxIZxESYBV FPIiXH2FurT7YIkafwhjSYQjjCXHvHG77a+egUOin94gcknWDTc/1F5b7GyZIidYYVXA aVQrlQ+50d9ulE6tg+/MPgrhIkZfYaS7OzYjpeYeEPq/9NJ0uye4l27i6IB/qBWa/odr Bn0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fBjPuaiQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62297-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVgWIsVTkC5Ch5Hqe1/Z4UF5fdvoQs++fUDy+1yvpxf1N3EQPqhYBTmaLtfYzGRZNrEbWrf+7PhcuNPW6yMTfihycylxliwsZgjT2fiJQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q19-20020a656853000000b005dc6d1551basi703391pgt.234.2024.02.12.11.58.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 11:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62297-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fBjPuaiQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62297-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C657FB21342 for ; Mon, 12 Feb 2024 19:56:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCF2747F46; Mon, 12 Feb 2024 19:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fBjPuaiQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAC5D47A63; Mon, 12 Feb 2024 19:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707767807; cv=none; b=FYgeVF0bd2LNOZxHR/g9sFoPreq84Mvdu5j8C/IsJjj7Ta3L0Iy5z0sPp1cU2J090+Q6Qc+5tz2p3zgq5kdSDvM6Ua0pM2AbZRhH17tNr7eIn7og5EhWZ1Do4Wntgo0IgjgYkXzfypaz0mtJwS6KqMgVQRLhei3oeyJWwVc6Iug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707767807; c=relaxed/simple; bh=dmVX8i40tnB9ewS4UawWwIEkd+FyBOxmlrA+K6xKYOE=; h=Mime-Version:Content-Type:Date:Message-Id:From:To:Cc:Subject: References:In-Reply-To; b=nw9rR4GCqHn8+7t2aJ6eMS0ByUAERj1X/Knhk1fil6mMN3kNF7XP1M0xLcbW1dY0MyfGalTCIFnwIkbfGTtxoeKvCxlCqvJSwQ7pDPSOlZ7+BTqPg0c+5QqAXDUqfSZ2Z7fiaABffsTswp5QEZWM4k4GwrWqLTxMfcZf4Z5DsxU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fBjPuaiQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00B4CC433F1; Mon, 12 Feb 2024 19:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707767806; bh=dmVX8i40tnB9ewS4UawWwIEkd+FyBOxmlrA+K6xKYOE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fBjPuaiQGQ6Hz7D7U/V25N7rwnkmbY0aRQz5R2YdCQXauO+59x7nfy5SXkEInwI1K /8igDEFdeAYl2VIQQgoEdDZ+DzgG4lO/M4PuAEOOUJej6fZkiabDg4LJSlJnTirNsK H6LtFfnZn+R6zRaxOkoE44Gm8Exwu21uzkoC1ys1RifRxElY1qLb5U73PQx4ozHrUA 2iJYg1yVn4xQ3reVg279w6Z3h/s+xvi5NPQm4bxwQ+43+btXeWf375yECveTzEMZcz CcjGHUpZrLXhCrY9VHUxytD4F43e6s0wxmr8KS/Q/dSdrgyjSYrOeMql9UpUYhfkZ2 0LYHQW7plpdzA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 12 Feb 2024 21:56:40 +0200 Message-Id: From: "Jarkko Sakkinen" To: "Haitao Huang" , , , , , , , , , , , , , Cc: , , , , , , , Subject: Re: [PATCH v9 11/15] x86/sgx: Abstract check for global reclaimable pages X-Mailer: aerc 0.16.0 References: <20240205210638.157741-1-haitao.huang@linux.intel.com> <20240205210638.157741-12-haitao.huang@linux.intel.com> In-Reply-To: <20240205210638.157741-12-haitao.huang@linux.intel.com> On Mon Feb 5, 2024 at 11:06 PM EET, Haitao Huang wrote: > From: Kristen Carlson Accardi > > To determine if any page available for reclamation at the global level, > only checking for emptiness of the global LRU is not adequate when pages > are tracked in multiple LRUs, one per cgroup. For this purpose, create a > new helper, sgx_can_reclaim(), currently only checks the global LRU, > later will check emptiness of LRUs of all cgroups when per-cgroup > tracking is turned on. Replace all the checks of the global LRU, > list_empty(&sgx_global_lru.reclaimable), with calls to > sgx_can_reclaim(). > > Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > Signed-off-by: Kristen Carlson Accardi > Co-developed-by: Haitao Huang > Signed-off-by: Haitao Huang > --- > v7: > - Split this out from the big patch, #10 in V6. (Dave, Kai) > --- > arch/x86/kernel/cpu/sgx/main.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/mai= n.c > index 2279ae967707..6b0c26cac621 100644 > --- a/arch/x86/kernel/cpu/sgx/main.c > +++ b/arch/x86/kernel/cpu/sgx/main.c > @@ -37,6 +37,11 @@ static inline struct sgx_epc_lru_list *sgx_lru_list(st= ruct sgx_epc_page *epc_pag > return &sgx_global_lru; > } > =20 /* * Description */ > +static inline bool sgx_can_reclaim(void) > +{ > + return !list_empty(&sgx_global_lru.reclaimable); > +} > + > static atomic_long_t sgx_nr_free_pages =3D ATOMIC_LONG_INIT(0); > =20 > /* Nodes with one or more EPC sections. */ > @@ -398,7 +403,7 @@ unsigned int sgx_reclaim_pages(struct sgx_epc_lru_lis= t *lru, unsigned int *nr_to > static bool sgx_should_reclaim(unsigned long watermark) > { > return atomic_long_read(&sgx_nr_free_pages) < watermark && > - !list_empty(&sgx_global_lru.reclaimable); > + sgx_can_reclaim(); > } > =20 > static void sgx_reclaim_pages_global(bool indirect) > @@ -601,7 +606,7 @@ struct sgx_epc_page *sgx_alloc_epc_page(void *owner, = bool reclaim) > break; > } > =20 > - if (list_empty(&sgx_global_lru.reclaimable)) { > + if (!sgx_can_reclaim()) { > page =3D ERR_PTR(-ENOMEM); > break; > } BR, Jarkko