Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp119457lqd; Tue, 23 Apr 2024 17:26:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW++tDO7FsJWocHlyYIZEtnNEAEkUAgeedILsEjEKIJG/e91f2rWRrkGHLT6D834dvCmajao/wuX+/jSbxVbILzXHT3iHo9HvktUO+krw== X-Google-Smtp-Source: AGHT+IEAyA2Rj8/z3LGOr9PQtO6vutdBYFSVAa/LdHj9cbwzsMf817yVwH9nopnpd6RIlUFUBtov X-Received: by 2002:a05:6a00:a86:b0:6ea:749c:7849 with SMTP id b6-20020a056a000a8600b006ea749c7849mr1744103pfl.13.1713918391763; Tue, 23 Apr 2024 17:26:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713918391; cv=pass; d=google.com; s=arc-20160816; b=w+bvMX4ww4N7KSB6HuwlHmkkaG3XD9kHZYHTlirZzzN5m7sPXRp7KpGf8AEuDhPVEp Z02r+ZYAEJxti6um0uklkRDsyC3XulTtp24aIpMn206BupZ4o+37TH9Xu2YapoWSttko fWZ1iiovaDzoZLxADRa+saEahwUKLIAHP9nbTb9jDYlsqs+gHLY9W3Co5jbo5oebVv0Z VdnSQtljKqHF7lpkvq75hivBNfCjtYsak3t9wWfoW032dDxbgG0BbiUbpN1gk60DT1H5 srvOg/varDvTwvDN8H7S+sVRQneAhYIFPZWX1ghCWXwRRtN1bqnO+ZCMIgMVFpxEHd8J 5AUg== 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=fJWh1D13QTowwgwX0xyz2SOhx2bLk8L0enoj9348Y3I=; fh=OK8hE/OGnMxIReEQZhYf6bwp8mUGPbh0xxxskt7wcn0=; b=W6uX1KdMJ/k/EN3xTYd7GmkQ3V3ixtGZuzNW3azIJT6i5D6ofZAxhBkWz4HZtpS7lZ m+dEEE9oiTzOrJvGb5aY4bPt+sVVDcieygw/E+0aegMbvp5m+wH5RHN4clpAa+Ad5Tp+ pqcCcJyGDVQemLQOtK3bvkwGQ8Tzp18huGg5nfh4VU2QfxH2q4Y/6csigF2LQgqMd5H1 uv/1HkkMUhlmWT4lk0bfo4nean1M0pcjeaVidh/92/slEOiwBKmdGanOk3qaoWvbGMWH 6nszbGTrKtLTgf3bx/iga2IHi9S5IdbJHykthQpEEsNZ9QNq1P9Of/fBGFuHY5uMvFFc sMDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="T/6SaNRk"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-156055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156055-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f8-20020a056a00238800b006ecffe7c32asi10648847pfc.15.2024.04.23.17.26.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 17:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="T/6SaNRk"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-156055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156055-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A6DA4287F54 for ; Wed, 24 Apr 2024 00:26:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56AF91C36; Wed, 24 Apr 2024 00:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T/6SaNRk" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 02A33363; Wed, 24 Apr 2024 00:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713918382; cv=none; b=TwGwNi8wQoeg2OIoS81mmYeYdM39onANQTomWDiYNIEVZ+U+chXDRE2wBevWOjr6hXimW7uksks//n1aMvkCP6syU91xQciGrrioCdiQmrgM6EkiQ1NYY0Yu9uz5qkmMx8kWDkOA6U8HEynuX20/VRc5I4KShfY7Hlu7xEvTVo4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713918382; c=relaxed/simple; bh=AuZge035jK1lr9CSiJ18H/bDqMTgmAXL4Ovt7rRbaQ0=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=BXQJz2HIlYGBpi4qANJTxXN94hi/sI6mFmvUJYYA8qnFDaMM996c6m+niEeCS08NEoQGGRgQEi98uR7HJJflMOzrJQolK9XP8sVdO8lwQGhtpxmLkAUDgcBYfdz/geh6dh22d2m95OoPanFiP8LUF3/A35CNWFRNhEOe2SZmqD0= 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=T/6SaNRk; arc=none smtp.client-ip=198.175.65.17 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=1713918382; x=1745454382; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=AuZge035jK1lr9CSiJ18H/bDqMTgmAXL4Ovt7rRbaQ0=; b=T/6SaNRkjqgAydMTYixO/4Oil0/UKIZCx4pIBRxO+7I08afc/BQHI1mu gxv421xYl+LeTOjniWaqLq+TT3SAx+D40iJshjPMpytYosI+zBmIKeZ25 5IZNqu6vMuP8VkEQym1CTkJbi+b8S5NfOccSZXu/KfLDyp+SowoRJ6Bg/ O2BySMXadL2yhteJKB9bw+stZ/JaP2lMdBd+fvT7lmMlQhBKlej5snSG1 ih9xHQQa8HDRgZ6bHOnN0/thSB5tBe7ZpBvxfgL+wwHOsdV7ByFDWKYJE MKHBCPw/OW6YIkP45gsww4J1semuIGHlFaWpSp89hXo6YY/50eYkMoulD g==; X-CSE-ConnectionGUID: 6DJ6IAprQvOiRIUBjY/B6A== X-CSE-MsgGUID: vRDgYvBgQXGmjOO8GlHWoQ== X-IronPort-AV: E=McAfee;i="6600,9927,11053"; a="9638452" X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="9638452" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2024 17:26:22 -0700 X-CSE-ConnectionGUID: rW7drRa6RP+lp5kZnVykDA== X-CSE-MsgGUID: Lr/lQ9SdSdyaE/UKq7ut8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="24581795" Received: from hhuan26-mobl.amr.corp.intel.com ([10.125.85.20]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/AES256-SHA; 23 Apr 2024 17:26:17 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "linux-sgx@vger.kernel.org" , "jarkko@kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "mkoutny@suse.com" , "Mehta, Sohil" , "tj@kernel.org" , "tim.c.chen@linux.intel.com" , "tglx@linutronix.de" , "bp@alien8.de" , "Huang, Kai" 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 v12 09/14] x86/sgx: Implement async reclamation for cgroup References: <20240416032011.58578-1-haitao.huang@linux.intel.com> <20240416032011.58578-10-haitao.huang@linux.intel.com> <640866c5-9fe0-4f7b-a459-7a685dbe4092@intel.com> <4be309656cb4e03793703098bbebab3dee93077e.camel@intel.com> <914371bd0673870c03e5f4c37db5a2a08fc50aa4.camel@intel.com> Date: Tue, 23 Apr 2024 19:26:15 -0500 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) On Tue, 23 Apr 2024 17:13:15 -0500, Huang, Kai wrote: > On Tue, 2024-04-23 at 10:30 -0500, Haitao Huang wrote: >> > > It's a workaround because you use the capacity==0 but it does not >> really >> > > mean to disable the misc cgroup for specific resource IIUC. >> > >> > Please read the comment around @misc_res_capacity again: >> > >> > * Miscellaneous resources capacity for the entire machine. 0 >> capacity >> > * means resource is not initialized or not present in the host. >> > >> >> I mentioned this in earlier email. I think this means no SGX EPC. It >> doesnot mean sgx epc cgroup not enabled. That's also consistent with the >> behavior try_charge() fails if capacity is zero. > > OK. To me the "capacity" is purely the concept of cgroup, so it must be > interpreted within the scope of "cgroup". If cgroup, in our case, SGX > cgroup, is disabled, then whether "leaving the capacity to reflect the > presence of hardware resource" doesn't really matter. > So what you are saying is that, the kernel must initialize the capacity > of > some MISC resource once it is added as valid type. > And you must initialize the "capacity" even MISC cgroup is disabled > entirely by kernel commandline, in which case, IIUC, misc.capacity is not > even going to show in the /fs. > > If this is your point, then your patch: > > cgroup/misc: Add SGX EPC resource type > > is already broken, because you added the new type w/o initializing the > capacity. > > Please fix that up. > >> >> > > >> > > There is explicit way for user to disable misc without setting >> capacity> > to >> > > zero. >> > >> > Which way are you talking about? >> >> Echo "-misc" to cgroup.subtree_control at root level for example still >> shows non-zero sgx_epc capacity. > > I guess "having to disable all MISC resources just in order to disable > SGX > EPC cgroup" is a brilliant idea. > > You can easily disable the entire MISC cgroup by commandline for that > purpose if that's acceptable. > > And I have no idea why "still showing non-zero EPC capacity" is important > if SGX cgroup cannot be supported at all. > Okay, all I'm trying to say is we should care about consistency in code and don't want SGX do something different. Mixing "disable" with "capacity==0" causes inconsistencies AFAICS: 1) The try_charge() API currently returns error when capacity is zero. So it appears not to mean that the cgroup is disabled otherwise it should return success. 2) The current explicit way ("-misc") to disable misc still shows non-zero entries in misc.capacity. (At least for v2 cgroup, it does when I tested). Maybe this is not important but I just don't feel good about this inconsistency. For now I'll just do BUG_ON() unless there are more strong opinions one way or the other. BR Haitao