Skip to contentSkip to conversation

selftests/cgroup: Fix build on older distros

PATCH In review Sachin Sant 2 participants 3 messages Nov 6, 2020 – Nov 11, 2020 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH v2 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' cgroup_util.c:346:33: error: invalid application of 'sizeof' to incomplete
type 'struct clone_args'

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.

---

V2: Replace all instances of clone_args by __clone_args
---

b/tools/testing/selftests/cgroup/cgroup_util.c renamed from a/tools/testing/selftests/cgroup/cgroup_util.c +2 -2
index 05853b0..0270146 100644
@@ -337,13 +337,13 @@ 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,
 	};
 
-	pid = sys_clone3(&args, sizeof(struct clone_args));
+	pid = sys_clone3(&args, sizeof(struct __clone_args));
 	/*
 	 * Verify that this is a genuine test failure:
 	 * ENOSYS -> clone3() not available
maintainer
#1 lore raw
Quoted 32 lines · Sachin Sant

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' cgroup_util.c:346:33: error: invalid application of 'sizeof' to incomplete
type 'struct clone_args'

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.

---

V2: Replace all instances of clone_args by __clone_args
---

b/tools/testing/selftests/cgroup/cgroup_util.c renamed from a/tools/testing/selftests/cgroup/cgroup_util.c +1 -1
index 05853b0..0270146 100644
@@ -337,13 +337,13 @@ pid_t clone_into_cgroup(int cgroup_fd)
  #ifdef CLONE_ARGS_SIZE_VER2
  	pid_t pid;
 
-	struct clone_args args = {
+	struct __clone_args args = {

b/tools/testing/selftests/cgroup/cgroup_util.c pid_t clone_into_cgroup(int cgroup_fd) · line 349

Quoted 10 lines
b/tools/testing/selftests/cgroup/cgroup_util.c renamed from a/tools/testing/selftests/cgroup/cgroup_util.c +1 -1
  		.flags = CLONE_INTO_CGROUP,
  		.exit_signal = SIGCHLD,
  		.cgroup = cgroup_fd,
  	};
 
-	pid = sys_clone3(&args, sizeof(struct clone_args));
+	pid = sys_clone3(&args, sizeof(struct __clone_args));
  	/*
  	 * Verify that this is a genuine test failure:
  	 * ENOSYS -> clone3() not available

Not sure how you generated the patch. I had to use git am -p2

Applied to linux-kselftest next - please make sure to generate from top level.

thanks,
-- Shuah

#2 lore raw
Quoted 15 lines · Shuah Khan

b/tools/testing/selftests/cgroup/cgroup_util.c

Quoted 7 lines · Sachin Sant

---
V2: Replace all instances of clone_args by __clone_args
---

b/tools/testing/selftests/cgroup/cgroup_util.c renamed from a/tools/testing/selftests/cgroup/cgroup_util.c +0 -0
index 05853b0..0270146 100644

Not sure how you generated the patch. I had to use git am -p2

Sorry about that. Not sure what happened. Thanks.

-Sachin