Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2496212lqt; Mon, 22 Apr 2024 12:20:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhmdEXnWqmDdpRDooPF1U0vwggi3e2BaAuqHm87rIk4tn0awt4sUATRn99Je3v1pN+eikluAHlEQhOWjkgQ5rPL7IwUdSQ+hHFhcHoRw== X-Google-Smtp-Source: AGHT+IGGeRbL+Yz3IlXE7VgybeTTAneHVsOhZgC81zLKvLy+pSE6qK2pOmKpd1yvnPxgKgBuwddu X-Received: by 2002:a05:6a20:9f08:b0:1ac:4ef9:3d53 with SMTP id mk8-20020a056a209f0800b001ac4ef93d53mr11426054pzb.5.1713813635561; Mon, 22 Apr 2024 12:20:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713813635; cv=pass; d=google.com; s=arc-20160816; b=U4uAaBkmNQ0Rxdyzv4dIYC7PWKAck4a5gdbx5W4nHHsXx28hnnm9We1+PdokA9snLw 5+Zd9ERS5yzfrgvkIQ5Egk9KDh9xe7R19yNoHCk28iHUtGmJNBDD2LOPk/sQt2NqEOsE IA+uZhgnMGOiBhgNC8ExydksaW8Mh8coYVkCRI6qkGxGz0rR9e4iYtBd0DCIam5QktXY GnWHxzlilccSkU2E9bfHvGPGv5frs07fCpmD8103tEJKboxhQS5CAyOmUXnAuW6ZtGML 6Jb3YnQhxxnVWflQluoZodwGKM2X3jJw7dXigl6ul4Pxtk1FiXeIYP7S0ZvBVMP+WidF ul8g== 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=b8b5o/MQOIlNFeW0BHpFdIfYRmlRRPGaeJmqhS76Ryw=; fh=7UzHNuuZ8xqWv6S7FduSAlGb/mUlJ87S+85VziWTXqU=; b=AeIkZC1XtCYrTdAycwlBgPFUj2bKvUAwiAW8gM26njPT11rdsx4ZABsyBx11RtZDz6 +lNvBI+DrniQqXGsm4uiVhp6DuB+H3qyGZcFcgmAxvGO53+R/Eyi7qRwD1OCK3amIoD4 +C9YGw0XRkvFRwfd5GFSvwcb/lBWwvSxGrend523AzGSULYHTHfpMj9KS5BciMocSxuy 9dfZO8cqfJIIoMncpqAy4KeEIa4XvjI99jrSRruI3dHsw4DWE/IUI0ZgRAlULTgnTJgM FKCezsi7t9hxkbcq4s+ahB1g+V83bh/Of2Zwr0UQpvXPOAg47D900AS5FIzv61j0R0HB pmCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T2WK9qIZ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-153691-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k18-20020a6568d2000000b005f808f19b65si5045865pgt.412.2024.04.22.12.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 12:20:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153691-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=@intel.com header.s=Intel header.b=T2WK9qIZ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-153691-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153691-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E351CB24F39 for ; Mon, 22 Apr 2024 16:18:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8F7A1509B1; Mon, 22 Apr 2024 16:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T2WK9qIZ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 3B16A153805; Mon, 22 Apr 2024 16:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713802650; cv=none; b=gfX2zeA7HR9tI5MufyabFApEW9Asu6vpOGNqPgsHemCZ0j4kzgMez9YS5rRoNhngnhJxxaLTt3oLpFHJyQBnD+BrAitq62xSnmtBVaqQ9u5XDnPu9igAtdV6s5LR7t5kryqeSPxgk+VAQQJs/ooYs4eXsHzBVlXI+pSR0BXqnd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713802650; c=relaxed/simple; bh=CHj5J2SiKW93Q/oMEtlJw3ktWz2ajC1KqAP798B8a1w=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=I9ZsN54PcuPXZVNyjy5+7XNUNEmHxEF1eOlcvT0loVM4SXd74NiHsCcVwCgZe/U8efoubzxns2dLi0XSZqCMPHgdBjLiVxZfgEygGeVcdPgwphPkq9TBrbKFN1jj8IT8xiwUN/htIjUoDulKY+4q0LBdEK93WWG0gl3mc4BSCQw= 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=T2WK9qIZ; arc=none smtp.client-ip=198.175.65.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=1713802649; x=1745338649; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=CHj5J2SiKW93Q/oMEtlJw3ktWz2ajC1KqAP798B8a1w=; b=T2WK9qIZ4lxUPkCGeU9xHKbd17/MzD+VX6F4c+MZj5wb4urWuRgWpLYu N847rAtDh2U3Rdl+dRU+Ukhjv0iD+bcPvoaO0tFiVgfTKsBQ7Y2wSexp9 4qEMSxrvlH10NogSRLujOHB1jhjs00+0osnG3h7rE2sqcuOeWSQzjJVDg 3tNPcxC3ylp5TP/o/M8AVu7aDFqaacoZTy/99wMPImSv/QjiD0WHnWug/ ArbjiZzHCJR7G34LMbBo8Plr416PCIIevqCqJx3Vf6ZdeAoseSMd6EXO0 0zZdV2igtnrg2q9/atRues5+ERCfmvlwKQ7BFMO/qlG20tsaN3NYIMqkw Q==; X-CSE-ConnectionGUID: kvKBkooqRTaI0ypV09lAMg== X-CSE-MsgGUID: rqtCjlEzTeGImVIthpdarw== X-IronPort-AV: E=McAfee;i="6600,9927,11052"; a="31841215" X-IronPort-AV: E=Sophos;i="6.07,221,1708416000"; d="scan'208";a="31841215" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 09:17:27 -0700 X-CSE-ConnectionGUID: 33tcsd0TR5eTtVLq8D5tJg== X-CSE-MsgGUID: P8l2lfn/QteslRZxuP55ug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,221,1708416000"; d="scan'208";a="24582524" Received: from hhuan26-mobl.amr.corp.intel.com ([10.125.85.20]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 22 Apr 2024 09:17:24 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Mehta, Sohil" , "mingo@redhat.com" , "jarkko@kernel.org" , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "cgroups@vger.kernel.org" , "hpa@zytor.com" , "tim.c.chen@linux.intel.com" , "linux-sgx@vger.kernel.org" , "mkoutny@suse.com" , "tglx@linutronix.de" , "tj@kernel.org" , "linux-kernel@vger.kernel.org" , "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> Date: Mon, 22 Apr 2024 11:17:21 -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 Sun, 21 Apr 2024 19:22:27 -0500, Huang, Kai wrote: > On Fri, 2024-04-19 at 20:14 -0500, Haitao Huang wrote: >> > > I think we can add support for "sgx_cgroup=disabled" in future if >> indeed >> > > needed. But just for init failure, no? >> > > >> > >> > It's not about the commandline, which we can add in the future when >> > needed. It's about we need to have a way to handle SGX cgroup being >> > disabled at boot time nicely, because we already have a case where we >> > need >> > to do so. >> > >> > Your approach looks half-way to me, and is not future extendible. If >> we >> > choose to do it, do it right -- that is, we need a way to disable it >> > completely in both kernel and userspace so that userspace won't be >> able> to >> > see it. >> >> That would need more changes in misc cgroup implementation to support >> sgx-disable. Right now misc does not have separate files for different >> resource types. So we can only block echo "sgx_epc..." to those >> interfacefiles, can't really make files not visible. > > "won't be able to see" I mean "only for SGX EPC resource", but not the > control files for the entire MISC cgroup. > > I replied at the beginning of the previous reply: > > " > Given SGX EPC is just one type of MISC cgroup resources, we cannot just > disable MISC cgroup as a whole. > " > Sorry I missed this point. below. > You just need to set the SGX EPC "capacity" to 0 to disable SGX EPC. See > the comment of @misc_res_capacity: > > * Miscellaneous resources capacity for the entire machine. 0 capacity > * means resource is not initialized or not present in the host. > IIUC I don't think the situation we have is either of those cases. For our case, resource is inited and present on the host but we have allocation error for sgx cgroup infra. > And "blocking echo sgx_epc ... to those control files" is already > sufficient for the purpose of not exposing SGX EPC to userspace, correct? > > E.g., if SGX cgroup is enabled, you can see below when you read "max": > > # cat /sys/fs/cgroup/my_group/misc.max > # > sgx_epc ... > ... > > Otherwise you won't be able to see "sgx_epc": > > # cat /sys/fs/cgroup/my_group/misc.max > # > ... > > And when you try to write the "max" for "sgx_epc", you will hit error: > > # echo "sgx_epc 100" > /sys/fs/cgroup/my_group/misc.max > # ... echo: write error: Invalid argument > > The above applies to all the control files. To me this is pretty much > means "SGX EPC is disabled" or "not supported" for userspace. > You are right, capacity == 0 does block echoing max and users see an error if they do that. But 1) doubt you literately wanted "SGX EPC is disabled" and make it unsupported in this case, 2) even if we accept this is "sgx cgroup disabled" I don't see how it is much better user experience than current solution or really helps user better. Also to implement this approach, as you mentioned, we need workaround the fact that misc_try_charge() fails when capacity set to zero, and adding code to return root always? So it seems like more workaround code to just make it work for a failing case no one really care much and end result is not really much better IMHO. Thanks Haitao