From: Punit Agrawal <punit.agrawal@arm.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 12/13] hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug
Date: Tue, 14 Nov 2017 15:59:28 +0000 [thread overview]
Message-ID: <20171114155929.24237-13-punit.agrawal@arm.com> (raw)
In-Reply-To: <20171114155929.24237-1-punit.agrawal@arm.com>
From: James Morse <james.morse@arm.com>
When LTP is started over ssh, systemd will use cgroups to group all the
tasks started by this session. LTPs cpuhotplug04 will remove all but one
CPU as part of its test.
In the kernel cpuset_hotplug_workfn() is documented thus: "Non-root
cpusets are only affected by offlining". This means cpuhotplug04 will
cause all future tasks to only have one available CPU. cpuhotplug04
effectively looses those CPUs for all users until the next reboot.
This problem has been reported, and was fixed for the unified hierarchy
by be4c9dd7aee5 ("cpuset: enable onlined cpu/node in effective
masks"). Since v3.17, this behaviour could be selected by passing '-o
__DEVEL__sane_behavior' to the cgroup mount. Linux v4.4 grouped all the
ABI breakage together into a new filesystem: cgroup2, removing the
__DEVEL__sane_behavior flag.
With v226 Systemd can be forced to use cgroup2 by passing
'systemd.unified_cgroup_hierarchy=1' on the kernel command line.
Ubuntu 15.04 ships with systemd v219.
LTP tests that online CPUs must test for the legacy cgroup hierarchy and
update the cpusets for all users/sessions. Add this code the
cpu_online() helper.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
.../cpu_hotplug/include/cpuhotplug_hotplug.sh | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
index 9f856e554..35ec7c86b 100644
--- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
@@ -58,6 +58,39 @@ set_affinity()
return $?
}
+# repopulate_cpusets()
+#
+# If the legacy cgroup hierarchy is in use, and cpuset is mounted, copy
+# the permitted cpus from the root group, which always has all available
+# cpus and memory, into the other hierarchy nodes. This prevents hotplug
+# tests from losing CPUs, and affecting the results of later tests.
+#
+CPUSET="/sys/fs/cgroup/cpuset"
+repopulate_cpusets()
+{
+ # Only if we have cpusets
+ if [ ! -d ${CPUSET} ] ; then
+ return;
+ fi
+
+ # And then only legacy cpusets
+ if grep --quiet "/sys/fs/cgroup/cpuset[ ]*cgroup2" /proc/mounts ; then
+ return;
+ fi
+
+ # Copy root cpus into system and user slices
+ cat ${CPUSET}/cpuset.cpus > ${CPUSET}/system.slice/cpuset.cpus
+ cat ${CPUSET}/cpuset.cpus > ${CPUSET}/user.slice/cpuset.cpus
+
+ # Fix each session of each user
+ for TUSER in ${CPUSET}/user.slice/user-*.slice ; do
+ cat ${CPUSET}/cpuset.cpus > ${TUSER}/cpuset.cpus
+ for SESSION in ${TUSER}/session-*.scope; do
+ cat ${CPUSET}/cpuset.cpus > ${SESSION}/cpuset.cpus
+ done
+ done
+}
+
# online_cpu(CPU)
#
# Onlines the given CPU. Returns a true value if it was able
@@ -77,6 +110,9 @@ online_cpu()
$TIME echo 1 > /sys/devices/system/cpu/cpu${CPU}/online
RC=$?
+
+ repopulate_cpusets
+
report_timing "Online cpu ${CPU}"
return $RC
}
--
2.14.2
next prev parent reply other threads:[~2017-11-14 15:59 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 15:59 [LTP] [PATCH v2 00/13] Collection of fixes Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 01/13] Move check_hugepage() helper to mem/lib Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 02/13] thp: ensure THP/hugetlbfs is available Punit Agrawal
2017-11-27 16:20 ` Cyril Hrubis
2017-11-27 16:59 ` Punit Agrawal
2017-11-29 12:44 ` Cyril Hrubis
2017-11-29 13:29 ` Punit Agrawal
2017-11-29 14:34 ` Cyril Hrubis
2017-11-14 15:59 ` [LTP] [PATCH v2 03/13] hugeshmctl01: Convert to LTP synchronisation primitives Punit Agrawal
2017-11-27 16:52 ` Cyril Hrubis
2017-11-27 17:34 ` Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 04/13] hugeshmctl01: Fix warning about signed/unsigned comparison Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 05/13] hugeshmctl02: Fix allocation size for odd number of hugepages Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 06/13] hugeshmget02: add missing SHM_HUGETLB flag on segment creation Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 07/13] sigwaitinfo01: fix race between sending and dequeueing RT signals Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 08/13] sigwaitinfo01: catch SEGV and report success for bad_address2 testcase Punit Agrawal
2017-11-29 10:29 ` Cyril Hrubis
2017-11-29 13:25 ` Punit Agrawal
2017-11-29 15:33 ` Cyril Hrubis
2017-11-14 15:59 ` [LTP] [PATCH v2 09/13] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE' Punit Agrawal
2017-11-29 13:20 ` Cyril Hrubis
2017-11-29 16:50 ` Punit Agrawal
2017-11-30 12:21 ` Cyril Hrubis
2017-11-30 12:56 ` Punit Agrawal
2017-11-30 13:17 ` Cyril Hrubis
2017-11-30 15:56 ` Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 10/13] getdtablesize01: Handle ENFILE errno Punit Agrawal
2017-11-30 13:12 ` Cyril Hrubis
2017-11-30 16:06 ` Punit Agrawal
2017-11-30 16:20 ` Cyril Hrubis
2017-11-30 16:41 ` Suzuki K Poulose
2017-12-01 13:38 ` Cyril Hrubis
2017-12-01 15:30 ` Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 11/13] perf_event_open: Handle absence of PMU gracefully Punit Agrawal
2017-11-14 15:59 ` Punit Agrawal [this message]
2017-11-30 13:58 ` [LTP] [PATCH v2 12/13] hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug Cyril Hrubis
2017-12-01 16:00 ` Punit Agrawal
2017-11-14 15:59 ` [LTP] [PATCH v2 13/13] hotplug/cpu_hotplug: Remove bashism disown from kill_pid() Punit Agrawal
2017-11-21 16:15 ` [LTP] [PATCH v2 00/13] Collection of fixes Punit Agrawal
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=20171114155929.24237-13-punit.agrawal@arm.com \
--to=punit.agrawal@arm.com \
--cc=ltp@lists.linux.it \
/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