]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
11 months agosrc/daemon/cgrulesengd: match naming with upstream Linux
Kamalesh Babulal [Fri, 11 Oct 2024 00:51:26 +0000 (06:21 +0530)] 
src/daemon/cgrulesengd: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
bringing it closer to the Linux kernel cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agosrc: match naming with upstream Linux
Kamalesh Babulal [Thu, 10 Oct 2024 05:34:16 +0000 (11:04 +0530)] 
src: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under src/*.c bringing it closer to the Linux kernel

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agosrc/libcgroup-internal: match naming with upstream Linux
Kamalesh Babulal [Wed, 9 Oct 2024 07:08:42 +0000 (12:38 +0530)] 
src/libcgroup-internal: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
bringing it closer to the Linux kernel cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/cgroup: Fix typo in CgroupMount::__init__
Kamalesh Babulal [Wed, 16 Oct 2024 09:11:32 +0000 (14:41 +0530)] 
ftests/cgroup: Fix typo in CgroupMount::__init__

Fix the typo of '==' (comparison) to '=' assignment in
CgroupMount::__init__.

Fixes: 52b196c2f4f3c ("ftests/cgroup: Add support for favordynmods")
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/ftests-wrapper.sh: Improve timeout comments
Kamalesh Babulal [Sat, 19 Oct 2024 09:10:12 +0000 (14:40 +0530)] 
ftests/ftests-wrapper.sh: Improve timeout comments

Fix the timeout minutes '5' -> '50' and improve the comment stating, we
would abort after timeout minutes.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoapi.c: fix memory leak on non-writable settings
Felix Moessbauer [Wed, 16 Oct 2024 13:30:29 +0000 (15:30 +0200)] 
api.c: fix memory leak on non-writable settings

When hitting the path st_mode check, we might already have allocated a
path. In this case, the continue re-enters the loop without freeing the
path:

 653 bytes in 8 blocks are definitely lost in loss record
    at 0x484582F: realloc (vg_replace_malloc.c:1437)
    by 0x49023E1: __vasprintf_internal (vasprintf.c:79)
    by 0x48D5BD5: asprintf (asprintf.c:31)
    by 0x4B41722: cgroup_set_values_recursive (api.c:2414)
    by 0x4B4688A: _cgroup_create_cgroup (api.c:2999)
    by 0x4B47067: cgroup_create_cgroup (api.c:3062)
    by 0x4B47067: cgroup_create_cgroup (api.c:3028)

Fixes: 0e50142a1fe0 ("api.c: Don't fail a recursive write if value isn't dirty")
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
11 months agocgrules: Add ignore_rt option
Kamalesh Babulal [Tue, 8 Oct 2024 13:25:00 +0000 (13:25 +0000)] 
cgrules: Add ignore_rt option

Introduce new ignore_rt option for cgrules, that would ignore rules
matching user:process, controller(s), destination cgroup with SCHED_RR
and SCHED_FF policies.

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>
11 months agoapi.c: constify cgroup_get_threads() arguments
Kamalesh Babulal [Wed, 2 Oct 2024 07:08:42 +0000 (12:38 +0530)] 
api.c: constify cgroup_get_threads() arguments

Constify the char* functional arguments of cgroup_get_threads(), these
parameters are not supposed to changed.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoapi.c: constify cgroup_get_procs() arguments
Kamalesh Babulal [Tue, 1 Oct 2024 06:47:12 +0000 (12:17 +0530)] 
api.c: constify cgroup_get_procs() arguments

Constify the char* functional arguments of cgroup_get_procs(), these
parameters are not supposed to changed.

Fixes: https://github.com/libcgroup/libcgroup/issues/445
Reported-by: Dan Dedrick <dan.dedrick@gmail.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agotools/cgset: Fix -R switch indentation in help menu
Kamalesh Babulal [Fri, 4 Oct 2024 07:08:51 +0000 (12:38 +0530)] 
tools/cgset: Fix -R switch indentation in help menu

Fix the indentation of '-R' switch description of cgset help menu.

Before:
-------
$ cgset --help
Usage: cgset [-r <name=value>] <cgroup_path> ...
   or: cgset --copy-from <source_cgroup_path> <cgroup_path> ...
Set the parameters of given cgroup(s)
  -r, --variable <name>                 Define parameter to set
  --copy-from <source_cgroup_path>      Control group whose parameters will be copied
  -b                                    Ignore default systemd delegate hierarchy
  -R                                      Recursively set variable(s) for cgroups under <cgroup_path>

After:
------
$ cgset --help
Usage: cgset [-r <name=value>] <cgroup_path> ...
   or: cgset --copy-from <source_cgroup_path> <cgroup_path> ...
Set the parameters of given cgroup(s)
  -r, --variable <name>                 Define parameter to set
  --copy-from <source_cgroup_path>      Control group whose parameters will be copied
  -b                                    Ignore default systemd delegate hierarchy
  -R                                    Recursively set variable(s) for cgroups under <cgroup_path>

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoapi.c: add support to build procs path for cgroup.thread
Kamalesh Babulal [Fri, 27 Sep 2024 06:45:09 +0000 (12:15 +0530)] 
api.c: add support to build procs path for cgroup.thread

In cgroup_build_tid_path(), add support for building path to write
tid into cgroup.thread instead of cgroup.procs, if the calling function
is cgroup_attach_thread_tid() or else build path to write into
cgroup.procs.

Fixes: https://github.com/libcgroup/libcgroup/issues/441
Reported-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoapi: Add is_tid parameter to cgroup_get_cg_type()
Kamalesh Babulal [Thu, 26 Sep 2024 10:45:09 +0000 (16:15 +0530)] 
api: Add is_tid parameter to cgroup_get_cg_type()

Add new parameter bool is_tid to cgroup_get_cg_type(), this parameter
gets set, when called from cgroup_attach_thread_tid() path. When set and
cgroup.type is 'domain threaded', it returns 'cgroup.threads' instead of
'cgroup.procs'.

Fixes: https://github.com/libcgroup/libcgroup/issues/441
Reported-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoapi.c: Rename cgroup_v1_build_procs_path()
Kamalesh Babulal [Wed, 25 Sep 2024 07:08:42 +0000 (12:38 +0530)] 
api.c: Rename cgroup_v1_build_procs_path()

Rename cgroup_v1_build_procs_path() to cgroup_build_tid_path(), this
function will be used to build a procs path on both cgroup v1/v2 to
which the tid/pid will be written based on the cgroup type. Change
the name to reflect the new functionality.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/030: teach parsing v6.12 memory isolation
Kamalesh Babulal [Sun, 29 Sep 2024 09:18:03 +0000 (14:48 +0530)] 
ftests/030: teach parsing v6.12 memory isolation

Starting v6.12 memory code is split into v1 and v2 code, where v1 code
is only compiled when CONFIG_MEMCG_V1 is set. Which defaults to
disabled, teach the test case to ignore such failure.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/030: teach parsing v6.12 cpuset isolation
Kamalesh Babulal [Sat, 28 Sep 2024 09:14:58 +0000 (14:44 +0530)] 
ftests/030: teach parsing v6.12 cpuset isolation

Starting v6.12 cpuset code is split into v1 and v2 code, where v1 code
is only compiled when CONFIG_CPUSET_V1 is set. Which defaults to
disabled, teach the test case to ignore such failure.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoworkflow/ci: Install flake8-quote under pylint job
Kamalesh Babulal [Wed, 14 Aug 2024 05:35:59 +0000 (11:05 +0530)] 
workflow/ci: Install flake8-quote under pylint job

In the Github workflow continuous integration::flake8-lint job, add
new checks for standardizing Python quotes usage. This will help
maintain the recommended quotes style in all new PR's.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agosamples/python/create_systemd_scope: Fix quote warnings
Kamalesh Babulal [Tue, 13 Aug 2024 06:31:14 +0000 (12:01 +0530)] 
samples/python/create_systemd_scope: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/cgroup: Fix quote warnings
Kamalesh Babulal [Mon, 12 Aug 2024 06:29:04 +0000 (11:59 +0530)] 
ftests/cgroup: Fix quote warnings

Fix "Q003 Change outer quotes to avoid escaping inner quotes" and
"Q000 Double quotes found but single quotes preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/consts: Fix quote warnings
Kamalesh Babulal [Sun, 11 Aug 2024 06:26:23 +0000 (11:56 +0530)] 
ftests/consts: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/092: Fix quote warning
Kamalesh Babulal [Sat, 10 Aug 2024 06:23:31 +0000 (11:53 +0530)] 
ftests/092: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/ftests: Fix quote warnings
Kamalesh Babulal [Fri, 9 Aug 2024 11:11:00 +0000 (16:41 +0530)] 
ftests/ftests: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
and "Q000 Double quotes found but single quotes preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/process: Fix quote warnings
Kamalesh Babulal [Thu, 8 Aug 2024 11:05:55 +0000 (16:35 +0530)] 
ftests/process: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/run: Fix quote warning
Kamalesh Babulal [Wed, 7 Aug 2024 11:03:24 +0000 (16:33 +0530)] 
ftests/run: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/systemd: Fix quote warnings
Kamalesh Babulal [Tue, 6 Aug 2024 11:01:04 +0000 (16:31 +0530)] 
ftests/systemd: Fix quote warnings

Fix "Q001 Single quote multiline found but double quotes preferred" and
multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/009: Fix quote warning
Kamalesh Babulal [Mon, 5 Aug 2024 05:59:05 +0000 (11:29 +0530)] 
ftests/009: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/010: Fix quote warning
Kamalesh Babulal [Sun, 4 Aug 2024 05:57:21 +0000 (11:27 +0530)] 
ftests/010: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/011: Fix quote warnings
Kamalesh Babulal [Sat, 3 Aug 2024 10:56:37 +0000 (16:26 +0530)] 
ftests/011: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/012: Fix quote warning
Kamalesh Babulal [Fri, 2 Aug 2024 05:54:50 +0000 (11:24 +0530)] 
ftests/012: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/012: Fix quote warnings
Kamalesh Babulal [Thu, 1 Aug 2024 10:55:53 +0000 (16:25 +0530)] 
ftests/012: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/016: Fix quote warnings
Kamalesh Babulal [Wed, 31 Jul 2024 10:54:45 +0000 (16:24 +0530)] 
ftests/016: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings by adjusting two lines into single line.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/017: Fix quote warnings
Kamalesh Babulal [Tue, 30 Jul 2024 10:51:04 +0000 (16:21 +0530)] 
ftests/017: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/018: Fix quote warnings
Kamalesh Babulal [Mon, 29 Jul 2024 10:50:19 +0000 (16:20 +0530)] 
ftests/018: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/019: Fix quote warnings
Kamalesh Babulal [Sun, 28 Jul 2024 10:49:21 +0000 (16:19 +0530)] 
ftests/019: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/020: Fix quote warnings
Kamalesh Babulal [Sat, 27 Jul 2024 10:48:09 +0000 (16:18 +0530)] 
ftests/020: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/021: Fix quote warnings
Kamalesh Babulal [Fri, 26 Jul 2024 10:46:46 +0000 (16:16 +0530)] 
ftests/021: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/031: Fix couple of quite warnings
Kamalesh Babulal [Thu, 25 Jul 2024 10:45:49 +0000 (16:15 +0530)] 
ftests/031: Fix couple of quite warnings

Fix "Q001 Single quote multiline found but double quotes preferred" and
multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/032: Fix couple of quite warnings
Kamalesh Babulal [Wed, 24 Jul 2024 10:43:50 +0000 (16:13 +0530)] 
ftests/032: Fix couple of quite warnings

Fix "Q001 Single quote multiline found but double quotes preferred" and
multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/038: Fix quote warning
Kamalesh Babulal [Tue, 23 Jul 2024 10:42:13 +0000 (16:12 +0530)] 
ftests/038: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/039: Fix quote warnings
Kamalesh Babulal [Mon, 22 Jul 2024 10:39:42 +0000 (16:09 +0530)] 
ftests/039: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/045: Fix quote warning
Kamalesh Babulal [Sun, 21 Jul 2024 10:35:36 +0000 (16:05 +0530)] 
ftests/045: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/054: Fix quote warnings
Kamalesh Babulal [Sat, 20 Jul 2024 10:34:38 +0000 (16:04 +0530)] 
ftests/054: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/055: Fix quote warnings
Kamalesh Babulal [Fri, 19 Jul 2024 10:33:03 +0000 (16:03 +0530)] 
ftests/055: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/056: Fix quote warnings
Kamalesh Babulal [Mon, 15 Jul 2024 10:30:35 +0000 (16:00 +0530)] 
ftests/056: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/057: Fix quote warnings
Kamalesh Babulal [Sun, 14 Jul 2024 10:28:56 +0000 (15:58 +0530)] 
ftests/057: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/058: Fix quote warnings
Kamalesh Babulal [Sat, 13 Jul 2024 10:27:20 +0000 (15:57 +0530)] 
ftests/058: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/059: Fix quote warnings
Kamalesh Babulal [Fri, 12 Jul 2024 10:25:38 +0000 (15:55 +0530)] 
ftests/059: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/071: Fix quote warnings
Kamalesh Babulal [Thu, 11 Jul 2024 10:23:31 +0000 (15:53 +0530)] 
ftests/071: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/078: Fix quote warning
Kamalesh Babulal [Wed, 10 Jul 2024 10:20:16 +0000 (15:50 +0530)] 
ftests/078: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/079: Fix quote warning
Kamalesh Babulal [Tue, 9 Jul 2024 10:19:25 +0000 (15:49 +0530)] 
ftests/079: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/084: Fix quote warnings
Kamalesh Babulal [Fri, 28 Jun 2024 08:04:14 +0000 (13:34 +0530)] 
ftests/084: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/076: Fix quote warning
Kamalesh Babulal [Mon, 24 Jun 2024 07:54:37 +0000 (13:24 +0530)] 
ftests/076: Fix quote warning

Fix "Q001 Single quote multiline found but double quotes preferred"
warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/081: Fix quote warnings
Kamalesh Babulal [Sun, 23 Jun 2024 07:50:45 +0000 (13:20 +0530)] 
ftests/081: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/082: Fix quote warnings
Kamalesh Babulal [Sat, 22 Jun 2024 07:48:29 +0000 (13:18 +0530)] 
ftests/082: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/088: Fix quote warnings
Kamalesh Babulal [Fri, 21 Jun 2024 07:41:55 +0000 (13:11 +0530)] 
ftests/088: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agotools/cgsnapshot: Fix ret value in load_list()
Kamalesh Babulal [Tue, 16 Jul 2024 07:13:32 +0000 (12:43 +0530)] 
tools/cgsnapshot: Fix ret value in load_list()

The CodeQL reported a warning:
"Incorrect return-value check for a 'scanf'-like function"

More information about the warning:
https://github.com/libcgroup/libcgroup/security/code-scanning/18

Fix the warning by adding an additional "EOF" check for the ret value
from sscanf() in the load_list().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agosrc/api: Fix ret value in cgroup_get_current_controller_path()
Kamalesh Babulal [Wed, 17 Jul 2024 07:30:48 +0000 (13:00 +0530)] 
src/api: Fix ret value in cgroup_get_current_controller_path()

The CodeQL reported a warning:
"Incorrect return-value check for a 'scanf'-like function"

More information about the warning:
https://github.com/libcgroup/libcgroup/security/code-scanning/16

Fix the warning by adding an additional "EOF" check for the ret value
from fscanf() in the cgroup_get_current_controller_path()

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/013: Refactor code to match outputs with same line
Kamalesh Babulal [Mon, 8 Jul 2024 11:16:49 +0000 (16:46 +0530)] 
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>
14 months agoftests/010: Refactor code to match outputs with same line
Kamalesh Babulal [Sun, 7 Jul 2024 05:28:49 +0000 (10:58 +0530)] 
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>
14 months agoftests/009: Refactor code to match outputs with same line
Kamalesh Babulal [Sat, 6 Jul 2024 10:35:02 +0000 (16:05 +0530)] 
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>
14 months agoftests/utils: Add helper to check if output matches
Kamalesh Babulal [Fri, 5 Jul 2024 09:58:01 +0000 (15:28 +0530)] 
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>
14 months agoftests: Add more smarts when creating a container
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>
14 months agoman: cgxset: document -R option
Kamalesh Babulal [Thu, 4 Jul 2024 02:17:30 +0000 (07:47 +0530)] 
man: cgxset: document -R option

Document -R option. It recursively sets variable settings passed with -r
option to cgroup_path and its descendant cgroups.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests: add test to exercise cgxset recursive set option
Kamalesh Babulal [Wed, 3 Jul 2024 04:08:06 +0000 (09:38 +0530)] 
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>
14 months agoftests/cgroup: Add recursive support for set()
Kamalesh Babulal [Tue, 2 Jul 2024 01:10:26 +0000 (06:40 +0530)] 
ftests/cgroup: Add recursive support for set()

Add support to recursively xset controller settings of a cgroup and its
descendants.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agotools/cgxset: add support for cgroup.subtree_control
Kamalesh Babulal [Mon, 1 Jul 2024 02:25:22 +0000 (07:55 +0530)] 
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.

example:
--------
$ sudo cgget -n -v -r cgroup.subtree_control a
cpu memory pids
$ sudo cgget -n -v -r cgroup.subtree_control a/b
cpu memory pids
$ sudo cgget -n -v -r cgroup.subtree_control a/b/c

$
$ sudo cgxset -R -r cgroup.subtree_control="-pids +cpuset" a
$ sudo cgget -n -v -r cgroup.subtree_control a
cpuset cpu memory
$ sudo cgget -n -v -r cgroup.subtree_control a/b
cpuset cpu memory
$ sudo cgget -n -v -r cgroup.subtree_control a/b/c

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agotools/cgxset: add -R option to recursively set variables
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.

example:
--------
./cgcreate -gcpu,memory:foo -gcpu:memory:foo/ch1 -gcpu,memory:foo/ch2
./cgget -r cpu.shares foo foo/ch1 foo/ch2
foo:
cpu.shares: 1024

foo/ch1:
cpu.shares: 1024

foo/ch2:
cpu.shares: 1024

Without the patch
------------------
./cgxset -2 -r cpu.weight=256 foo
./cgget -r cpu.shares foo
foo/ch1 foo/ch2
foo:
cpu.shares: 256

foo/ch1:
cpu.shares: 1024

foo/ch2:
cpu.shares: 1024

With the patch
--------------
./cgxset -R -2 -r cpu.weight=50 foo
./cgget -r cpu.shares foo foo/ch1 foo/ch2
foo:
cpu.shares: 512

foo/ch1:
cpu.shares: 512

foo/ch2:
cpu.shares: 512

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agotools/cgxset: add cgroup_set_cgroup_values() helper
Kamalesh Babulal [Sat, 29 Jun 2024 00:06:38 +0000 (05:36 +0530)] 
tools/cgxset: add cgroup_set_cgroup_values() helper

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>
14 months agotools/tools-common.c: handle DT_UNKNOWN from readdir()
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.

Signed-off-by: Vasil Kolev <vasil@ludost.net>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
14 months agoftests/utils: Fix flake8 warning
Kamalesh Babulal [Tue, 25 Jun 2024 10:06:51 +0000 (15:36 +0530)] 
ftests/utils: Fix flake8 warning

tests/ftests/utils.py:84:1: E302 expected 2 blank lines, found 1

Fixes: aa345bbe1d45 ("ftests/cgroup: Add function to return kernel version")
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/071: Introduce delay before killing cgroup
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>
15 months agoftests/013: Populate newer cpu controller output
Kamalesh Babulal [Thu, 13 Jun 2024 14:39:57 +0000 (20:09 +0530)] 
ftests/013: Populate newer cpu controller output

Populate the newer cpu controller output with pid controller list() by
adjusting the index.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/consts: Add cpu controller throttled_usec (v2)
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>
15 months agoftests/consts: Add cpu controller throttled_usec (v1)
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>
15 months agoftests/cgroup: Add support for favordynmods
Kamalesh Babulal [Sun, 9 Jun 2024 11:33:57 +0000 (17:03 +0530)] 
ftests/cgroup: Add support for favordynmods

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>
15 months agoftests: Add minimum Python version
Kamalesh Babulal [Sat, 8 Jun 2024 07:28:05 +0000 (12:58 +0530)] 
ftests: Add minimum Python version

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>
15 months agoftests/005: Append newer kernel expected output
Kamalesh Babulal [Thu, 6 Jun 2024 09:58:59 +0000 (15:28 +0530)] 
ftests/005: Append newer kernel expected output

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>
15 months agoftests/013: Use the controller list from consts
Kamalesh Babulal [Tue, 4 Jun 2024 15:25:11 +0000 (20:55 +0530)] 
ftests/013: Use the controller list from consts

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>
15 months agoftests/010: Use the controller list from consts
Kamalesh Babulal [Mon, 3 Jun 2024 15:21:53 +0000 (20:51 +0530)] 
ftests/010: Use the controller list from consts

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>
15 months agoftests/009: Use the controller list from consts
Kamalesh Babulal [Sun, 2 Jun 2024 15:11:48 +0000 (20:41 +0530)] 
ftests/009: Use the controller list from consts

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>
15 months agoftests/consts: Add cpu,pid controllers output lists
Kamalesh Babulal [Sat, 1 Jun 2024 15:01:36 +0000 (20:31 +0530)] 
ftests/consts: Add cpu,pid controllers output lists

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>
16 months agoftests/cgroup: Fix flake8 warning
Kamalesh Babulal [Thu, 30 May 2024 15:46:06 +0000 (21:16 +0530)] 
ftests/cgroup: Fix flake8 warning

Fix pythonlint (flake8) warning:
tests/ftests/cgroup.py:630:22: E275 missing whitespace after keyword

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agoftests/061: Fix the expected line in cpu controller
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>
16 months agoftests/cgroup: Add function to return kernel version
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

16 months agoftests/060: Add new systemd error message
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>
17 months agofix: cgroupv2_subtree_control_recursive(): test before writing
Adriaan Schmidt [Tue, 2 Apr 2024 12:55:46 +0000 (14:55 +0200)] 
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.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
17 months agoftests/038: fix cpuset_exclusive oddity
Kamalesh Babulal [Fri, 12 Apr 2024 10:18:45 +0000 (15:48 +0530)] 
ftests/038: fix cpuset_exclusive oddity

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>
17 months agoftests/013: add pids controller format
Kamalesh Babulal [Wed, 3 Apr 2024 10:13:27 +0000 (15:43 +0530)] 
ftests/013: add pids controller format

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>
17 months agoftests/013: add cpu controller format (v2)
Kamalesh Babulal [Mon, 1 Apr 2024 10:19:42 +0000 (15:49 +0530)] 
ftests/013: 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: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>
17 months agoftests/010: add cpu controller format (v2)
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>
17 months agoftests/009: add cpu controller format (v2)
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>
18 months agofeat: add cgroup_get_threads()
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.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
18 months agoftests/092: add test to attach threads to cgroup (v1)
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>
18 months agosrc/python: add attach_threads option to attach()
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>
18 months agoapi: add new API cgroup_attach_thread_tid() (v1)
Kamalesh Babulal [Fri, 8 Mar 2024 01:59:54 +0000 (07:29 +0530)] 
api: add new API cgroup_attach_thread_tid() (v1)

Add a new API cgroup_attach_thread_tid(), that will allow the users to
move all threads sharing the same tid (thread group leader).

Example:
---------
 #include <libcgroup.h>
 #include <stdio.h>
 #include <stdlib.h>

 #define CGRP_NAME "cgrp_foo"

 int main(int argc, char **argv)
 {
         struct cgroup_controller *cgc = NULL;
         struct cgroup *cgroup = NULL;
         int ret = 0;

         ret = cgroup_init();
         if (ret) {
                 fprintf(stderr, "cgroup_init failed\n");
                 exit(1);
         }

         cgroup = cgroup_new_cgroup(CGRP_NAME);
         if (!cgroup) {
                 fprintf(stderr, "Failed to allocate cgroup %s\n", CGRP_NAME);
                 exit(1);
         }

         cgc = cgroup_add_controller(cgroup, "cpu");
         if (!cgc) {
                 fprintf(stderr, "Failed to add controller cpu cgroup %s\n", CGRP_NAME);
                 exit(1);
         }

         ret = cgroup_create_cgroup(cgroup, 0);
         if (ret)
                 fprintf(stderr, "Failed to create cgroup %s\n", CGRP_NAME);

         ret = cgroup_attach_thread_tid(cgroup, atoi(argv[1]));
         if (ret)
                 fprintf(stderr, "failed to write threads tid %d\n", atoi(argv[1]));

         cgroup_free(&cgroup);

         exit(0);
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
18 months agoapi: add helper to write into cgroup.procs (v1)
Kamalesh Babulal [Thu, 7 Mar 2024 01:58:01 +0000 (07:28 +0530)] 
api: add helper to write into cgroup.procs (v1)

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>
18 months agoapi: add helper to move threads into cgroup (v1)
Kamalesh Babulal [Wed, 6 Mar 2024 01:55:17 +0000 (07:25 +0530)] 
api: add helper to move threads into cgroup (v1)

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>
20 months agoman: update cgconfig.conf with systemd settings
Kamalesh Babulal [Mon, 1 Jan 2024 09:55:21 +0000 (15:25 +0530)] 
man: update cgconfig.conf with systemd settings

Update the cgconfig.conf for available systemd settings, along with an
example.

Fixes: https://github.com/libcgroup/libcgroup/issues/418
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Minor grammatical changes

20 months agoftests/081: add support for cgroup hybrid mode
Kamalesh Babulal [Wed, 1 Nov 2023 10:43:33 +0000 (16:13 +0530)] 
ftests/081: add support for cgroup hybrid mode

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>
20 months agoftests/089: enable controller for hybrid parent cgroup
Kamalesh Babulal [Wed, 1 Nov 2023 07:20:46 +0000 (12:50 +0530)] 
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>
21 months agoRFE: Bump actions/upload-artifact from 3 to 4
dependabot[bot] [Mon, 18 Dec 2023 22:51:48 +0000 (22:51 +0000)] 
RFE: Bump actions/upload-artifact from 3 to 4

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>