Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2787127lqz; Wed, 3 Apr 2024 08:35:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyLt5nDTo3HR0NubwI3kjVhiKPC1aePrJSHIR3/AdFEbrbvfrP8WA3WqmhUy+5eLg0sDWWMiI88ko7xxI84DQAUJxEiDF910Huk6RB5Q== X-Google-Smtp-Source: AGHT+IEq091Vg+ZQvwNuai7Cj0mtqT4oD8xhVO0LFHTEJ8sBsneEni8vM1nhPsC95d13S892lAa5 X-Received: by 2002:a17:90a:5891:b0:2a0:9b66:8e22 with SMTP id j17-20020a17090a589100b002a09b668e22mr11205920pji.24.1712158528758; Wed, 03 Apr 2024 08:35:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712158528; cv=pass; d=google.com; s=arc-20160816; b=ongRsoRo/dtbjkfKnvHt91VaZqrPKnxoRxrXEJCXBt79IVL/p8K7ssrXfHZUuihwLs IEcHxA1h2LKhHJsAV8F/RrMUxZLwcsYvCAg1L358PPj7JVwq5aJjE0PLaOeNffmLkUkI 2k131dUMZ+xwrTc+PRJIcj4Iz8lrwO6KFgAyvecyPrnupihR68bfu2DxfWkAdSQS19RZ TYVNF2Kwk/9T2JT4BW2rPkeXtHhxFkwAYoikaMijqVsyLse/hHa/kK2qR2Gi8OxI5Af2 UU7bG8cszWclg71lkQtDXmt/KxIMTedk9bdk23PuTGbyXlqQKXov/fpnnSWW5kbMuv3S EVIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=DYcGnUJoaoJLE/LPPGuwBKIHSRIH4Nk88b9kS3CyxXc=; fh=Svf3HfLV1E01UW3PO6Vi4CbeABeNA/NlRWKcmiNGP+M=; b=fF0XAtiLiSXeg1/2T7T5EdMi3Er0f4UinZRaU+cCQCvQDWR/fJSmvcNwWu5Ux3JgKi JYdelhhYS2y+gIOvnChkMeyH9wi2EO0n9j8UtnRG4cccdpK9+6PvdYYiPn7BqxXUTcvt sdK0X2uJ49gNq/aq+PszvYPLEfm2BiUrmLCPD4HjiBW3DSbRGfxjuWtnNgXiOdPILFEG /kJ589Q+QxXrGtbRCnMsORzo+VQSzsyL0Dz4+t3hDHM8HVtn88EgnC+NS1t2V3cFElH/ sDgxPP484fXY2Tlz1q3E4R58nd/2M2h+71lXh/WuJp/BYbfh0NV0c1+hCYoroehhI1cG rpYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E7ZFqz7M; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130098-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k3-20020a17090ac50300b0029de97229e8si15054247pjt.189.2024.04.03.08.35.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130098-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=@kernel.org header.s=k20201202 header.b=E7ZFqz7M; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130098-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130098-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 3D47D28A51F for ; Wed, 3 Apr 2024 15:34:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 785F114A4CA; Wed, 3 Apr 2024 15:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E7ZFqz7M" 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 9A47714A092; Wed, 3 Apr 2024 15:34:31 +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=1712158471; cv=none; b=kMrh93Vc7cb0Y5RKfVFnpT5lylzA1CBb7TsPpWp6vNTdzM+O0zcE9WX0UM+SklGjDkt7InU29Odium/aAuq6wOyCo4zVVYkS0JxE2ywTiiKh99DcKrOIo8ARhJiQkqXqD3kqfvVSl7kqLQIdQvhycu7Hyidc7E1yQ5+E0O2048s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712158471; c=relaxed/simple; bh=Mxc+CC8sC/scrgK6foejLgrA2eOYbMZE4L+NN/kTniA=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=u+QVpBHHLSwJ8IKetn+JaZlzKOFaWeChtWEYOUjOBpz5CaD7egs6evsqlVTystP4oJ+3NkraoFH1zb34d40l83VER07JeUpo7FeJwvPy56BxvE65NE9HQfDfEejr7qv+eLTDxvRHRyLdwREA63pCgbJyl+j53fhN/qqqL8wEAlc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E7ZFqz7M; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A80CEC433F1; Wed, 3 Apr 2024 15:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712158471; bh=Mxc+CC8sC/scrgK6foejLgrA2eOYbMZE4L+NN/kTniA=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=E7ZFqz7MZg+3CPEomG/D2lcumlgIERtDKcjeo603ozf4CuxA8Ko6KDuBfNfsRukNz iU2nxtDWub9HYPkJtDmGCCZOOoRJR/ydGBKcrp6NnYlBRYUvhEfymlUlTqpAnUTVAB 2weWAnkzLdog+IEW+Rp769dAtV+mKoc2j4RpoIQBV2XicEk17tFzhK9cGf9YYMLjUB +h5gU6Qd054+0Rf0BpQSjCeqfbo57b4gGycTh++/hVa9Sji6MojEY21x2Q4mmB8/GO VdCrC4ADZFBuVbDwm7OXooLH2NencpaZLdVwuQ/xEZj/AWdcA/0Qolkj/LBe81KXr6 nTrc6IR0Quhvg== 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: Wed, 03 Apr 2024 18:34:24 +0300 Message-Id: To: "Haitao Huang" Cc: , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2] selftests/sgx: Improve cgroup test scripts From: "Jarkko Sakkinen" X-Mailer: aerc 0.17.0 References: <20240402014254.27717-1-haitao.huang@linux.intel.com> In-Reply-To: On Tue Apr 2, 2024 at 8:31 PM EEST, Haitao Huang wrote: > On Tue, 02 Apr 2024 02:43:25 -0500, Jarkko Sakkinen = =20 > wrote: > > > On Tue Apr 2, 2024 at 4:42 AM EEST, Haitao Huang wrote: > >> Make cgroup test scripts ash compatible. > >> Remove cg-tools dependency. > >> Add documentation for functions. > >> > >> Tested with busybox on Ubuntu. > >> > >> Signed-off-by: Haitao Huang > >> --- > >> v2: > >> - Fixes for v2 cgroup > >> - Turn off swapping before memcontrol tests and back on after > >> - Add comments and reformat > >> --- > >> tools/testing/selftests/sgx/ash_cgexec.sh | 57 ++++++ > >> .../selftests/sgx/run_epc_cg_selftests.sh | 187 +++++++++++------= - > >> .../selftests/sgx/watch_misc_for_tests.sh | 13 +- > >> 3 files changed, 179 insertions(+), 78 deletions(-) > >> create mode 100755 tools/testing/selftests/sgx/ash_cgexec.sh > >> > >> diff --git a/tools/testing/selftests/sgx/ash_cgexec.sh =20 > >> b/tools/testing/selftests/sgx/ash_cgexec.sh > >> new file mode 100755 > >> index 000000000000..9607784378df > >> --- /dev/null > >> +++ b/tools/testing/selftests/sgx/ash_cgexec.sh > >> @@ -0,0 +1,57 @@ > >> +#!/usr/bin/env sh > >> +# SPDX-License-Identifier: GPL-2.0 > >> +# Copyright(c) 2024 Intel Corporation. > >> + > >> +# Move the current shell process to the specified cgroup > >> +# Arguments: > >> +# $1 - The cgroup controller name, e.g., misc, memory. > >> +# $2 - The path of the cgroup, > >> +# relative to /sys/fs/cgroup for cgroup v2, > >> +# relative to /sys/fs/cgroup/$1 for v1. > >> +move_to_cgroup() { > >> + controllers=3D"$1" > >> + path=3D"$2" > >> + > >> + # Check if cgroup v2 is in use > >> + if [ ! -d "/sys/fs/cgroup/misc" ]; then > >> + # Cgroup v2 logic > >> + cgroup_full_path=3D"/sys/fs/cgroup/${path}" > >> + echo $$ > "${cgroup_full_path}/cgroup.procs" > >> + else > >> + # Cgroup v1 logic > >> + OLD_IFS=3D"$IFS" > >> + IFS=3D',' > >> + for controller in $controllers; do > >> + cgroup_full_path=3D"/sys/fs/cgroup/${controller}/${path}" > >> + echo $$ > "${cgroup_full_path}/tasks" > >> + done > >> + IFS=3D"$OLD_IFS" > >> + fi > > > > I think that if you could point me to git v10 and all this I could > > then quite easily create test image and see what I get from that. > > > > I will code review the whole thing but this is definitely good > > enough to start testing this series properly! Thanks for the > > effort with this. The payback from this comes after the feature > > is mainline. We have now sort of reference of the usage patterns > > and less layers when we need to debug any possible (likely) bugs > > in the future. > > > > This is definitely to the right direction. I'm just wondering do > > we want to support v1 cgroups or would it make sense support only > > v2? > > BR, Jarkko > > > I can drop v1. I think most distro now support v2. > Created this branch to host these changes so far: =20 > https://github.com/haitaohuang/linux/tree/sgx_cg_upstream_v10_plus Thanks!=20 I'll point my build to that, make a test image and report the results. BR, Jarkko