ftests/013: Refactor code to match outputs with same line
Refactor the code to match controller(s) output, with expected
controller(s) output, where more than one items in the expected output
list matches number of lines. Without this patch, the output is matched
only against the first item matching the line count in the expected
output.
-----------------------------------------------------------------
Test Results:
Run Date: Jun 24 11:17:11
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------
setup 0.00
013-cgget-multiple_g_flags.py 0.05
teardown 0.00
--------------------------------------------
Total Run Time 0.05
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/010: Refactor code to match outputs with same line
Refactor the code to match controller(s) output, with expected
controller(s) output, where more than one items in the expected output
list matches number of lines. Without this patch, the output is matched
only against the first item matching the line count in the expected
output.
-----------------------------------------------------------------
Test Results:
Run Date: Jun 23 10:58:49
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------------
setup 0.00
010-cgget-g_flag_controller_and_cgroup.py 0.03
teardown 0.00
--------------------------------------------------------
Total Run Time 0.03
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/009: Refactor code to match outputs with same line
Refactor the code to match controller(s) output, with expected
controller(s) output, where more than one items in the expected output
list matches number of lines. Without this patch, the output is matched
only against the first item matching the line count in the expected
output.
-----------------------------------------------------------------
Test Results:
Run Date: Jun 22 10:18:38
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------
setup 0.00
009-cgget-g_flag_controller_only.py 0.04
teardown 0.00
--------------------------------------------------
Total Run Time 0.04
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/utils: Add helper to check if output matches
Add a helper to check if the output from the controller(s), matches the
expected controller(s) output. It returns True/False and None in case
of matching output, a line that doesn't match in differing output.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 17 Jul 2024 19:06:49 +0000 (13:06 -0600)]
ftests: Add more smarts when creating a container
If lxc returns 'Instance is busy running a "create" operation', the
container was successfully created but it's not yet fully running. Call
this a success as future operations will succeed once the container has
fully started.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests: add test to exercise cgxset recursive set option
Add a test to recursive set settings of the controller(s) in a cgroup
and its descendants using cgxset '-R' flag.
-----------------------------------------------------------------
Test Results:
Run Date: Jul 03 09:03:39
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
-------------------------------------------
setup 0.00
090-cgxset-recursive_flag.py 0.15
teardown 0.00
-------------------------------------------
Total Run Time 0.15
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tools/cgxset: add support for cgroup.subtree_control
The cgroup.subtree_control settings are special, in comparison to other
controller settings. It can both enable and disable the controllers in
the single argument, depending on the argument the cgroup hierarchy walk
is either pre-order or post-order.
Kamalesh Babulal [Sun, 30 Jun 2024 02:21:02 +0000 (07:51 +0530)]
tools/cgxset: add -R option to recursively set variables
Add -R option to recursively set variable(s) passed to cgroups under
<cgroup_path>. This will help users to set a controller setting for
all the cgroups under a cgroup hierarchy, instead of passing the
cgroups multiple times on the command line.
Move the cgroup controller value setting logic to a helper function,
cgroup_set_cgroup_values() and also introduce program_name variable, to
be used instead of argv[0], when printing the info()/err() messages.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Vasil Kolev [Fri, 17 May 2024 10:58:38 +0000 (13:58 +0300)]
tools/tools-common.c: handle DT_UNKNOWN from readdir()
It's possible that readdir() would return DT_UNKNOWN in d_type for some
filesystems (observed on RHEL 8 with XFS and documented in readdir(3)),
thus the need to do an explicit stat() for such cases.
Kamalesh Babulal [Tue, 18 Jun 2024 06:56:28 +0000 (12:26 +0530)]
ftests/071: Introduce delay before killing cgroup
Fix the following issue:
071-sudo-set_default_systemd_cgroup.py - cgroup_delete_cgroup failed: 50016
Some older version of Kernel/Python combination, requires few jiffies to
sync the cgroup.procs list of process. Fix it by introducing 0.5 second
delay, before removing the cgroup.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 12 Jun 2024 05:46:55 +0000 (11:16 +0530)]
ftests/consts: Add cpu controller throttled_usec (v2)
Add cpu controller (v2) stat output throttled_usec, introduced by 677ea015f231 ("sched: add throttled time stat for throttled children")
-----------------------------------------------------------------
Test Results:
Run Date: Jun 12 05:46:40
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------
setup 0.00
009-cgget-g_flag_controller_only.py 0.09
teardown 0.00
--------------------------------------------------
Total Run Time 0.09
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 11 Jun 2024 06:05:38 +0000 (11:35 +0530)]
ftests/consts: Add cpu controller throttled_usec (v1)
Add cpu controller (v1) stat output throttled_usec, introduced by 677ea015f231 ("sched: add throttled time stat for throttled children")
-----------------------------------------------------------------
Test Results:
Run Date: Jun 11 05:39:08
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------
setup 0.00
009-cgget-g_flag_controller_only.py 0.07
teardown 0.00
--------------------------------------------------
Total Run Time 0.07
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Upstream Linux Kernel commit 81d3a5be05d3 ("cgroup: add
cgroup_favordynmods= command-line option") introduced
CONFIG_CGROUP_FAVOR_DYNMODS, that would append favordynmods to the mount
options on cgroup v1. This patch strips that option.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Add Python version >= 3.6, as minimum required for executing ftests.
It's required for multi-process/multi-threaded test cases to execute
without time outs.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Append newer kernels cpuset controller output to the list of expected
output(s).
-----------------------------------------------------------------
Test Results:
Run Date: Jun 07 15:28:39
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------
setup 0.00
005-cgsnapshot-basic_snapshot_v2.py 0.27
teardown 0.00
--------------------------------------------------
Total Run Time 0.27
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Use consts.EXPECTED_CPU_OUT_* lists, instead of local EXPECTED_OUT_*
lists. This removes maintaining of duplicate controller output lists.
-----------------------------------------------------------------
Test Results:
Run Date: Jun 04 15:25:17
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------
setup 0.00
013-cgget-multiple_g_flags.py 0.06
teardown 0.00
--------------------------------------------
Total Run Time 0.06
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Use consts.EXPECTED_CPU_OUT_* lists, instead of local EXPECTED_OUT_*
lists. This removes maintaining of duplicate controller output lists.
-----------------------------------------------------------------
Test Results:
Run Date: Jun 03 15:22:15
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------------
setup 0.00
010-cgget-g_flag_controller_and_cgroup.py 0.04
teardown 0.00
--------------------------------------------------------
Total Run Time 0.04
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Use consts.EXPECTED_CPU_OUT_* lists, instead of local EXPECTED_OUT_*
lists. This removes maintaining of duplicate controller output lists.
-----------------------------------------------------------------
Test Results:
Run Date: Jun 02 15:20:50
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------
setup 0.00
009-cgget-g_flag_controller_only.py 0.04
teardown 0.00
--------------------------------------------------
Total Run Time 0.04
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Add cpu and pid controllers expected output lists to consts. It helps
in maintaining the controller output(s) list as a single list, lowering
the maintenance overhead for every new Kernels and also removes the
duplication across the test cases.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 28 May 2024 09:50:35 +0000 (15:20 +0530)]
ftests/061: Fix the expected line in cpu controller
Cgroup cpu controller output might be less than 10 lines in older
Kernel version <= 5.4, fix it by adjusting the expected outline count
after reading the current kernel's version.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Sat, 25 May 2024 09:30:05 +0000 (15:00 +0530)]
ftests/cgroup: Add function to return kernel version
Add function to return the Major, Minor and Patch level of the current
booted kernel.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Moved function from CgroupVersion class to utils.py
Kamalesh Babulal [Sun, 26 May 2024 06:42:03 +0000 (12:12 +0530)]
ftests/060: Add new systemd error message
systemd >= 252 has changed the error message on creating duplicate
transient units, upstream commit 1f83244641f1 ("manager: allow transient
units to have drop-ins"). Adopt the newer systemd error message to avoid
expected failure.
-----------------------------------------------------------------
Test Results:
Run Date: May 26 07:03:01
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
-------------------------------------------------
setup 0.00
060-sudo-cgconfigparser-systemd.py 3.62
teardown 0.00
-------------------------------------------------
Total Run Time 3.62
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
fix: cgroupv2_subtree_control_recursive(): test before writing
cgroupv2_subtree_control_recursive() writes to subtree_control
files in the cgroup tree, starting at the root cgroup. As the
root cgroup is managed by SystemD, its control files belong to the
root user.
This new check ensures that we only attempt to write to subtree_control
if the desired controller is not already active (e.g., because we're
using SystemD Delegation mechanisms), thus better enabling cgroup
manipulations for non-root users.
With upstream commit 7476a636d3100 ("cgroup/cpuset: Show invalid
partition reason string"), doesn't return error but needs to be re-read
again. This oddity is seen in kernel >= 6.5, fix it by introducing some
checks for cpuset_exclusive oddity.
-----------------------------------------------------------------
Test Results:
Run Date: Apr 12 10:20:07
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------
setup 0.00
038-cgxget-cpuset_settings.py 24.75
teardown 0.00
--------------------------------------------
Total Run Time 24.75
Fixes: https://github.com/libcgroup/libcgroup/issues/423 Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Starting Linux Kernel version 6.1, the pids controller added an new
interface file pids.peak. It was introduced by upstream commit 5251c6c436ed ("cgroup: add pids.peak interface for pids controller").
Append a new expected output with the interface 'pids.peak' to cgroup v1
and v2 valid output.
-----------------------------------------------------------------
Test Results:
Run Date: Apr 04 10:11:31
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------
setup 0.00
013-cgget-multiple_g_flags.py 0.12
teardown 0.00
--------------------------------------------
Total Run Time 0.12
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Starting Linux Kernel version 6.0, the cpu controller cpu.stat (v2)
additionally displays force_idle statistics. It was introduced by
upstream commit 1fcf54deb767 ("sched/core: add forced idle accounting
for cgroups"). Append a new expected output with the field
'core_sched.force_idle_usec' to cgroup v2 valid output.
-----------------------------------------------------------------
Test Results:
Run Date: Apr 03 15:49:31
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------
setup 0.00
013-cgget-multiple_g_flags.py 0.12
teardown 0.00
--------------------------------------------
Total Run Time 0.12
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Fri, 29 Mar 2024 07:18:59 +0000 (12:48 +0530)]
ftests/010: add cpu controller format (v2)
Starting Linux Kernel version 6.0, the cpu controller cpu.stat (v2)
additionally displays force_idle statistics. It was introduced by
upstream commit 1fcf54deb767 ("sched/core: add forced idle accounting
for cgroups"). Append a new expected output with the field
'core_sched.force_idle_usec' to cgroup v2 valid output.
-----------------------------------------------------------------
Test Results:
Run Date: Apr 03 15:48:51
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------------
setup 0.00
010-cgget-g_flag_controller_and_cgroup.py 0.09
teardown 0.00
--------------------------------------------------------
Total Run Time 0.09
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 28 Mar 2024 06:07:09 +0000 (11:37 +0530)]
ftests/009: add cpu controller format (v2)
Starting Linux Kernel version 6.0, the cpu controller cpu.stat (v2)
additionally displays force_idle statistics. It was introduced by
upstream commit 1fcf54deb767 ("sched/core: add forced idle accounting
for cgroups"). Append a new expected output with the field
'core_sched.force_idle_usec' to cgroup v2 valid output.
-----------------------------------------------------------------
Test Results:
Run Date: Apr 03 15:36:32
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
--------------------------------------------------
setup 0.00
009-cgget-g_flag_controller_only.py 0.10
teardown 0.00
--------------------------------------------------
Total Run Time 0.10
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Adriaan Schmidt [Tue, 27 Feb 2024 12:37:17 +0000 (13:37 +0100)]
feat: add cgroup_get_threads()
In the same way `cgroup_get_procs()` reads the cgroup.procs
file of a cgroup, the new function reads cgroup.threads, which
is useful to interact with threaded cgroups.
Kamalesh Babulal [Wed, 13 Mar 2024 10:04:25 +0000 (10:04 +0000)]
ftests/092: add test to attach threads to cgroup (v1)
Add test to attach/move all thread of a tid to cgroup using
cgroup_attach_thread_tid() in cgroup v1.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 13 09:52:58
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------
setup 0.00
092-sudo-cgroup_attach_thread_tid.py 0.09
teardown 0.00
---------------------------------------------------
Total Run Time 0.09
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Mon, 11 Mar 2024 03:37:19 +0000 (09:07 +0530)]
src/python: add attach_threads option to attach()
Add support to move all threads by writing a tid into cgroups
cgroup.procs for the cgroup v1 controller, when attach_threads option in
the attach() is set, by default its false. When set, it calls
cgroup_attach_thread_tid().
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Add helper cgroup_v1_build_cgroup_procs_path(), that constructs the path
to write tid into cgroup.procs, that will allow to move all of the tasks
sharing the same pid (thread leader). This helper, will be called by
cgroup_attach_task_tid() based on the move_threads function argument.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Introduce a new helper cgroup_attach_task_tid(), which will be used to
move threads into a cgroup for legacy/hybrid controllers running setup
in cgroup v1 mode. The core of the helper is craved out of
cgroup_attach_task_pid(), now both cgroup_attach_task_pid() and
cgroup_attach_task() calls cgroup_attach_task_tid() in turn.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Add support for cgroup hybrid mode with controllers in cgroup v2.
-----------------------------------------------------------------
Test Results:
Run Date: Nov 01 10:40:32
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
-----------------------------------------------------------
setup 0.00
081-pybindings-cgrp_get_curr_ctrl_path-v1.py 2.09
teardown 0.00
-----------------------------------------------------------
Total Run Time 2.09
Suggested-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/089: enable controller for hybrid parent cgroup
Enable the cpuset controller for the hybrid parent cgroup, in case of
the cgroup hybrid setup mode with controller enabled.
-----------------------------------------------------------------
Test Results:
Run Date: Nov 01 12:50:20
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
------------------------------------------
setup 0.00
089-cgset-recursive_flag.py 0.23
teardown 0.00
------------------------------------------
Total Run Time 0.23
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 6 Dec 2023 15:37:44 +0000 (15:37 +0000)]
ftests/systemd: add method to check if systemd support
Add a method to check if libcgroup is compiled with --enable-systemd
support. The newly introduced is_systemd_enabled(), calls systemd C
function is_systemd_enabled(), that return true if configured with
--enable-systemd, false otherwise.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 7 Dec 2023 04:19:07 +0000 (04:19 +0000)]
python: compile systemd support by default
Compile systemd support file by default, there are two versions of
systemd functions available now, those get called based on the
--enable-systemd configuration, hence remove the #ifdef WITH_SYSTEMD
guards from bindings.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Mon, 27 Nov 2023 14:37:33 +0000 (20:07 +0530)]
include/Makefile: install systemd.h by default
Install systemd.h header file by default, as we have stub and defined
versions of the systemd functions for both non-systemd and systemd
enabled configurations. This will help packagers to ship package
without systemd support (--enable-systemd=no).
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Sat, 25 Nov 2023 14:32:34 +0000 (20:02 +0530)]
src/Makefile: compile systemd support by default
Compile systemd support file by default, now we have stub and defined
versions of the systemd functions for both non-systemd and systemd
enabled configurations. Pass linker flag WITH_SYSTEMD only when
--enable-systemd is set, that will call the defined function, otherwise
call the stub functions.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>