Skip to contentSkip to conversation

selftests/cgroup: Fix cg_run_in_subcgroups ignoring arg parameter

PATCH Applied Hongfu Li 3 participants 3 messages Aug 20 – Aug 21

Subsystems (4)
lore
Share & tools
lore

Hongfu Li

author
#0 lore raw

PATCH 1/1 selftests/cgroup: Fix cg_run_in_subcgroups ignoring arg parameter

From: Hongfu Li <[email protected]>

cg_run_in_subcgroups() discards its arg and always passes NULL to cg_run(), turning the (void *)100 from test_kmem_dead_cgroups() into NULL so no allocation occurs.

This makes test_kmem_dead_cgroups() falsely pass without exercising the "dying cgroup with charged slab" scenario it intends to test.

Pass the arg through to cg_run() to fix this.

Fixes 933dc80ec262 ("kselftests: cgroup: add kernel memory accounting tests")
---
 tools/testing/selftests/cgroup/test_kmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cgroup/test_kmem.c +1 -1
index 1db0ba1226b9..98e9f9f45ab9 100644
@@ -145,7 +145,7 @@ static int cg_run_in_subcgroups(const char *parent,
 			return -1;
 		}
 
-		if (cg_run(child, fn, NULL)) {
+		if (cg_run(child, fn, arg)) {
 			cg_destroy(child);
 			free(child);
 			return -1;
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Hongfu Li

From: Hongfu Li <[email protected]>

cg_run_in_subcgroups() discards its arg and always passes NULL to cg_run(), turning the (void *)100 from test_kmem_dead_cgroups() into NULL so no allocation occurs.

This makes test_kmem_dead_cgroups() falsely pass without exercising the "dying cgroup with charged slab" scenario it intends to test.

Quoted 7 lines

Pass the arg through to cg_run() to fix this.

Fixes 933dc80ec262 ("kselftests: cgroup: add kernel memory accounting tests")
---
 tools/testing/selftests/cgroup/test_kmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Good catch,