Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp3053138rdd; Sat, 13 Jan 2024 13:05:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5+l+2pByfNBkjlDs6cFFqDp+XMsUeBRQafmTZcqqDyoGI+sj8JBJcHBQEbgEqOiBAOO1C X-Received: by 2002:aa7:c485:0:b0:557:379f:36df with SMTP id m5-20020aa7c485000000b00557379f36dfmr818667edq.29.1705179910625; Sat, 13 Jan 2024 13:05:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705179910; cv=none; d=google.com; s=arc-20160816; b=ih3eqonJWvNqqvgeLJq2xmuhEsz8CvMQjxII6i8WxLLA6LWqcSek7pVZWfmixdBYUF Naf2dUFsbMvQN0JaqS/AcTDMlyZGybGMoFO4ZQsrhsWCWtQUSmNbP/u/ciVdorHp7GEW jG8iBWhlpdBJL9ZN6qAS+jYeBy/MyiCcHMzKPghecwI5m8KvZTPP4X1Sk0WX6ccIgJfF FO8YQfXaIDEUJV0R/IZqO+sGDV2Au+MDNHuADXniG3C0l810CTX+msI3Rs6ftYJLpt3T OI1ydInsQi3cw6Lydp3s1HSEnPlY1P19jZdpdAQGLzxk2D/SJTPr4ql/Fj48JnEXaHH9 gDwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=nuIEBuTh+XGh6hQSCRmfuXgfAapE4Gok84gHxZdsW5E=; fh=sVMTgjYnKsc+ytgTNT4QixxsSgU7UTl/u/pwJfbdxSA=; b=eIBgvUSa4/4oolK8i4Fky0LfdWjfoDjR8q7C1cKM19XbQVAZlV/y57zDVfvjaV2Py/ ijQb8rs0oa4JZArshTJcMZHO7nsri1AULpvGB5dJ0xO3QFV3LcUythT8MbRkCeiAI5z9 2SEIc9tAhaEOIhttNnLF1WWYDYvYjObUoRScp/9M6IOjZXssywFa2WktLuI2IMltg09e y4H944wOMfqdE6nvTIQZsro0aIcYfBujLVw7R4b10ecAtXp5H1ItUGloHfziFTaKT1Ax KvQk0jUGFTgxKpWyKvUraZQmFvPiurYS9GHxNpHumM82+iJ4dj1vdp4WVJIExMTmWl8F TMRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rYV8Ky+6; spf=pass (google.com: domain of linux-kernel+bounces-25370-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id et14-20020a056402378e00b005591f7b9682si153183edb.70.2024.01.13.13.05.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jan 2024 13:05:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25370-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rYV8Ky+6; spf=pass (google.com: domain of linux-kernel+bounces-25370-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25370-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 620F51F220C2 for ; Sat, 13 Jan 2024 21:05:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46B9B16427; Sat, 13 Jan 2024 21:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rYV8Ky+6" 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 6D180107A6; Sat, 13 Jan 2024 21:05:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86632C433C7; Sat, 13 Jan 2024 21:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705179900; bh=ux54uZJWkkoZPaHx5sQX6OQDNhSpfNHWw1t1XFJcD8w=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=rYV8Ky+6NziqG3w22urj/CYOfZu/nLd+f3GZpyP+b35d4r+ZbLzAbY+zmq9BM7gd9 mIFtAAaRQ+j/xDVLJXr7OfT6W21TKrbUM6AFG1bffoOPCNzbeFFHwc63J0hGnWXNUN YrnhEF0Mt6Nk36cqXS01+6x5mD/XIzcZOXUflI6VbRqZ9LzWcecWP0DJKxPNC1zOUl YiwL+bMUooPZqwLoNX4OlVfJrCHIhM0JYX48nhRbPV78iuMjI0PFZwG2zaXLCA/TK6 TgSsq2EfvmWclH++2bZpaHe0UhKDyTHbpA5pWWoR+d//iyJmU5pKBp4hg3wjW+Yar9 scLX6fY1SYfiA== 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: Sat, 13 Jan 2024 23:04:54 +0200 Message-Id: To: "Haitao Huang" , "Mehta, Sohil" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "tj@kernel.org" , "mkoutny@suse.com" , "tglx@linutronix.de" , "linux-sgx@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" , "Huang, Kai" Cc: "mikko.ylinen@linux.intel.com" , "seanjc@google.com" , "Zhang, Bo" , "kristen@linux.intel.com" , "anakrish@microsoft.com" , "sean.j.christopherson@intel.com" , "Li, Zhiquan1" , "yangjie@microsoft.com" Subject: Re: [PATCH v6 09/12] x86/sgx: Restructure top-level EPC reclaim function From: "Jarkko Sakkinen" X-Mailer: aerc 0.16.0 References: <20231030182013.40086-1-haitao.huang@linux.intel.com> <20231030182013.40086-10-haitao.huang@linux.intel.com> <431c5d7f5aee7d11ec2e8aa2e526fde438fa53b4.camel@intel.com> <3c27bca678c1b041920a14a7da0d958c9861ebca.camel@intel.com> <73ed579be8ad81835df1c309b7c69b491b7f2c8e.camel@intel.com> In-Reply-To: On Fri Jan 12, 2024 at 7:07 PM EET, Haitao Huang wrote: > On Sun, 17 Dec 2023 19:44:56 -0600, Huang, Kai wrot= e: > > > > >> > > >> > The point is, with or w/o this patch, you can only reclaim 16 EPC = =20 > >> pages > >> > in one > >> > function call (as you have said you are going to remove > >> > SGX_NR_TO_SCAN_MAX, > >> > which is a cipher to both of us). The only difference I can see is, > >> > with this > >> > patch, you can have multiple calls of "isolate" and then call the > >> > "do_reclaim" > >> > once. > >> > > >> > But what's the good of having the "isolate" if the "do_reclaim" can = =20 > >> only > >> > reclaim > >> > 16 pages anyway? > >> > > >> > Back to my last reply, are you afraid of any LRU has less than 16 = =20 > >> pages > >> > to > >> > "isolate", therefore you need to loop LRUs of descendants to get 16? > >> > Cause I > >> > really cannot think of any other reason why you are doing this. > >> > > >> > > >> > >> I think I see your point. By capping pages reclaimed per cycle to 16, > >> there is not much difference even if those 16 pages are spread in =20 > >> separate > >> LRUs . The difference is only significant when we ever raise that cap.= =20 > >> To > >> preserve the current behavior of ewb loops independent on number of LR= Us > >> to loop through for each reclaiming cycle, regardless of the exact val= ue > >> of the page cap, I would still think current approach in the patch is > >> reasonable choice. What do you think? > > > > To me I won't bother to do that. Having less than 16 pages in one LRU = is > > *extremely rare* that should never happen in practice. It's pointless = =20 > > to make > > such code adjustment at this stage. > > > > Let's focus on enabling functionality first. When you have some real > > performance issue that is related to this, we can come back then. > > > > I have done some rethinking about this and realize this does save quite = =20 > some significant work: without breaking out isolation part from =20 > sgx_reclaim_pages(), I can remove the changes to use a list for isolated = =20 > pages, and no need to introduce "state" such as RECLAIM_IN_PROGRESS. Abou= t =20 > 1/3 of changes for per-cgroup reclamation will be gone. > > So I think I'll go this route now. The only downside may be performance i= f =20 > a enclave spreads its pages in different cgroups and even that is minimum= =20 > impact as we limit reclamation to 16 pages a time. Let me know if someone= =20 > feel strongly we need dealt with that and see some other potential issues= =20 > I may have missed. We could deal with possible performance regression later on (if there is need). I mean there should we a workload first that would so that sort stimulus... > Thanks > > Haitao BR, Jarkko