All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Yang Xu <xuyang2018.jy@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1 2/2] include/lapi/sched.h: Move lapi/clone.h into here
Date: Thu, 01 Dec 2022 10:06:40 +0000	[thread overview]
Message-ID: <87lenrigjp.fsf@suse.de> (raw)
In-Reply-To: <1669704060-5635-2-git-send-email-xuyang2018.jy@fujitsu.com>


Yang Xu <xuyang2018.jy@fujitsu.com> writes:

> Like namespaces_constants.h, kernel doesn't have
> clone.h header. We can also move it into here.
>
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>

> ---
> This patch has been verified on my ltp fork[1].
> [1]https://github.com/xuyang0410/ltp/actions/runs/3571298308/jobs/6003048080
>  include/lapi/clone.h                          | 56 -------------------
>  include/lapi/sched.h                          | 31 ++++++++++
>  lib/tst_clone.c                               |  2 +-
>  testcases/kernel/containers/pidns/pidns13.c   |  2 +-
>  testcases/kernel/containers/userns/userns08.c |  2 +-
>  testcases/kernel/syscalls/clone3/clone301.c   |  2 +-
>  testcases/kernel/syscalls/clone3/clone302.c   |  2 +-
>  .../syscalls/close_range/close_range01.c      |  2 +-
>  .../syscalls/close_range/close_range02.c      |  2 +-
>  9 files changed, 38 insertions(+), 63 deletions(-)
>  delete mode 100644 include/lapi/clone.h
>
> diff --git a/include/lapi/clone.h b/include/lapi/clone.h
> deleted file mode 100644
> index 437d1376f..000000000
> --- a/include/lapi/clone.h
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> -/*
> - * Copyright (c) 2020 Linaro Limited. All rights reserved.
> - * Author: Viresh Kumar <viresh.kumar@linaro.org>
> - */
> -
> -#ifndef LAPI_CLONE_H__
> -#define LAPI_CLONE_H__
> -
> -#include <sys/syscall.h>
> -#include <linux/types.h>
> -#include <sched.h>
> -#include <stdint.h>
> -
> -#include "config.h"
> -#include "lapi/syscalls.h"
> -
> -#ifndef HAVE_CLONE3
> -struct clone_args {
> -	uint64_t __attribute__((aligned(8))) flags;
> -	uint64_t __attribute__((aligned(8))) pidfd;
> -	uint64_t __attribute__((aligned(8))) child_tid;
> -	uint64_t __attribute__((aligned(8))) parent_tid;
> -	uint64_t __attribute__((aligned(8))) exit_signal;
> -	uint64_t __attribute__((aligned(8))) stack;
> -	uint64_t __attribute__((aligned(8))) stack_size;
> -	uint64_t __attribute__((aligned(8))) tls;
> -};
> -
> -static inline int clone3(struct clone_args *args, size_t size)
> -{
> -	return tst_syscall(__NR_clone3, args, size);
> -}
> -#endif
> -
> -#ifndef CLONE_PIDFD
> -#define CLONE_PIDFD	0x00001000	/* set if a pidfd should be placed in parent */
> -#endif
> -
> -#ifndef CLONE_NEWUSER
> -# define CLONE_NEWUSER	0x10000000
> -#endif
> -
> -static inline void clone3_supported_by_kernel(void)
> -{
> -	long ret;
> -
> -	if ((tst_kvercmp(5, 3, 0)) < 0) {
> -		/* Check if the syscall is backported on an older kernel */
> -		ret = syscall(__NR_clone3, NULL, 0);
> -		if (ret == -1 && errno == ENOSYS)
> -			tst_brk(TCONF, "Test not supported on kernel version < v5.3");
> -	}
> -}
> -
> -#endif /* LAPI_CLONE_H__ */
> diff --git a/include/lapi/sched.h b/include/lapi/sched.h
> index 3b0b4be31..1d22a9d7e 100644
> --- a/include/lapi/sched.h
> +++ b/include/lapi/sched.h
> @@ -11,6 +11,7 @@
>  #include <unistd.h>
>  #include <stdint.h>
>  #include <inttypes.h>
> +#include "config.h"
>  #include "lapi/syscalls.h"
>  
>  struct sched_attr {
> @@ -43,6 +44,32 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
>  	return syscall(__NR_sched_getattr, pid, attr, size, flags);
>  }
>  
> +#ifndef HAVE_CLONE3
> +struct clone_args {
> +	uint64_t __attribute__((aligned(8))) flags;
> +	uint64_t __attribute__((aligned(8))) pidfd;
> +	uint64_t __attribute__((aligned(8))) child_tid;
> +	uint64_t __attribute__((aligned(8))) parent_tid;
> +	uint64_t __attribute__((aligned(8))) exit_signal;
> +	uint64_t __attribute__((aligned(8))) stack;
> +	uint64_t __attribute__((aligned(8))) stack_size;
> +	uint64_t __attribute__((aligned(8))) tls;
> +};
> +
> +static inline int clone3(struct clone_args *args, size_t size)
> +{
> +	return tst_syscall(__NR_clone3, args, size);
> +}
> +#endif
> +
> +static inline void clone3_supported_by_kernel(void)
> +{
> +	if ((tst_kvercmp(5, 3, 0)) < 0) {
> +		/* Check if the syscall is backported on an older kernel */
> +		tst_syscall(__NR_clone3, NULL, 0);
> +	}
> +}
> +
>  #ifndef SCHED_DEADLINE
>  # define SCHED_DEADLINE	6
>  #endif
> @@ -55,6 +82,10 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
>  # define CLONE_FS	0x00000200
>  #endif
>  
> +#ifndef CLONE_PIDFD
> +# define CLONE_PIDFD	0x00001000
> +#endif
> +
>  #ifndef CLONE_NEWNS
>  # define CLONE_NEWNS	0x00020000
>  #endif
> diff --git a/lib/tst_clone.c b/lib/tst_clone.c
> index 07e7f0767..ecc84408c 100644
> --- a/lib/tst_clone.c
> +++ b/lib/tst_clone.c
> @@ -8,7 +8,7 @@
>  #include <stddef.h>
>  
>  #include "tst_test.h"
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  
>  pid_t tst_clone(const struct tst_clone_args *tst_args)
>  {
> diff --git a/testcases/kernel/containers/pidns/pidns13.c b/testcases/kernel/containers/pidns/pidns13.c
> index 39fd6df7f..6a155027c 100644
> --- a/testcases/kernel/containers/pidns/pidns13.c
> +++ b/testcases/kernel/containers/pidns/pidns13.c
> @@ -31,7 +31,7 @@
>  
>  #include "tst_test.h"
>  #include "tst_clone.h"
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  
>  static int pipe_fd[2];
>  
> diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c
> index afdad6cad..2697d874b 100644
> --- a/testcases/kernel/containers/userns/userns08.c
> +++ b/testcases/kernel/containers/userns/userns08.c
> @@ -25,7 +25,7 @@
>  
>  #include "tst_test.h"
>  #include "tst_clone.h"
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  #include "tst_safe_file_at.h"
>  
>  static pid_t clone_newuser(void)
> diff --git a/testcases/kernel/syscalls/clone3/clone301.c b/testcases/kernel/syscalls/clone3/clone301.c
> index f7ef0b2d7..d0fadbc5d 100644
> --- a/testcases/kernel/syscalls/clone3/clone301.c
> +++ b/testcases/kernel/syscalls/clone3/clone301.c
> @@ -15,7 +15,7 @@
>  #include <sys/wait.h>
>  
>  #include "tst_test.h"
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  #include "lapi/pidfd.h"
>  
>  #define CHILD_SIGNAL	SIGUSR1
> diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
> index 08d6417ce..b1b4ccebb 100644
> --- a/testcases/kernel/syscalls/clone3/clone302.c
> +++ b/testcases/kernel/syscalls/clone3/clone302.c
> @@ -14,7 +14,7 @@
>  #include <stdlib.h>
>  
>  #include "tst_test.h"
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  
>  static struct clone_args *valid_args, *invalid_args;
>  unsigned long stack;
> diff --git a/testcases/kernel/syscalls/close_range/close_range01.c b/testcases/kernel/syscalls/close_range/close_range01.c
> index 5e2de4d1e..30bb600b6 100644
> --- a/testcases/kernel/syscalls/close_range/close_range01.c
> +++ b/testcases/kernel/syscalls/close_range/close_range01.c
> @@ -28,7 +28,7 @@
>  #include "tst_test.h"
>  #include "tst_clone.h"
>  
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  #include "lapi/close_range.h"
>  
>  static int fd[3];
> diff --git a/testcases/kernel/syscalls/close_range/close_range02.c b/testcases/kernel/syscalls/close_range/close_range02.c
> index bd46936bb..aec899261 100644
> --- a/testcases/kernel/syscalls/close_range/close_range02.c
> +++ b/testcases/kernel/syscalls/close_range/close_range02.c
> @@ -18,7 +18,7 @@
>  #include "tst_clone.h"
>  #include "lapi/fcntl.h"
>  #include "lapi/close_range.h"
> -#include "lapi/clone.h"
> +#include "lapi/sched.h"
>  
>  static int try_close_range(int fd, int flags)
>  {
> -- 
> 2.23.0


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2022-12-01 10:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29  6:40 [LTP] [PATCH v1 1/2] include/lapi/sched.h: move namespaces_constants.h's constant into here Yang Xu
2022-11-29  5:50 ` Li Wang
2022-11-29  6:41 ` [LTP] [PATCH v1 2/2] include/lapi/sched.h: Move lapi/clone.h " Yang Xu
2022-11-29  5:50   ` Li Wang
2022-12-01 10:06   ` Richard Palethorpe [this message]
2022-12-01 10:05 ` [LTP] [PATCH v1 1/2] include/lapi/sched.h: move namespaces_constants.h's constant " Richard Palethorpe
2022-12-02  2:30   ` xuyang2018.jy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lenrigjp.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=xuyang2018.jy@fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.