2020-11-04 10:07:54

by Michael Ellerman

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Michael Ellerman <[email protected]>
---
tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 05853b0b8831..58e30f65df5e 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -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
--
2.25.1


2020-11-04 12:22:33

by Sachin Sant

[permalink] [raw]
Subject: Re: [PATCH] selftests/cgroup: Fix build on older distros



> On 04-Nov-2020, at 3:35 PM, Michael Ellerman <[email protected]> wrote:
>
> 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.
>

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));

> Signed-off-by: Michael Ellerman <[email protected]>
> ---
> tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
> index 05853b0b8831..58e30f65df5e 100644
> --- a/tools/testing/selftests/cgroup/cgroup_util.c
> +++ b/tools/testing/selftests/cgroup/cgroup_util.c
> @@ -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
> --
> 2.25.1
>

2020-11-04 12:33:41

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH] selftests/cgroup: Fix build on older distros

On Wed, Nov 04, 2020 at 05:50:40PM +0530, Sachin Sant wrote:
>
>
> > On 04-Nov-2020, at 3:35 PM, Michael Ellerman <[email protected]> wrote:
> >
> > 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.
> >
>
> 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));
>
> > Signed-off-by: Michael Ellerman <[email protected]>
> > ---

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:
Acked-by: Christian Brauner <[email protected]>

Thanks!
Christian