From: Peter Newman <peternewman@google.com>
To: babu.moger@amd.com
Cc: bp@alien8.de, dave.hansen@linux.intel.com, eranian@google.com,
fenghua.yu@intel.com, gupasani@google.com, hpa@zytor.com,
james.morse@arm.com, linux-kernel@vger.kernel.org,
mingo@redhat.com, peternewman@google.com,
reinette.chatre@intel.com, skodak@google.com, tglx@linutronix.de,
tony.luck@intel.com, x86@kernel.org
Subject: Re: [PATCH v5 3/3] Documentation/x86: Documentation for MON group move feature
Date: Fri, 31 Mar 2023 10:12:09 +0200 [thread overview]
Message-ID: <20230331081209.3170293-1-peternewman@google.com> (raw)
In-Reply-To: <f826dd28-0213-b7ea-494c-8c7a0ff348ce@amd.com>
Hi Babu,
On Thu, Mar 30, 2023 at 7:33 PM Moger, Babu <babu.moger@amd.com> wrote:
> On 3/30/23 08:55, Peter Newman wrote:
> > Describe new support for moving MON groups to a new parent CTRL_MON
> > group and its restrictions.
>
> Sorry for coming in late here. I am planning to test these patches. It
> would be helpful to give a simple example to test this feature.
Do you mean inline in the documentation?
For now, you can also try the patch below. These are the testcases I
used.
I'm planning to convert many of our internal, shell script-based test
cases into kernel selftests so I can try to upstream them.
Thanks!
-Peter
---8<-------
From f6d215e90db3c416bd39889b9fa1143d798245e0 Mon Sep 17 00:00:00 2001
From: Peter Newman <peternewman@google.com>
Date: Tue, 7 Mar 2023 11:57:03 +0100
Subject: [PATCH] selftests/resctrl: Test for MON group renaming
Signed-off-by: Peter Newman <peternewman@google.com>
---
tools/testing/selftests/resctrl/Makefile | 2 +
.../selftests/resctrl/test_mongrp_move.sh | 120 ++++++++++++++++++
2 files changed, 122 insertions(+)
create mode 100755 tools/testing/selftests/resctrl/test_mongrp_move.sh
diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile
index 73d53257df42..0b696e7cf19b 100644
--- a/tools/testing/selftests/resctrl/Makefile
+++ b/tools/testing/selftests/resctrl/Makefile
@@ -5,6 +5,8 @@ CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := resctrl_tests
+TEST_PROGS := test_mongrp_move.sh
+
include ../lib.mk
$(OUTPUT)/resctrl_tests: $(wildcard *.c)
diff --git a/tools/testing/selftests/resctrl/test_mongrp_move.sh b/tools/testing/selftests/resctrl/test_mongrp_move.sh
new file mode 100755
index 000000000000..6d9bfc4e0c8d
--- /dev/null
+++ b/tools/testing/selftests/resctrl/test_mongrp_move.sh
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+set -e
+
+rc=0
+
+cleanup()
+{
+ rmdir _test_*
+ rmdir mon_groups/_test_*
+}
+
+skip_all()
+{
+ echo Bail out! $1
+
+ cleanup
+
+ # SKIP code is 4.
+ exit 4
+}
+
+expect_success()
+{
+ if [ "$1" -eq 0 ]; then
+ echo ok $2
+ else
+ echo not ok $2
+ rc=1
+ fi
+}
+
+expect_fail()
+{
+ if [ "$1" -eq 0 ]; then
+ echo not ok $2
+ rc=1
+ else
+ echo ok $2
+ fi
+}
+
+if [ "$(id -u)" != 0 ]; then
+ skip_all "must be run as root"
+fi
+
+if [ ! -d /sys/fs/resctrl/info ]; then
+ mount -t resctrl resctrl /sys/fs/resctrl || skip_all "no resctrlfs"
+fi
+
+cd /sys/fs/resctrl
+
+if [ ! -f info/L3_MON/mon_features ]; then
+ skip_all "no monitoring support"
+fi
+
+if [ ! -f schemata ]; then
+ skip_all "no allocation support"
+fi
+
+echo "1..11"
+
+if [ -d _test_c1 ] || [ -d _test_c2 ] || [ -d mon_groups/_test_m1 ]; then
+ skip_all "test directories already exist"
+fi
+
+mkdir _test_c1
+mkdir _test_c2
+mkdir _test_c3
+
+mkdir mon_groups/_test_m1
+echo 1 > mon_groups/_test_m1/cpus
+
+mkdir _test_c1/mon_groups/_test_m1
+echo $$ > _test_c1/tasks
+echo $$ > _test_c1/mon_groups/_test_m1/tasks
+
+if mv _test_c1/mon_groups/_test_m1 _test_c2/mon_groups; then
+ echo "ok 1 # MON group move to new parent succeeded"
+else
+ echo "1..0 # skip because MON group move to new parent not supported"
+ cleanup
+ exit 4
+fi
+
+set +e
+
+grep -q $$ _test_c2/tasks
+expect_success $? "2 # PID in new CTRL_MON group"
+
+grep -q $$ _test_c2/mon_groups/_test_m1/tasks
+expect_success $? "3 # PID remains in MON group after move"
+
+grep -q $$ _test_c1/tasks
+expect_fail $? "4 # PID no longer in previous CTRL_MON group"
+
+mv _test_c2/mon_groups/_test_m1/cpus mon_groups
+expect_fail $? "5 # moving files not allowed"
+
+mv _test_c2/mon_groups/_test_m1 _test_c2/mon_groups/_test_m2
+expect_success $? "6 # simple MON directory rename"
+
+mv _test_c2/mon_groups/_test_m2 info
+expect_fail $? "7 # move to info not allowed"
+
+mv _test_c2/mon_groups/_test_m2 _test_c2/mon_groups/mon_groups
+expect_fail $? "8 # rename to mon_groups not allowed"
+
+mv mon_groups/_test_m1 _test_c1/mon_groups
+expect_fail $? "9 # cannot move groups monitoring CPUs"
+
+mv mon_groups/_test_m1 mon_groups/_test_m2
+expect_success $? "10 # groups monitoring CPUs can be renamed"
+
+mv mon_groups/_test_m2/mon_data _test_c1/mon_groups
+expect_fail $? "11 # cannot move subdirectories of a mon_group"
+
+cleanup
+
+exit $rc
--
2.40.0.423.gd6c402a77b-goog
next prev parent reply other threads:[~2023-03-31 8:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 13:55 [PATCH v5 0/3] Subject: x86/resctrl: Implement rename to help move containers' tasks Peter Newman
2023-03-30 13:55 ` [PATCH v5 1/3] x86/resctrl: Factor rdtgroup lock for multi-file ops Peter Newman
2023-03-30 13:55 ` [PATCH v5 2/3] x86/resctrl: Implement rename op for mon groups Peter Newman
2023-04-18 21:52 ` Reinette Chatre
2023-04-19 9:38 ` Peter Newman
2023-04-19 16:11 ` Reinette Chatre
2023-03-30 13:55 ` [PATCH v5 3/3] Documentation/x86: Documentation for MON group move feature Peter Newman
2023-03-30 17:33 ` Moger, Babu
2023-03-31 8:12 ` Peter Newman [this message]
2023-03-31 20:51 ` Moger, Babu
2023-04-18 21:53 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230331081209.3170293-1-peternewman@google.com \
--to=peternewman@google.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=gupasani@google.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=skodak@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®