[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230517152654.7193-3-mathieu.desnoyers@efficios.com>
Date: Wed, 17 May 2023 11:26:52 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
"Paul E . McKenney" <paulmck@...nel.org>,
Boqun Feng <boqun.feng@...il.com>,
"H . Peter Anvin" <hpa@...or.com>, Paul Turner <pjt@...gle.com>,
linux-api@...r.kernel.org, Christian Brauner <brauner@...nel.org>,
Florian Weimer <fw@...eb.enyo.de>, David.Laight@...LAB.COM,
carlos@...hat.com, Peter Oskolkov <posk@...k.io>,
Alexander Mikhalitsyn <alexander@...alicyn.com>,
Chris Kennelly <ckennelly@...gle.com>,
Ingo Molnar <mingo@...hat.com>,
Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>,
André Almeida <andrealmeid@...lia.com>,
libc-alpha@...rceware.org, Steven Rostedt <rostedt@...dmis.org>,
Jonathan Corbet <corbet@....net>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: [RFC PATCH 2/4] selftests/rseq: Add sched_state rseq field and getter
Extend struct rseq in the rseq selftests to include the sched_state
field. Implement a getter function for this field.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
---
tools/testing/selftests/rseq/rseq-abi.h | 17 +++++++++++++++++
tools/testing/selftests/rseq/rseq.h | 5 +++++
2 files changed, 22 insertions(+)
diff --git a/tools/testing/selftests/rseq/rseq-abi.h b/tools/testing/selftests/rseq/rseq-abi.h
index fb4ec8a75dd4..15ec333e9eec 100644
--- a/tools/testing/selftests/rseq/rseq-abi.h
+++ b/tools/testing/selftests/rseq/rseq-abi.h
@@ -37,6 +37,13 @@ enum rseq_abi_cs_flags {
(1U << RSEQ_ABI_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT),
};
+enum rseq_sched_state {
+ /*
+ * Task is currently running on a CPU if bit is set.
+ */
+ RSEQ_SCHED_STATE_ON_CPU = (1U << 0),
+};
+
/*
* struct rseq_abi_cs is aligned on 4 * 8 bytes to ensure it is always
* contained within a single cache-line. It is usually declared as
@@ -164,6 +171,16 @@ struct rseq_abi {
*/
__u32 mm_cid;
+ /*
+ * Restartable sequences sched_state field. Updated by the kernel. Read
+ * by user-space with single-copy atomicity semantics. This fields can
+ * be read by any userspace thread. Aligned on 32-bit. Contains a
+ * bitmask of enum rseq_sched_state. This field is provided as a hint
+ * by the scheduler, and requires that the page holding struct rseq is
+ * faulted-in for the state update to be performed by the scheduler.
+ */
+ __u32 sched_state;
+
/*
* Flexible array member at end of structure, after last feature field.
*/
diff --git a/tools/testing/selftests/rseq/rseq.h b/tools/testing/selftests/rseq/rseq.h
index d7364ea4d201..348e9385cb2b 100644
--- a/tools/testing/selftests/rseq/rseq.h
+++ b/tools/testing/selftests/rseq/rseq.h
@@ -236,6 +236,11 @@ static inline void rseq_prepare_unload(void)
rseq_clear_rseq_cs();
}
+static inline uint32_t rseq_current_sched_state(void)
+{
+ return RSEQ_ACCESS_ONCE(rseq_get_abi()->sched_state);
+}
+
static inline __attribute__((always_inline))
int rseq_cmpeqv_storev(enum rseq_mo rseq_mo, enum rseq_percpu_mode percpu_mode,
intptr_t *v, intptr_t expect,
--
2.25.1
Powered by blists - more mailing lists