mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for NeilBrown" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: NeilBrown <neilb@suse.de>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched: add wait_var_event_io()
Date: Tue, 08 Oct 2024 07:56:21 -0000	[thread overview]
Message-ID: <172837418166.1442.8175035816812384640.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240925053405.3960701-7-neilb@suse.de>

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     80681c04c5e8e4297b9ebf201ca3ce6242aa16c3
Gitweb:        https://git.kernel.org/tip/80681c04c5e8e4297b9ebf201ca3ce6242aa16c3
Author:        NeilBrown <neilb@suse.de>
AuthorDate:    Wed, 25 Sep 2024 15:31:43 +10:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 07 Oct 2024 09:28:39 +02:00

sched: add wait_var_event_io()

It is not currently possible to wait wait_var_event for an io_schedule()
style wait.  This patch adds wait_var_event_io() for that purpose.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240925053405.3960701-7-neilb@suse.de
---
 include/linux/wait_bit.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h
index 6aea10e..6346e26 100644
--- a/include/linux/wait_bit.h
+++ b/include/linux/wait_bit.h
@@ -281,6 +281,9 @@ __out:	__ret;								\
 #define __wait_var_event(var, condition)				\
 	___wait_var_event(var, condition, TASK_UNINTERRUPTIBLE, 0, 0,	\
 			  schedule())
+#define __wait_var_event_io(var, condition)				\
+	___wait_var_event(var, condition, TASK_UNINTERRUPTIBLE, 0, 0,	\
+			  io_schedule())
 
 /**
  * wait_var_event - wait for a variable to be updated and notified
@@ -306,6 +309,34 @@ do {									\
 	__wait_var_event(var, condition);				\
 } while (0)
 
+/**
+ * wait_var_event_io - wait for a variable to be updated and notified
+ * @var: the address of variable being waited on
+ * @condition: the condition to wait for
+ *
+ * Wait for an IO related @condition to be true, only re-checking when a
+ * wake up is received for the given @var (an arbitrary kernel address
+ * which need not be directly related to the given condition, but
+ * usually is).
+ *
+ * The process will wait on a waitqueue selected by hash from a shared
+ * pool.  It will only be woken on a wake_up for the given address.
+ *
+ * This is similar to wait_var_event(), but calls io_schedule() instead
+ * of schedule().
+ *
+ * The condition should normally use smp_load_acquire() or a similarly
+ * ordered access to ensure that any changes to memory made before the
+ * condition became true will be visible after the wait completes.
+ */
+#define wait_var_event_io(var, condition)				\
+do {									\
+	might_sleep();							\
+	if (condition)							\
+		break;							\
+	__wait_var_event_io(var, condition);				\
+} while (0)
+
 #define __wait_var_event_killable(var, condition)			\
 	___wait_var_event(var, condition, TASK_KILLABLE, 0, 0,		\
 			  schedule())

  reply	other threads:[~2024-10-08  7:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25  5:31 [PATCH 0/7 v3] Make wake_up_{bit,var} less fragile NeilBrown
2024-09-25  5:31 ` [PATCH 1/7] sched: change wake_up_bit() and related function to expect unsigned long * NeilBrown
2024-10-08  7:56   ` [tip: sched/core] " tip-bot2 for NeilBrown
2024-09-25  5:31 ` [PATCH 2/7] sched: Improve documentation for wake_up_bit/wait_on_bit family of functions NeilBrown
2024-10-08  7:56   ` [tip: sched/core] " tip-bot2 for NeilBrown
2024-09-25  5:31 ` [PATCH 3/7] sched: Document wait_var_event() family of functions and wake_up_var() NeilBrown
2024-10-08  7:56   ` [tip: sched/core] " tip-bot2 for NeilBrown
2024-09-25  5:31 ` [PATCH 4/7] sched: Add test_and_clear_wake_up_bit() and atomic_dec_and_wake_up() NeilBrown
2024-10-08  7:56   ` [tip: sched/core] " tip-bot2 for NeilBrown
2024-09-25  5:31 ` [PATCH 5/7] sched: Add wait/wake interface for variable updated under a lock NeilBrown
2024-10-08  7:56   ` [tip: sched/core] " tip-bot2 for NeilBrown
2024-09-25  5:31 ` [PATCH 6/7] sched: add wait_var_event_io() NeilBrown
2024-10-08  7:56   ` tip-bot2 for NeilBrown [this message]
2024-09-25  5:31 ` [PATCH 7/7] softirq: use bit waits instead of var waits NeilBrown
2024-10-08  7:56   ` [tip: sched/core] " tip-bot2 for NeilBrown
2024-09-26 17:13 ` [PATCH 0/7 v3] Make wake_up_{bit,var} less fragile Thomas Gleixner
2024-09-26 21:14   ` NeilBrown

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=172837418166.1442.8175035816812384640.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=peterz@infradead.org \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®