All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: brauner@kernel.org, arnd@arndb.de, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 1/5] exit: abtract out should_wake helper for child_wait_callback()
Date: Tue, 11 Jul 2023 14:43:48 -0600	[thread overview]
Message-ID: <20230711204352.214086-2-axboe@kernel.dk> (raw)
In-Reply-To: <20230711204352.214086-1-axboe@kernel.dk>

Abstract out the helper that decides if we should wake up following
a wake_up() callback on our internal waitqueue.

No functional changes intended in this patch.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/exit.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index edb50b4c9972..2809dad69492 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1520,6 +1520,17 @@ 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)
+{
+	if (!eligible_pid(wo, p))
+		return false;
+
+	if ((wo->wo_flags & __WNOTHREAD) && wo->child_wait.private != p->parent)
+		return false;
+
+	return true;
+}
+
 static int child_wait_callback(wait_queue_entry_t *wait, unsigned mode,
 				int sync, void *key)
 {
@@ -1527,13 +1538,10 @@ static int child_wait_callback(wait_queue_entry_t *wait, unsigned mode,
 						child_wait);
 	struct task_struct *p = key;
 
-	if (!eligible_pid(wo, p))
-		return 0;
+	if (pid_child_should_wake(wo, p))
+		return default_wake_function(wait, mode, sync, key);
 
-	if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)
-		return 0;
-
-	return default_wake_function(wait, mode, sync, key);
+	return 0;
 }
 
 void __wake_up_parent(struct task_struct *p, struct task_struct *parent)
-- 
2.40.1


  reply	other threads:[~2023-07-11 20:44 UTC|newest]

Thread overview: 22+ 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 ` Jens Axboe [this message]
2023-07-14 15:31   ` [PATCH 1/5] exit: abtract out should_wake helper for child_wait_callback() 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
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 1/5] exit: abtract out should_wake helper for child_wait_callback() 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=20230711204352.214086-2-axboe@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.