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 <[email protected]>
---
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
Hello,
kernel test robot noticed "kernel-selftests.kvm.make.fail" on:
commit: 1f70aced56e5ae7bcdaba5f55ff62e610c105089 ("[RFC PATCH 2/4] selftests/rseq: Add sched_state rseq field and getter")
url: https://github.com/intel-lab-lkp/linux/commits/Mathieu-Desnoyers/rseq-Add-sched_state-field-to-struct-rseq/20230517-233229
base: https://git.kernel.org/cgit/linux/kernel/git/shuah/linux-kselftest.git next
patch link: https://lore.kernel.org/all/[email protected]/
patch subject: [RFC PATCH 2/4] selftests/rseq: Add sched_state rseq field and getter
in testcase: kernel-selftests
version: kernel-selftests-x86_64-60acb023-1_20230329
with following parameters:
group: kvm
test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
compiler: gcc-11
test machine: 224 threads 2 sockets Intel(R) Xeon(R) Platinum 8480+ (Sapphire Rapids) with 256G memory
(please refer to attached dmesg/kmsg for entire log/backtrace)
If you fix the issue, kindly add following tag
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-lkp/[email protected]
In file included from ../rseq/rseq.h:20,
from ../rseq/rseq.c:35,
from rseq_test.c:23:
../rseq/rseq-abi.h:40:6: error: redeclaration of ‘enum rseq_sched_state’
40 | enum rseq_sched_state {
| ^~~~~~~~~~~~~~~~
In file included from rseq_test.c:16:
/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/usr/include/linux/rseq.h:40:6: note: originally defined here
40 | enum rseq_sched_state {
| ^~~~~~~~~~~~~~~~
../rseq/rseq-abi.h:44:9: error: redeclaration of enumerator ‘RSEQ_SCHED_STATE_ON_CPU’
44 | RSEQ_SCHED_STATE_ON_CPU = (1U << 0),
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/usr/include/linux/rseq.h:44:9: note: previous definition of ‘RSEQ_SCHED_STATE_ON_CPU’ with type ‘enum rseq_sched_state’
44 | RSEQ_SCHED_STATE_ON_CPU = (1U << 0),
| ^~~~~~~~~~~~~~~~~~~~~~~
cc1: note: unrecognized command-line option ‘-Wno-gnu-variable-sized-type-not-at-end’ may have been intended to silence earlier diagnostics
make: *** [../lib.mk:147: /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/rseq_test] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm'
2023-05-27 01:58:33 make quicktest=1 run_tests -C kvm
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm'
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -Wno-gnu-variable-sized-type-not-at-end -fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset -fno-stack-protector -fno-PIE -I/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/../../../tools/include -I/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/../../../tools/arch/x86/include -I/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/../../../usr/include/ -Iinclude -I. -Iinclude/x86_64 -I ../rseq -I.. -isystem /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/../../../usr/include -pthread -no-pie rseq_test.c /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/assert.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/elf.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/guest_modes.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/io.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/kvm_util.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/memstress.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/rbtree.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/sparsebit.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/test_util.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/ucall_common.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/userfaultfd_util.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/apic.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/hyperv.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/memstress.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/processor.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/svm.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/ucall.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/vmx.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/x86_64/handlers.o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/lib/string_override.o -ldl -o /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/rseq_test
In file included from ../rseq/rseq.h:20,
from ../rseq/rseq.c:35,
from rseq_test.c:23:
../rseq/rseq-abi.h:40:6: error: redeclaration of ‘enum rseq_sched_state’
40 | enum rseq_sched_state {
| ^~~~~~~~~~~~~~~~
In file included from rseq_test.c:16:
/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/usr/include/linux/rseq.h:40:6: note: originally defined here
40 | enum rseq_sched_state {
| ^~~~~~~~~~~~~~~~
../rseq/rseq-abi.h:44:9: error: redeclaration of enumerator ‘RSEQ_SCHED_STATE_ON_CPU’
44 | RSEQ_SCHED_STATE_ON_CPU = (1U << 0),
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/usr/include/linux/rseq.h:44:9: note: previous definition of ‘RSEQ_SCHED_STATE_ON_CPU’ with type ‘enum rseq_sched_state’
44 | RSEQ_SCHED_STATE_ON_CPU = (1U << 0),
| ^~~~~~~~~~~~~~~~~~~~~~~
cc1: note: unrecognized command-line option ‘-Wno-gnu-variable-sized-type-not-at-end’ may have been intended to silence earlier diagnostics
make: *** [../lib.mk:147: /usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm/rseq_test] Error 1
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-8.3-kvm-1f70aced56e5ae7bcdaba5f55ff62e610c105089/tools/testing/selftests/kvm'
To reproduce:
git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
sudo bin/lkp install job.yaml # job file is attached in this email
bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run
sudo bin/lkp run generated-yaml-file
# if come across any failure that blocks the test,
# please remove ~/.lkp and /lkp dir to run from a clean state.
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki