public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang via ltp <ltp@lists.linux.it>
To: Chris Wailes <chriswailes@google.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Update clone3 wrapper signature
Date: Fri, 20 Mar 2026 11:13:36 +0800	[thread overview]
Message-ID: <aby7YE-yhJz1BTzi@redhat.com> (raw)
In-Reply-To: <20260319185455.3683566-1-chriswailes@google.com>

On Thu, Mar 19, 2026 at 11:54:55AM -0700, Chris Wailes via ltp wrote:
> This CL adds the `ltp_clone3_raw` wrapper for direct testing of the
> syscall, conditionally defines `clone_args_minimal`, and adds a
> `ltp_clone3` wrapper for libc implementations that provide `clone3`.

When you signed off patch better to use 'git commit -sm "xxx"'
otherwise patch has no signature:

  Signed-off-by: Chris Wailes <chriswailes@google.com>

Also, the next patch version better to have "v2" keywords:

  git format-patch --subject-prefix="PATCH v2" -1 

add notes like "v2: blablabla..." via:

  git notes add 

> ---
>  include/lapi/sched.h                        | 27 +++++++++++++++------
>  testcases/kernel/syscalls/clone3/clone301.c |  2 +-
>  testcases/kernel/syscalls/clone3/clone302.c |  2 +-
>  3 files changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/include/lapi/sched.h b/include/lapi/sched.h
> index 36f1ecad9..fc367f772 100644
> --- a/include/lapi/sched.h
> +++ b/include/lapi/sched.h
> @@ -49,8 +49,7 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
>  # define SCHED_ATTR_SIZE_VER0 48	/* sizeof first published struct */
>  #endif
>  
> -#ifndef HAVE_CLONE3
> -struct clone_args {
> +struct clone_args_minimal {
>  	uint64_t __attribute__((aligned(8))) flags;
>  	uint64_t __attribute__((aligned(8))) pidfd;
>  	uint64_t __attribute__((aligned(8))) child_tid;
> @@ -59,12 +58,10 @@ struct clone_args {
>  	uint64_t __attribute__((aligned(8))) stack;
>  	uint64_t __attribute__((aligned(8))) stack_size;
>  	uint64_t __attribute__((aligned(8))) tls;
> -	uint64_t __attribute__((aligned(8))) set_tid;
> -	uint64_t __attribute__((aligned(8))) set_tid_size;
> -	uint64_t __attribute__((aligned(8))) cgroup;
>  };
>  
> -struct clone_args_minimal {
> +#ifndef HAVE_CLONE_ARGS

In LTP, these HAVE_* macros are typically generated by the configure
script (autoconf). The configure script checks for the existence of
types, functions, and headers in the system, and defines corresponding
macros in config.h.

But here you use a non_exist HAVE_CLONE_ARGS, I think we should to
use HAVE_CLONE3 or add struct clone_args check there(then we can
use HAVE_STRUCT_CLONE_ARGS).

See: ltp/configure.ac

> +struct clone_args {
>  	uint64_t __attribute__((aligned(8))) flags;
>  	uint64_t __attribute__((aligned(8))) pidfd;
>  	uint64_t __attribute__((aligned(8))) child_tid;
> @@ -73,12 +70,28 @@ struct clone_args_minimal {
>  	uint64_t __attribute__((aligned(8))) stack;
>  	uint64_t __attribute__((aligned(8))) stack_size;
>  	uint64_t __attribute__((aligned(8))) tls;
> +	uint64_t __attribute__((aligned(8))) set_tid;
> +	uint64_t __attribute__((aligned(8))) set_tid_size;
> +	uint64_t __attribute__((aligned(8))) cgroup;
>  };
> +#endif
>  
> -static inline int clone3(struct clone_args *args, size_t size)
> +static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
>  {
>  	return tst_syscall(__NR_clone3, args, size);
>  }
> +
> +#ifdef HAVE_CLONE3_WRAPPER

Here as well.

You can check with:

  grep -r "HAVE_CLONE3_WRAPPER" configure.ac m4/ include/config.h.in

before using unsure macros.

> +static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
> +               int (*fn)(void *), void *arg) {
> +	return clone3(cl_args, size, fn, arg);
> +}
> +#else
> +static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
> +                             int (*fn)(void *), void *arg)
> +{
> +	return -1;
> +}
>  #endif
>  
>  static inline void clone3_supported_by_kernel(void)
> diff --git a/testcases/kernel/syscalls/clone3/clone301.c b/testcases/kernel/syscalls/clone3/clone301.c
> index deed30b9f..58fc1702e 100644
> --- a/testcases/kernel/syscalls/clone3/clone301.c
> +++ b/testcases/kernel/syscalls/clone3/clone301.c
> @@ -123,7 +123,7 @@ static void run(unsigned int n)
>  	parent_received_signal = 0;
>  	SAFE_SIGACTION(tc->exit_signal, &psig_action, NULL);
>  
> -	TEST(pid = clone3(args, sizeof(*args)));
> +	TEST(pid = ltp_clone3_raw(args, sizeof(*args)));
>  	if (pid < 0) {
>  		tst_res(TFAIL | TTERRNO, "clone3() failed (%d)", n);
>  		return;
> diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
> index 9e98f1954..883112183 100644
> --- a/testcases/kernel/syscalls/clone3/clone302.c
> +++ b/testcases/kernel/syscalls/clone3/clone302.c

We need to modify it in clone304.c as well.

The rest part looks good.

> @@ -83,7 +83,7 @@ static void run(unsigned int n)
>  		args->tls = tc->tls;
>  	}
>  
> -	TEST(clone3(args, tc->size));
> +	TEST(ltp_clone3_raw(args, tc->size));
>  
>  	if (!TST_RET)
>  		exit(EXIT_SUCCESS);
> -- 
> 2.53.0.959.g497ff81fa9-goog
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

-- 
Regards,
Li Wang


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

  reply	other threads:[~2026-03-20  3:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 18:54 [LTP] [PATCH] Update clone3 wrapper signature Chris Wailes via ltp
2026-03-20  3:13 ` Li Wang via ltp [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-11-14 19:52 Chris Wailes via ltp
2025-12-16 12:40 ` Andrea Cervesato via ltp
2025-12-16 17:50   ` Chris Wailes via ltp
2025-12-17  7:58     ` Anrea Cervesato via ltp
2025-12-17  9:43       ` Li Wang via ltp
2026-03-04 21:33         ` Chris Wailes via ltp
2026-03-18 18:29           ` Chris Wailes via ltp
2026-03-19  3:54             ` Li Wang via ltp
2026-03-19 18:55               ` Chris Wailes via ltp

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=aby7YE-yhJz1BTzi@redhat.com \
    --to=ltp@lists.linux.it \
    --cc=chriswailes@google.com \
    --cc=liwang@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox