Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp177064lqt; Wed, 5 Jun 2024 23:20:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVSVihMnomh0rH3sF7PcfoejlKIVqp8/8oApoA5Z6Yfs3AuH1ye0kZ/PCBcBK6AmvALBdVRDUbv5+IQomiEDiIPylxYuKEQp/xhhT0Gw== X-Google-Smtp-Source: AGHT+IH5bYcjHRsnyWAIns7D3FwZz/TMAgP6SxFfW1BtzNJ75AFaak4S/QIP/OBFDOMHL+a2/3G8 X-Received: by 2002:a17:903:244c:b0:1f0:67ea:cdf8 with SMTP id d9443c01a7336-1f6a5a699d0mr50147915ad.46.1717654846494; Wed, 05 Jun 2024 23:20:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717654846; cv=pass; d=google.com; s=arc-20160816; b=Wd5PPmMCymudnAhLgCuyBl4NtiGWorHipyYDz9pmfq2hRDA5s5sz6rOMLP58fVY4Gy Kf/TWns/XO8P3GBDgGLazhiHU6x6BdumdCIvJbfRfEXCYgyeIVJjteP7V3J1/rsZLqYK auliisUVpksNBm5OHNKx7ZR+B6crS/AXAiRvEI8PFRbGPS2ozHLFCH98ErZdiYkcCVJI 2lVbCfihoYoOkgZ6RTdGk230aoF5jTBWwJlaPR4c0fo7yw3nTVyOAyAOy88YBXQ5YlZ2 Rq5m4MMzWO/uuD8IJ2Dq6hAKnTR0Jt6uVYchUkc4OMFlIYs0yBeiQI8NutZUiQrJzxsy p09w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=OQll26Gao9qAcKkuXr7oV99j22xA1SQNjxd/pnutndU=; fh=t1kmD/43USUJm5EQTSiJdbSs6MbXoHEoymRsn39D33M=; b=sQfDiej7z32oUNlQH5AoEMhrXPnWYUL1mU+dFCFc1yVg1zc0sYsCtMOzkv+BFKfBbM bvNkVPTKtqQzLJJmt9cRdGP3vNbRsgjbrpSWnNVxJEjmVLbfvuZ2rDXDbPhvSNw5qqVZ uC6g72qu9tU6aO2EoLABZZ7XuUldICc9EWn16IPF3uMsaJvGTvvg0Tmk50KSEuL2GR44 CVYMkTZ26YSz6wfOxjOXi6nzUbhYpZNk7Zrd7vPJ9FTNFg0gTlDLhc9oaCsS3x/iK1Yr 1mCqt80jPmOPfyQFJUH2OOpxebQEduoXAWzqSKBaq1aSUPs0+Jd1L69sjvh4M3Bk9T/G rfYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PFYPckTw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203649-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7d4c66si6059825ad.221.2024.06.05.23.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 23:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203649-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PFYPckTw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203649-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203649-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 555FB287A99 for ; Thu, 6 Jun 2024 06:20:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E96278C96; Thu, 6 Jun 2024 06:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PFYPckTw" 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 9C1F23A8CB; Thu, 6 Jun 2024 06:20:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717654823; cv=none; b=bUcyfW44Cd00ms+8L3NSsgDGXdJ4w3Vlc7yIog6bEhPVrTV6ocmkmsOv2wYZafW3E31QAo3eCLnzBJWoesl/yuIpwMF1ZVBsF01kPxvYnIPMkKpnXC6AWNWI7L/h9616XrEwBWjxngK8EACMeHhlP/SgjDsdYmJNlpRIXLFfQXw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717654823; c=relaxed/simple; bh=j0MquPfi/vCjoi1SmAsqOpd/5qF8sXpBLh7cch3Ljiw=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=PBak9+50exSNg+pszKa0jTUK28i+44GZrEmYgDbdC1of1iM1nyNz73VJnS36VSQ/6Rb8fISKKnlYpvOMwBurcjdjIzNq2CLu7qCEFI+dHgYeIAVTCJrvl9UJ/89UtDNMSXkk2J9abXGXzihbRIeARSRhR0J4pOhBwOX1JN8EPH4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PFYPckTw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71D27C2BD10; Thu, 6 Jun 2024 06:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717654823; bh=j0MquPfi/vCjoi1SmAsqOpd/5qF8sXpBLh7cch3Ljiw=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=PFYPckTwPtlU2Q6yc2XxFDj1a4kOn7LPfgUd8jE1iMpKXfHW+p4h38pdWBX7uCPNg ABNcAPIOO/0qVJu7MZE/2Fg8eB6PhV+VWJ9DDYy31koefpByBBW6mWzsjf/aL7Snae e0ryAUwdMnZmWjWQkTJ+XhL/zAFSZjfUF4KuXUo51cHLCQTT2TkaykKB5/vVJRE7gN U3FNRzkxCOu6fdVgBfZHYlI36zCkSRZ3IEu0d2lxSsk1HvZiUu9Z5ugzim4Zfn24al DHI+HTxvuvHFx31ORBKtvNRE2gkE9XmgcLbZwpUPjHwsMwklbqsHetWUUu3Mofarqp c6Nf3X3FhBifA== 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: Thu, 06 Jun 2024 09:20:16 +0300 Message-Id: Cc: , , , , , , , Subject: Re: [PATCH v14 14/14] selftests/sgx: Add scripts for EPC cgroup testing From: "Jarkko Sakkinen" To: "Huang, Kai" , "Haitao Huang" , , , , , , , , , , , , , X-Mailer: aerc 0.17.0 References: <20240531222630.4634-1-haitao.huang@linux.intel.com> <20240531222630.4634-15-haitao.huang@linux.intel.com> <7cbf3583-a23e-4437-afc2-1faeb4a1f436@intel.com> In-Reply-To: <7cbf3583-a23e-4437-afc2-1faeb4a1f436@intel.com> On Thu Jun 6, 2024 at 1:30 AM EEST, Huang, Kai wrote: > > >> Reorg: > >> > >> void sgx_cgroup_init(void) > >> { > >> =C2=A0=C2=A0=C2=A0=C2=A0struct workqueue_struct *wq; > >> > >> =C2=A0=C2=A0=C2=A0=C2=A0/* eagerly allocate the workqueue: */ > >> =C2=A0=C2=A0=C2=A0=C2=A0wq =3D alloc_workqueue("sgx_cg_wq", wq_unbound= | wq_freezable,=20 > >> wq_unbound_max_active); > >> =C2=A0=C2=A0=C2=A0=C2=A0if (!wq) { > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_warn("sgx_cg_wq creation= failed\n"); > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return; > >=20 > > sgx_cgroup_try_charge() expects sgx_cg_wq, so it would break unless we= =20 > > check and return 0 which was the initially implemented in v12. But then= =20 > > Kai had some concern on that we expose all the interface files to allow= =20 > > user to set limits but we don't enforce. To keep it simple we settled= =20 > > down back to BUG_ON().=20 > > [...] > > > This would only happen rarely and user can add=20 > > command-line to disable SGX if s/he really wants to start kernel in thi= s=20 > > case, just can't do SGX. > > Just to be clear that I don't like BUG_ON() either. It's inevitable you= =20 > will get attention because of using it. Just then plain disable SGX if it fails to start. Do not take down the whole system. > This is a compromise that you don't want to reset "capacity" to 0 when=20 > alloc_workqueue() fails. BUG_ON() is not a "compromise". > There are existing code where BUG_ON() is used during the kernel early=20 > boot code when memory allocation fails (e.g., see cgroup_init_subsys()),= =20 > so it might be acceptable to use BUG_ON() here, but it's up to=20 > maintainers to decide whether it is OK. When it is not possible continue to run the system at all, and only then. Here it is possible. Without SGX. BR, Jarkko