Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1568922rbb; Mon, 26 Feb 2024 13:48:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW2AldmS4lFgXHDQCDxtRzTzH/hM3n96Pbou9KUApx+d7rvTxzMaHLT9iK2Vdehiame4UHf8lfONx9dsqwtYpn1Wdg4kKhq2jJ16XNgTA== X-Google-Smtp-Source: AGHT+IEcHZ+dvb4pUpUr9k7f/u/GUVUl2oPaZ1I+QIVTz//fhJeoIp+kJTQOsJO0Y1LeCMg8F0T3 X-Received: by 2002:a05:6402:124b:b0:565:7733:3c58 with SMTP id l11-20020a056402124b00b0056577333c58mr5021689edw.4.1708984115467; Mon, 26 Feb 2024 13:48:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708984115; cv=pass; d=google.com; s=arc-20160816; b=oNIvKVIaCrPM5eyHTnAsXnbf8w6I/HB9uUVl5UhQfU9lFZ8OYbkHgM6IIvqjVAfqBJ Qn8YrkCzMos1uQ8yvswq/gwu81jhvEQQyPwRm8DokqHkFUG72TY6/evAP32/QvSNUIM1 Ej/V8FVYBQeIZ2hvtJImWj+6NqnlJ2F/r7w9LXe1y6sZqBxkn2ktsDD0CKumgmcoFBrF qSZIXwI2g6dP6X3zN3pZpZdxwvo4aqg3Sx1PhaPgSK76K0CbvIDh190gUUrvd6zxjZVN ugDyVwqNF6NcnG4BW3lsckjWhUEQh2gJcgEZrR67ocBkV6+4pw2oj7beTpcnUk5rB3fJ oe9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:message-id:organization:from :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:references:subject:cc:to :dkim-signature; bh=dp0lSoT70befeq038YftP5ZmbCV3JPes+gsj+RjtxBE=; fh=RO6Y/PUBxq0ukDdzbdSF6Cn8NSxIEwBSG9N2hX1rTEs=; b=WwJ1QiRgNlv+lCpTdFfCO3MQUNIwzygDEcdk0o4UuXoKk8qyFMNW/zqtriqksIseKS mLmfk/FI+PYQC6/sewGaxtUtQjXN4mKQnuqKokJuUyo6VUK7LGxcLosBUXasSXwCe/bY c74JNewp+1vk8Fa5TIJpJwER/FtPJe7JwvP/Y/CF0GXpvCAGsSQ6dk44p0hqUyjNXpjl /mYyJXNcYxEPwzfVY2EOH5R9hEcbe63J0KFt7Qa8USlDzpHq+iDJ6y5u1559c36NyS1s QWB3xP2m7nrIxTGSZj2kU9L06wj2mgJQSIYDUGcqHM3GP9tUWdcHaRIqJ5dz1vGLIRz9 1raw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CaZqnfpk; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82369-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82369-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x12-20020a50d60c000000b00563948cbff6si113580edi.348.2024.02.26.13.48.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 13:48:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82369-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CaZqnfpk; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82369-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82369-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3B3281F2451E for ; Mon, 26 Feb 2024 21:48:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6326131E28; Mon, 26 Feb 2024 21:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CaZqnfpk" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 7788D1DFCD; Mon, 26 Feb 2024 21:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708984107; cv=none; b=l0GZ0jEZABUBJFrTfA/B5LSWcMnehsI3G12Y9y8KCA+r8JNJ1dCYF6vCe1zOvODIllB6FxeITs4zuV8WIbXSyzoNwscrZ+qwLczmxVXpRK0RfpERe2PcJbi50+hYu1cJi9ze109BsfXFUXLN7ZB9wDVMy9PPoFY0h2eEDJEKims= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708984107; c=relaxed/simple; bh=p1RkEchGE/mNaNi3qBs14D7WQ1wY+4Ol5xO9+bc3K1o=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=RtPKLfcGb1clUEu5BgI/8+qtwVUQbPDr10nueKbm163jlFFBEesRZI0chdHSfrjWpPy/1XcDO0YUC7YK6VOkJ4YCj0EPlpquPx7Cu5ptCQHj4OhS+bMhJdXci6kFtXJbm9Dzh8wKFaCURRSrBiaU8WHhXgWf3y2WaEl3cfcLpro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CaZqnfpk; arc=none smtp.client-ip=192.198.163.9 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=1708984105; x=1740520105; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=p1RkEchGE/mNaNi3qBs14D7WQ1wY+4Ol5xO9+bc3K1o=; b=CaZqnfpkB2fw7JFZEvCz/ylI2YALJyoyJTauYm3EG3lIbdquUKOAddep f6l3O1SgoF4MtP5o+vPetFx8y0jz7FGQhqt1LmxAFHFVjbq6CqhlOrgMD 4tFO8tDdCTIWcPXo0XH8A4hs6xdfHR8sTzr0+2ue9Rkm+ApWuirAT5MwZ bfa+1yX35M1Xgyrho4eB4HwxWYSKk7WKSinqsaFZfW+3b8WPTg+7o2iRl 8WnJrXjPc/SyrupkXm+zr7PZoyqntCTEULecC3to9HtZ155XJ6MWeXV2B QQHAO+ePBRtgryb5GRiIggZuET1LvJODYs1EoXbX7oYxl7IySYHyjOMdi g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14010315" X-IronPort-AV: E=Sophos;i="6.06,186,1705392000"; d="scan'208";a="14010315" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 13:48:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,186,1705392000"; d="scan'208";a="7225171" Received: from hhuan26-mobl.amr.corp.intel.com ([10.92.17.168]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 26 Feb 2024 13:48:20 -0800 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Huang, Kai" , "tj@kernel.org" , "jarkko@kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "tim.c.chen@linux.intel.com" , "mkoutny@suse.com" , "Mehta, Sohil" , "linux-sgx@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "bp@alien8.de" , "Dave Hansen" Cc: "mikko.ylinen@linux.intel.com" , "seanjc@google.com" , "anakrish@microsoft.com" , "Zhang, Bo" , "kristen@linux.intel.com" , "yangjie@microsoft.com" , "Li, Zhiquan1" , "chrisyan@microsoft.com" Subject: Re: [PATCH v9 10/15] x86/sgx: Add EPC reclamation in cgroup try_charge() References: <20240205210638.157741-1-haitao.huang@linux.intel.com> <20240205210638.157741-11-haitao.huang@linux.intel.com> <4db8493b-35a2-474f-997c-5e6ac1b8bd11@intel.com> <7b53e155-2622-4acb-b7c9-d22e623e4cb3@intel.com> <48faaea8b24f032baa6a858a2909a5b4ace769c6.camel@intel.com> Date: Mon, 26 Feb 2024 15:48:18 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Message-ID: In-Reply-To: User-Agent: Opera Mail/1.0 (Win32) Hi Dave, On Mon, 26 Feb 2024 08:04:54 -0600, Dave Hansen wrote: > On 2/26/24 03:36, Huang, Kai wrote: >>> In case of overcomitting, even if we always reclaim from the same >>> cgroup >>> for each fault, one group may still interfere the other: e.g., >>> consider an >>> extreme case in that group A used up almost all EPC at the time group B >>> has a fault, B has to fail allocation and kill enclaves. >> If the admin allows group A to use almost all EPC, to me it's fair to >> say he/she >> doesn't want to run anything inside B at all and it is acceptable >> enclaves in B >> to be killed. > > Folks, I'm having a really hard time following this thread. It sounds > like there's disagreement about when to do system-wide reclaim. Could > someone remind me of the choices that we have? (A proposed patch would > go a _long_ way to helping me understand) > In case of overcomitting, i.e., sum of limits greater than the EPC capacity, if one group has a fault, and its usage is not above its own limit (try_charge() passes), yet total usage of the system has exceeded the capacity, whether we do global reclaim or just reclaim pages in the current faulting group. > Also, what does the core mm memcg code do? > I'm not sure. I'll try to find out but it'd be appreciated if someone more knowledgeable can comment on this. memcg also has the protection mechanism (i.e., min, low settings) to guarantee some allocation per group so its approach might not be applicable to misc controller here. > Last, what is the simplest (least amount of code) thing that the SGX > cgroup controller could implement here? > > I still think the current approach of doing global reclaim is reasonable and simple: try_charge() checks cgroup limit and reclaim within the group if needed, then do EPC page allocation, reclaim globally if allocation fails due to global usage reaches the capacity. I'm not sure how not doing global reclaiming in this case would bring any benefit. Please see my response to Kai's example cases. Thanks Haitao