aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/cgroup/cgroup_util.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-04-19kselftests: cgroup: add freezer controller self-testsRoman Gushchin1-1/+53
This patch implements 9 tests for the freezer controller for cgroup v2: 1) a simple test, which aims to freeze and unfreeze a cgroup with 100 processes 2) a more complicated tree test, which creates a hierarchy of cgroups, puts some processes in some cgroups, and tries to freeze and unfreeze different parts of the subtree 3) a forkbomb test: the test aims to freeze a forkbomb running in a cgroup, kill all tasks in the cgroup and remove the cgroup without the unfreezing. 4) rmdir test: the test creates two nested cgroups, freezes the parent one, checks that the child can be successfully removed, and a new child can be created 5) migration tests: the test checks migration of a task between frozen cgroups: from a frozen to a running, from a running to a frozen, and from a frozen to a frozen. 6) ptrace test: the test checks that it's possible to attach to a process in a frozen cgroup, get some information and detach, and the cgroup will remain frozen. 7) stopped test: the test checks that it's possible to freeze a cgroup with a stopped task 8) ptraced test: the test checks that it's possible to freeze a cgroup with a ptraced task 9) vfork test: the test checks that it's possible to freeze a cgroup with a parent process waiting for the child process in vfork() Expected output: $ ./test_freezer ok 1 test_cgfreezer_simple ok 2 test_cgfreezer_tree ok 3 test_cgfreezer_forkbomb ok 4 test_cgrreezer_rmdir ok 5 test_cgfreezer_migrate ok 6 test_cgfreezer_ptrace ok 7 test_cgfreezer_stopped ok 8 test_cgfreezer_ptraced ok 9 test_cgfreezer_vfork Signed-off-by: Roman Gushchin <guro@fb.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: kernel-team@fb.com Cc: linux-kselftest@vger.kernel.org
2019-04-19kselftests: cgroup: don't fail on cg_kill_all() error in cg_destroy()Roman Gushchin1-3/+1
If the cgroup destruction races with an exit() of a belonging process(es), cg_kill_all() may fail. It's not a good reason to make cg_destroy() fail and leave the cgroup in place, potentially causing next test runs to fail. Signed-off-by: Roman Gushchin <guro@fb.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: kernel-team@fb.com Cc: linux-kselftest@vger.kernel.org
2018-09-07Add tests for memory.oom.groupJay Kamat1-0/+21
Add tests for memory.oom.group for the following cases: - Killing all processes in a leaf cgroup, but leaving the parent untouched - Killing all processes in a parent and leaf cgroup - Keeping processes marked by OOM_SCORE_ADJ_MIN alive when considered for being killed by the group oom killer. Signed-off-by: Jay Kamat <jgkamat@fb.com> Acked-by: Roman Gushchin <guro@fb.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-09-07Fix cg_read_strcmp()Jay Kamat1-3/+14
Fix a couple issues with cg_read_strcmp(), to improve correctness of cgroup tests - Fix cg_read_strcmp() always returning 0 for empty "needle" strings. Previously, this function read to a size = 1 buffer when comparing against empty strings, which would lead to cg_read_strcmp() comparing two empty strings. - Fix a memory leak in cg_read_strcmp() Fixes: 84092dbcf901 ("selftests: cgroup: add memory controller self-tests") Signed-off-by: Jay Kamat <jgkamat@fb.com> Acked-by: Roman Gushchin <guro@fb.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-08-09Add cgroup core selftestsClaudio1-0/+8
This commit adds tests for some of the core functionalities of cgroups v2. The commit adds tests for some core principles of croup V2 API: - test_cgcore_internal_process_constraint Tests internal process constraint. You can't add a pid to a domain parent if a controller is enabled. - test_cgcore_top_down_constraint_enable Tests that you can't enable a controller on a child if it's not enabled on the parent. - test_cgcore_top_down_constraint_disable Tests that you can't disable a controller on a parent if it's enabled in a child. - test_cgcore_no_internal_process_constraint_on_threads Tests that there's no internal process constrain on threaded cgroups. You can add threads/processes on a parent with a controller enabled. - test_cgcore_parent_becomes_threaded Tests that when a child becomes threaded the parent type becomes domain threaded. - test_cgcore_invalid_domain In a situation like: A (domain threaded) - B (threaded) - C (domain) it tests that C can't be used until it is turned into a threaded cgroup. The "cgroup.type" file will report "domain (invalid)" in these cases. Operations which fail due to invalid topology use EOPNOTSUPP as the errno. - test_cgcore_populated In a situation like: A(0) - B(0) - C(1) \ D(0) It tests that A, B and C's "populated" fields would be 1 while D's 0. It tests that after the one process in C is moved to root, A,B and C's "populated" fields would flip to "0" and file modified events will be generated on the "cgroup.events" files of both cgroups. Signed-off-by: Claudio Zumbo <claudioz@fb.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Roman Gushchin <guro@fb.com> Cc: Tejun Heo <tj@kernel.org> Cc: kernel-team@fb.com Acked-by: Tejun Heo <tj@kernel.org> Reviewed-by: Roman Gushchin <guro@fb.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-06-07kselftest/cgroup: fix a signedness bugDan Carpenter1-2/+2
"len" needs to be signed for the error handling to work. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-05-30kselftest/cgroup: fix variable dereferenced before check warningRoman Gushchin1-4/+2
cg_name(const char *root, const char *name) is always called with non-empty root and name arguments, so there is no sense in checking it in the function body (after using in strlen()). Signed-off-by: Roman Gushchin <guro@fb.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-05-30selftests: cgroup/memcontrol: add basic test for swap controlsMike Rapoport1-0/+16
The new test verifies that memory.swap.max and memory.swap.current behave as expected for simple allocation scenarios Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Roman Gushchin <guro@fb.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-05-30selftests: cgroup: add memory controller self-testsRoman Gushchin1-0/+317
Cgroups are used for controlling the physical resource distribution (memory, CPU, io, etc) and often are used as basic building blocks for large distributed computing systems. Even small differences in the actual behavior may lead to significant incidents. The codebase is under the active development, which will unlikely stop at any time soon. Also it's scattered over different kernel subsystems, which makes regressions more probable. Given that, the lack of any tests is crying. This patch implements some basic tests for the memory controller, as well as a minimal required framework. It doesn't pretend for a very good coverage, but pretends to be a starting point. Hopefully, any following significant changes will include corresponding tests. Tests for CPU and io controllers, as well as cgroup core are next in the todo list. Signed-off-by: Roman Gushchin <guro@fb.com> Cc: Tejun Heo <tj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: kernel-team@fb.com Cc: linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>