Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp85831rdb; Mon, 18 Dec 2023 09:32:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2o0jPWhuHQkCYWLG79o2CrgxGOfOfRBicDqlL3CSvhjd9Gn0/Fx9gjLfiU6UMdVW1tpkM X-Received: by 2002:a05:6871:79a1:b0:1fa:f049:7a21 with SMTP id pb33-20020a05687179a100b001faf0497a21mr10349266oac.13.1702920779381; Mon, 18 Dec 2023 09:32:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702920779; cv=none; d=google.com; s=arc-20160816; b=REnMbL+Qge+vjHIYNnkllsTEAyqTQav0b91rH7W6vwnjv2+Mr6iaogDx02p+ewtxBs 2+iAE08YLLiKF/V5Lmo16evZ4i8TzIoYjlWpFF4qw8a7aZOJ6pl/pQ99+OXWpaBsqZf8 Z37utPpiK1KIglk5tAFaYk19C0H9fFch83gzLFSztwjYrpRS8BPWDTOOpbYjDwtXnzG5 bMoGrsNeV0sZyUG4pajpS3U1p+vrDENBFNtixbcy9Jm69fObFLRkOSMsCQQDVuqaNlNN iPXqCjjm1G6ACEsw7V173hGVeZ9A8sMctoaaoNKHOZj7svtnVzlj/qsUOjWwlLVCr5Ea qLTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nkGgAoQeUKWeSaBx4HDQDEPU7lcr8QyTUhD2iTI9hqc=; fh=RQ7KMYAIOMP0FU9lPYMXKCZYqDWyKh6QIZNCVCFAXkk=; b=MuLkm8gC2kaiEt0Yn1msZsBZz8RGwMJS39z10izXHGqOgDyGMPs/s+MCm3/vkzacKX eLyjftJ7YqUKp85dobURy9WM1XxnDA2F+n27vVndR5PFrZF60p1PqFYiCDdAGykE0g9i 3KFQcHa0vKWfqdJRNRpqFwgksTgWSYBIEFRW0O/zp/8RqsbOxDKwa1VnCsUu4wEyXpMY VoYmLK6IjkfiDqFE/N0YTjri5q7cjtEzp/vLaW62Zn7wGg+dHWLD3lLNr7+1nt2qPMe+ XPBlYS3bord3akT/b6YGqNrftkqInL5gXtwDr6ATsROzfKe4xuIMkr5h+oAXvx3sw8Nj +fLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GfPGXu6b; spf=pass (google.com: domain of linux-kernel+bounces-4174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id cm9-20020a05622a250900b004254a8e613asi26809888qtb.667.2023.12.18.09.32.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:32:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GfPGXu6b; spf=pass (google.com: domain of linux-kernel+bounces-4174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 01DC31C24EB9 for ; Mon, 18 Dec 2023 17:32:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 084E05BFAC; Mon, 18 Dec 2023 17:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GfPGXu6b" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 AB426498B7; Mon, 18 Dec 2023 17:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702920769; x=1734456769; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=4oSlzXrGumApmOxCKuJUTQ+F3TdnkbybnKrRfJmNmwA=; b=GfPGXu6bt/eJs8Au2xoP3j3Gnh4bp+ORKxUgG6eKGdX6AXgcDr3yFgul GULYGwAEX59zueZLz+PE3WZ9QAuQydnWdFnjrzlBEpceapWVq672iCwxb ITOXyaVPqn/0nYXkzW6EIlZCQ2bpqpBlRE8ELIHBIetvPeSCtDJmBinwT L9OvXtXRY8GfTjh0/80N7wBhGQUZ7Ln2m4GwCqhceXLjvZUBwAGgsNKD8 1Tw3EhK3/+tkzG/UIeIEHEEmyVJl5t85RPVIMroxFHRRwJhVlOmilDNTk 0MENoy5afAKYXrTEneDbj8YZLcN85D8/Ws1oBRTpurDEqq3HAvkZrczGq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="8909211" X-IronPort-AV: E=Sophos;i="6.04,286,1695711600"; d="scan'208";a="8909211" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 09:32:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="751829307" X-IronPort-AV: E=Sophos;i="6.04,286,1695711600"; d="scan'208";a="751829307" Received: from tvonhert-mobl1.ger.corp.intel.com (HELO himmelriiki) ([10.252.33.220]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 09:32:14 -0800 Date: Mon, 18 Dec 2023 19:32:05 +0200 From: Mikko Ylinen To: "Huang, Kai" Cc: "Mehta, Sohil" , "jarkko@kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "tj@kernel.org" , "mkoutny@suse.com" , "haitao.huang@linux.intel.com" , "tglx@linutronix.de" , "linux-sgx@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" , "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 Message-ID: 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73ed579be8ad81835df1c309b7c69b491b7f2c8e.camel@intel.com> On Mon, Dec 18, 2023 at 01:44:56AM +0000, Huang, Kai wrote: > > Let's focus on enabling functionality first. When you have some real > performance issue that is related to this, we can come back then. > > Btw, I think you need to step back even further. IIUC the whole multiple LRU > thing isn't mandatory in this initial support. > > Please (again) take a look at the comments from Dave and Michal: > > https://lore.kernel.org/lkml/7a1a5125-9da2-47b6-ba0f-cf24d84df16b@intel.com/#t > https://lore.kernel.org/lkml/yz44wukoic3syy6s4fcrngagurkjhe2hzka6kvxbajdtro3fwu@zd2ilht7wcw3/ I don't think setting a hard limit without any reclaiming is preferred. I'd rather see this similar to what the "sgx_epc.high" was in the RFC patchset: misc.max for sgx_epc becomes the max value for EPC usage but enclaves larger than the limit would still run OK. Per-cgroup reclaiming allows additional controls via memory.high/max in the same cgroup. If this reclaim flexibily was not there, the sgx_epc limit would always have to be set based on some "peak" EPC consumption which may not even be known at the time the limit is set. From a container runtime perspective (which is what I'm working for Kubernetes) the current proposal seems best to me: a container is guaranteed at most the amount of EPC set as the limit and no other container gets to use it. Also, each container gets charged for reclaiming independently if a low max value is used (which might be desirable to get more containers to run on the same node/system). In this model, the sum of containers' max values would be the capacity. -- Mikko