From: Christian Brauner <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: Re: [PATCH 4/5] exit: add internal include file with helpers
Date: Fri, 14 Jul 2023 17:38:51 +0200 [thread overview]
Message-ID: <20230714-lachen-gelassen-716cd90a9a0c@brauner> (raw)
In-Reply-To: <[email protected]>
On Tue, Jul 11, 2023 at 02:43:51PM -0600, Jens Axboe wrote:
> Move struct wait_opts and waitid_info into kernel/exit.h, and include
> function declarations for the recently added helpers. Make them
> non-static as well.
>
> This is in preparation for adding a waitid operation through io_uring.
> With the abtracted helpers, this is now possible.
>
> Signed-off-by: Jens Axboe <[email protected]>
> ---
> kernel/exit.c | 32 +++++++-------------------------
> kernel/exit.h | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 37 insertions(+), 25 deletions(-)
> create mode 100644 kernel/exit.h
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 8934c91a9fe1..1c9d1cbadcd0 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -74,6 +74,8 @@
> #include <asm/unistd.h>
> #include <asm/mmu_context.h>
>
> +#include "exit.h"
> +
> /*
> * The default value should be high enough to not crash a system that randomly
> * crashes its kernel from time to time, but low enough to at least not permit
> @@ -1037,26 +1039,6 @@ SYSCALL_DEFINE1(exit_group, int, error_code)
> return 0;
> }
>
> -struct waitid_info {
> - pid_t pid;
> - uid_t uid;
> - int status;
> - int cause;
> -};
> -
> -struct wait_opts {
> - enum pid_type wo_type;
> - int wo_flags;
> - struct pid *wo_pid;
> -
> - struct waitid_info *wo_info;
> - int wo_stat;
> - struct rusage *wo_rusage;
> -
> - wait_queue_entry_t child_wait;
> - int notask_error;
> -};
> -
> static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
> {
> return wo->wo_type == PIDTYPE_MAX ||
> @@ -1520,7 +1502,7 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk)
> return 0;
> }
>
> -static bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
> +bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
> {
> if (!eligible_pid(wo, p))
> return false;
> @@ -1590,7 +1572,7 @@ static int do_wait_pid(struct wait_opts *wo)
> return 0;
> }
>
> -static long __do_wait(struct wait_opts *wo)
> +long __do_wait(struct wait_opts *wo)
> {
> long retval;
>
> @@ -1662,9 +1644,9 @@ static long do_wait(struct wait_opts *wo)
> return retval;
> }
>
> -static int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
> - struct waitid_info *infop, int options,
> - struct rusage *ru, unsigned int *f_flags)
> +int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
> + struct waitid_info *infop, int options,
> + struct rusage *ru, unsigned int *f_flags)
> {
> struct pid *pid = NULL;
> enum pid_type type;
> diff --git a/kernel/exit.h b/kernel/exit.h
> new file mode 100644
> index 000000000000..f10207ba1341
> --- /dev/null
> +++ b/kernel/exit.h
> @@ -0,0 +1,30 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#ifndef LINUX_WAITID_H
> +#define LINUX_WAITID_H
> +
> +struct waitid_info {
> + pid_t pid;
> + uid_t uid;
> + int status;
> + int cause;
> +};
> +
> +struct wait_opts {
> + enum pid_type wo_type;
> + int wo_flags;
> + struct pid *wo_pid;
> +
> + struct waitid_info *wo_info;
> + int wo_stat;
> + struct rusage *wo_rusage;
> +
> + wait_queue_entry_t child_wait;
> + int notask_error;
> +};
> +
> +bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p);
> +long __do_wait(struct wait_opts *wo);
> +int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid,
> + struct waitid_info *infop, int options,
> + struct rusage *ru, unsigned int *f_flags);
I know this isn't your mess obviously but could you try and see whether
you can expose a nicer, dedicated struct and helper suited to io_uring's
needs instead of exposing the messy kernel/exit.c format?
next prev parent reply other threads:[~2023-07-14 15:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 20:43 [PATCHSET 0/5] Add io_uring support for waitid Jens Axboe
2023-07-11 20:43 ` [PATCH 1/5] exit: abtract out should_wake helper for child_wait_callback() Jens Axboe
2023-07-14 15:31 ` Christian Brauner
2023-07-11 20:43 ` [PATCH 2/5] exit: move core of do_wait() into helper Jens Axboe
2023-07-14 15:32 ` Christian Brauner
2023-07-11 20:43 ` [PATCH 3/5] exit: add kernel_waitid_prepare() helper Jens Axboe
2023-07-11 20:43 ` [PATCH 4/5] exit: add internal include file with helpers Jens Axboe
2023-07-14 15:38 ` Christian Brauner [this message]
2023-07-14 20:16 ` Jens Axboe
2023-07-14 20:21 ` Jens Axboe
2023-07-11 20:43 ` [PATCH 5/5] io_uring: add IORING_OP_WAITID support Jens Axboe
2023-07-11 21:11 ` Arnd Bergmann
2023-07-11 21:22 ` Jens Axboe
2023-07-11 22:18 ` Jens Axboe
2023-07-14 15:47 ` Christian Brauner
2023-07-14 18:33 ` Arnd Bergmann
2023-07-14 20:14 ` Jens Axboe
2023-07-15 7:12 ` Arnd Bergmann
2023-07-15 14:06 ` Jens Axboe
2023-07-15 14:34 ` Jens Axboe
2023-07-15 20:23 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2023-08-02 23:14 [PATCHSET v2] Add io_uring support for waitid Jens Axboe
2023-08-02 23:14 ` [PATCH 4/5] exit: add internal include file with helpers Jens Axboe
2023-08-11 14:16 [PATCHSET v3 0/5] Add io_uring support for waitid Jens Axboe
2023-08-11 14:16 ` [PATCH 4/5] exit: add internal include file with helpers Jens Axboe
2023-09-09 15:11 [PATCHSET v4 0/5] Add io_uring support for waitid Jens Axboe
2023-09-09 15:11 ` [PATCH 4/5] exit: add internal include file with helpers Jens Axboe
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=20230714-lachen-gelassen-716cd90a9a0c@brauner \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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