Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp4266782rba; Tue, 2 Apr 2024 11:48:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJSHOqGPlgr9q0XB8fwZWTQw68Q4bKpr7wAUfs2IjifuAyWznsLEIPd4Qct/z6yQ+DdGjWxDDXxYnRziGLes1McMCy347RAbNLkTaCOQ== X-Google-Smtp-Source: AGHT+IHL1F+Hp5YSieLGBTdFaQiNm3zerJyNm/hATTIQzUadjrkk5z/AzUCRUmMDWYfhcZPqxH87 X-Received: by 2002:a05:6871:438e:b0:22a:5092:ecc6 with SMTP id lv14-20020a056871438e00b0022a5092ecc6mr16407696oab.45.1712083733990; Tue, 02 Apr 2024 11:48:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712083733; cv=pass; d=google.com; s=arc-20160816; b=L4Fnxq/oigGxG+AWGFpAjQmDmlNkvgHftg9lsQYtTAEGAKhw0BcoM0rbC1Sz5/5ZGV EaqnHurLYYvFUtq8XZTycE2VcUBzTiV6CBWuq8dpCbEr6yoQeD3m8uwUNPISCSjHYZLh SE6OYAyrb8+Gx3t4iNQ7NdlsSxnoi8X2ffhXXwqqn39l8RyT5d5wJjnbAFx9CuUlotW9 IC44yRVK2/nb1t+aFM1UuWq00wXtaYOQJaKnhqYed6GxYGGKdzpl4IjSjD092popwQs+ Sxhuqywo48/hfHUJw7Z76ok6KYg/1B/8lfq+Be+em/scWu6PgOy3CMB0zxdWYD+JTI/x ViRg== 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=DK4Yxspm191GnxwEx8g30bBHV++rgqq/hNgOVCxxz/U=; fh=WUU5hqD/rTrK0E8O/N1MxHdsWAsTsHbrbPMMiUSj/NU=; b=fTYrqC/aBiO/kQG3h/CJn7R8dWspH+Wud4tFl5KNtrKXAwwHTNn3yn/V0I5pZ388H4 IL/9wHHFwAF7xHJ4rQLWqzH/mnN4n3quTAXGDPYHPbbdKMyy04Q14wvy0ryb7ZriIfen k3nLxr3UHzj8Mzw5gTwssH4BmS8Y34p58Fe2sewFM/gQFBTbQR92mPbRVvJR9QXkAPQG +Q4FTqqxV0G4OwzX64HFvb3qroLGp8f4rt5e+29KednPeCNk0NlYlWdX5mDu0KqYNO5w LhnTJoXqFix+p2n4fIqdRr44lR5pHX6t/rkFD2x0U+q3f4XqkzZzAJLTWaBYGjVPDWyD 1d+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RpaWjP7B; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-128427-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128427-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. [139.178.88.99]) by mx.google.com with ESMTPS id bq9-20020a056a02044900b005dc41265c15si13378417pgb.658.2024.04.02.11.48.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 11:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128427-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=@intel.com header.s=Intel header.b=RpaWjP7B; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-128427-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128427-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 7D6A828A5C0 for ; Tue, 2 Apr 2024 17:31:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5164F15A4B0; Tue, 2 Apr 2024 17:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RpaWjP7B" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 3C5A2156F33; Tue, 2 Apr 2024 17:31:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712079103; cv=none; b=ls5CeWkt5HBSlZhFKLbdXeMqSQ71RzXzC9h13Zm7rfZmpZEidfNYocyfxamL1h9wIBzVl31VpMNeU1gVKZcVyjc5u9env/URyjdaV+PH9nqynIKYgvAC4BSeXMGrSEw6zriZt/5NILu0aAiqCmd+HsDhWOpRz6ENrFhEglQGVps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712079103; c=relaxed/simple; bh=R83jK+pei7GoedhpFDOHXlUw+k4/j/waYzwaI/yXZ9E=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=agkhksPXm37/p1zpFHaaL3USadRb7bAvbX0Xgf7VHbR0rJJqywB5L/2HHbMcslycuFOMNEqOIICgmGA12ooFi5/jz9ZU/yMy6+PRG6PVAHLm4NqdDZqi2Mxqoo54ztT79pOGT+gTj0o7kUbYBVkJsg/D4xeiMBKJZESmmg3JXjU= 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=RpaWjP7B; arc=none smtp.client-ip=192.198.163.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=1712079101; x=1743615101; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=R83jK+pei7GoedhpFDOHXlUw+k4/j/waYzwaI/yXZ9E=; b=RpaWjP7BJXfldfIvmMzKaNHnXxppENUoVnxarPX2JBdNt/kjvWtq8HVX e5Np3OG3otNxq8oxdP7cWGvyUBQybWjON4rMSKh9H22sfutEftmRizcih ZvL/v0yqFCm6DZDF/9tBE5Bes9ycU2c4YQpBNHcYnbl6x0lXLuG9PK1qm CPtuRYOequS0vkbTi8bOz7+2xcZaKnQERlDjJryla4dh8BWDbJ6bzyciP ItMd4C5rk28WFOLN9MRvNAd+3DMCRPJzYfynyA5wb14mnUxyAby5x2sxJ IlT0Oy3tABuzD3mtjxKsvSbzIiWkj4fBUTkTfnVfJSDYCaRL9OMSusxX2 Q==; X-CSE-ConnectionGUID: YulYhiNUQIaeTR9Lfm4WoQ== X-CSE-MsgGUID: WuqoNnMESJ++g6ykzZImig== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7135691" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7135691" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 10:31:39 -0700 X-CSE-ConnectionGUID: jBxWQHvCSzKolXJhjJjjyg== X-CSE-MsgGUID: ZXiH4Q3XRaGXu0t67r0oBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="18255509" Received: from hhuan26-mobl.amr.corp.intel.com ([10.92.17.168]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/AES256-SHA; 02 Apr 2024 10:31:37 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Jarkko Sakkinen" Cc: anakrish@microsoft.com, bp@alien8.de, cgroups@vger.kernel.org, chrisyan@microsoft.com, dave.hansen@linux.intel.com, hpa@zytor.com, kai.huang@intel.com, kristen@linux.intel.com, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, mikko.ylinen@linux.intel.com, mingo@redhat.com, mkoutny@suse.com, seanjc@google.com, sohil.mehta@intel.com, tglx@linutronix.de, tim.c.chen@linux.intel.com, tj@kernel.org, x86@kernel.org, yangjie@microsoft.com, zhanb@microsoft.com, zhiquan1.li@intel.com Subject: Re: [PATCH v2] selftests/sgx: Improve cgroup test scripts References: <20240402014254.27717-1-haitao.huang@linux.intel.com> Date: Tue, 02 Apr 2024 12:31:36 -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, 02 Apr 2024 02:43:25 -0500, Jarkko Sakkinen 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 >> 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="$1" >> + path="$2" >> + >> + # Check if cgroup v2 is in use >> + if [ ! -d "/sys/fs/cgroup/misc" ]; then >> + # Cgroup v2 logic >> + cgroup_full_path="/sys/fs/cgroup/${path}" >> + echo $$ > "${cgroup_full_path}/cgroup.procs" >> + else >> + # Cgroup v1 logic >> + OLD_IFS="$IFS" >> + IFS=',' >> + for controller in $controllers; do >> + cgroup_full_path="/sys/fs/cgroup/${controller}/${path}" >> + echo $$ > "${cgroup_full_path}/tasks" >> + done >> + IFS="$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: https://github.com/haitaohuang/linux/tree/sgx_cg_upstream_v10_plus Thanks Haitao