Skip to contentSkip to conversation

selftests/cgroup: Fix build on older distros

PATCH In review Michael Ellerman 3 participants 3 messages Nov 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/cgroup: Fix build on older distros

On older distros struct clone_args does not have a cgroup member, leading to build errors:

cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:343:4: error: 'struct clone_args' has no member named 'cgroup'

But the selftests already have a locally defined version of the structure which is up to date, called __clone_args.

So use __clone_args which fixes the error.

---
 tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cgroup/cgroup_util.c +1 -1
index 05853b0b8831..58e30f65df5e 100644
@@ -337,7 +337,7 @@ pid_t clone_into_cgroup(int cgroup_fd)
 #ifdef CLONE_ARGS_SIZE_VER2
 	pid_t pid;
 
-	struct clone_args args = {
+	struct __clone_args args = {
 		.flags = CLONE_INTO_CGROUP,
 		.exit_signal = SIGCHLD,
 		.cgroup = cgroup_fd,

base-commit: cf7cd542d1b538f6e9e83490bc090dd773f4266d

Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Michael Ellerman

On older distros struct clone_args does not have a cgroup member, leading to build errors:

Quoted 8 lines

cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:343:4: error: 'struct clone_args' has no member named 'cgroup'

But the selftests already have a locally defined version of the structure which is up to date, called __clone_args.

So use __clone_args which fixes the error.

Argument passed to sys_clone3() will also require a similar change.

- pid = sys_clone3(&args, sizeof(struct clone_args));
+ pid = sys_clone3(&args, sizeof(struct __clone_args));

Without this compilation still fails(at least for me) due to following error

cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:346:33: error: invalid application of 'sizeof' to incomplete type 'struct clone_args'
pid = sys_clone3(&args, sizeof(struct clone_args));

Quoted 23 lines

---
tools/testing/selftests/cgroup/cgroup_util.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cgroup/cgroup_util.c +1 -1
index 05853b0b8831..58e30f65df5e 100644
@@ -337,7 +337,7 @@ pid_t clone_into_cgroup(int cgroup_fd)
 #ifdef CLONE_ARGS_SIZE_VER2
 	pid_t pid;
 
-	struct clone_args args = {
+	struct __clone_args args = {
 		.flags = CLONE_INTO_CGROUP,
 		.exit_signal = SIGCHLD,
 		.cgroup = cgroup_fd,

base-commit: cf7cd542d1b538f6e9e83490bc090dd773f4266d

Signature · 1 line
2.25.1
#2 lore raw
Quoted 21 lines · Sachin Sant
Quoted 7 lines · Michael Ellerman

On older distros struct clone_args does not have a cgroup member, leading to build errors:

Quoted 8 lines

cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:343:4: error: 'struct clone_args' has no member named 'cgroup'

But the selftests already have a locally defined version of the structure which is up to date, called __clone_args.

So use __clone_args which fixes the error.

Argument passed to sys_clone3() will also require a similar change.

(quoted diff) +1 -1
-	pid = sys_clone3(&args, sizeof(struct clone_args));
+	pid = sys_clone3(&args, sizeof(struct __clone_args));
Quoted 8 lines

Without this compilation still fails(at least for me) due to following error

cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:346:33: error: invalid application of 'sizeof' to incomplete type 'struct clone_args'
pid = sys_clone3(&args, sizeof(struct clone_args));

Quoted 2 lines

---

Thanks Michael for taking care fo this. Much appreciated. I think with the fix that Sachin pointed out this should work out fine!

Once that's fixed up:

Thanks!
Christian