Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1903784lqz; Tue, 2 Apr 2024 00:43:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUrO9hXf0cklsvQxMQ856oTTcwMr7ml1Rqg8gwseZFeE+1wd2WjWL0uOk912SjSv/qTiRO2/F8sm8iAT7iZu0gDeASVlk7AQZiJdHkbdA== X-Google-Smtp-Source: AGHT+IEG4Po+6Bc7600sFBaBK2m7PilbhjLpmBwT2DeiMDK38w2U1m+jUGyy1yM95SSIMvulUztZ X-Received: by 2002:a17:906:1814:b0:a4e:20d4:1591 with SMTP id v20-20020a170906181400b00a4e20d41591mr6688605eje.65.1712043820970; Tue, 02 Apr 2024 00:43:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712043820; cv=pass; d=google.com; s=arc-20160816; b=sYrLOnjeyMscW4eIjB1rcUS0Bn62zE+40alSMoFVNt4ptZddHYduu9ogU6yBLJIRyt DDLVK8eFggN/rL+kG/lZatzpGlhgPXBFVcBJSIRkDsytUNnceqtiFJGFvyXFVlGDKr56 u2Ww/wCfzqhWUP9iOqGPkgkVIYt+c5CKG760heqxyCHympSFvBW4Wp1UEriiC28WOBku AphSWOrfdP+aTxz9beKNHDcYXAQ9zx7noWoYuvGhZDrkJ4WtCRR43LMLrRd9QLuoTRbM IV4jVP72JzYFEC9i27XSzzTDNJ5NyaNfkVD22IkSwFPJbGq6F3tVx5K9SwCDbgVAjiTX AhaA== 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=2ukJiVh90qXEdYqjmRLfHbahzw5h2C5HNuMnunPaBg4=; fh=Svf3HfLV1E01UW3PO6Vi4CbeABeNA/NlRWKcmiNGP+M=; b=S5YtvMOT3eYKH9FNkw3Pe/HOJA/zlWHB+AUaj7+dS9ClaeVxkktFWet0PfyGZ32fKF M0LziW+raxs3Uj06T6ot2qr8Nv77ahDGTycgHj/zejS8dmITuzoiAo85STFJ/I0OoXvi kNe9bkxbyMNw4Bn1nWat7ezqOR8TrvbFAPKkvpXgnsan1CTSfpdk5ztzHfGKs9Tp4NWL c10eCJJNPeGB7Z+VLbGml3M+oe/mZoUfmFsHGc/XlvoyrXCh7Zr2K0v3hE466v9yHTNd ejWivEWJ/6k7QhKK4XeLrfUFgOKHpygK3TRsSzFCAkUi1qpCISvQZVEg2JPpoK6OWO8X QZoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNMMpQJi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127514-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z6-20020a1709063ac600b00a4ac16a784dsi5484570ejd.875.2024.04.02.00.43.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 00:43:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNMMpQJi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127514-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B1FD91F22683 for ; Tue, 2 Apr 2024 07:43:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 915FA3C699; Tue, 2 Apr 2024 07:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rNMMpQJi" 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 B000432C8B; Tue, 2 Apr 2024 07:43:32 +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=1712043812; cv=none; b=Nz13lVrFoCQNjDqXZNywdp6vDkVOPJz4hPp2V8yQmd4HmCqOUMWBxUmhbiVsBPymK21THzGh09jS6yPmhwXZkcnTlz+o5JZNq9NaDl9m9KdR2n8widF7jZSXwNJAOq8ImZRiSsUROJgQaJLmMwnQDERWf6oPgrwq6JvICT3aalw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712043812; c=relaxed/simple; bh=lOeUlS13nUasibcKAc+APQJ2GhDUpD5w9apCgLzBdJE=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=hMUxfn3yIFCN8LB1lem57NR7B3xHKbHZq6d167b3Atb9zi3m1IaLIkVZL7phtx9v2MKlRrRQSzmGuxDb5qrnVY6sX1UqHQn17Vb13WBbJ7t8amimsgvjYbzyPkp1Q+wlVJegDmHP5EGedGbNdWAgRxjeBPBbDQdF5F/qEEamWmk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rNMMpQJi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD2DFC433C7; Tue, 2 Apr 2024 07:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712043812; bh=lOeUlS13nUasibcKAc+APQJ2GhDUpD5w9apCgLzBdJE=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=rNMMpQJi+z+zXGyHrgy/DaCtRevEEQ2tWUaeN8zXTqLSVU39HoUSZ+2WR1yJCDzUW DCJjUe6N6V+1DAlLXPtlQ5ZHQbWc8ZdmJjOjW4ZtIqFqI1QhOx9tT0eH/478GSmmju hnl7rpHkzPa+GYy9qktz7b9hScg9TGVHIHsFc0Bnd3yarZf6p2X+Gf7WCmeR5MNeSX mop2J/pam1R2GlPb6+5DbUXYdqb6Sgsy5NT6AYUr92tPb+wzghIA2/n5ieiUm28lDw 91DOnwCWeBfJ/kdIWnQPR7WfeUpUEbq1sR1Ga6r4kCY7dsO2rlGYxaJ/T8PvgK/bNY UWsTtxzmgfyOA== 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: Tue, 02 Apr 2024 10:43:25 +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: <20240402014254.27717-1-haitao.huang@linux.intel.com> 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 b/tools/testing/se= lftests/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? =20 BR, Jarkko