[PATCH sched_ext/for-6.12-fixes] sched_ext: Fix enq_last_no_enq_fails selftest

Tejun Heo posted 1 patch 1 month ago
tools/testing/selftests/sched_ext/enq_last_no_enq_fails.bpf.c |    8 ++++++++
tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c     |   10 +++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
[PATCH sched_ext/for-6.12-fixes] sched_ext: Fix enq_last_no_enq_fails selftest
Posted by Tejun Heo 1 month ago
cc9877fb7677 ("sched_ext: Improve error reporting during loading") changed
how load failures are reported so that more error context can be
communicated. This breaks the enq_last_no_enq_fails test as attach no longer
fails. The scheduler is guaranteed to be ejected on attach completion with
full error information. Update enq_last_no_enq_fails so that it checks that
the scheduler is ejected using ops.exit().

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Vishal Chourasia <vishalc@linux.ibm.com>
Link: http://lkml.kernel.org/r/Zxknp7RAVNjmdJSc@linux.ibm.com
Fixes: cc9877fb7677 ("sched_ext: Improve error reporting during loading")
---
 tools/testing/selftests/sched_ext/enq_last_no_enq_fails.bpf.c |    8 ++++++++
 tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c     |   10 +++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.bpf.c b/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.bpf.c
index b0b99531d5d5..e1bd13e48889 100644
--- a/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.bpf.c
+++ b/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.bpf.c
@@ -12,10 +12,18 @@
 
 char _license[] SEC("license") = "GPL";
 
+u32 exit_kind;
+
+void BPF_STRUCT_OPS_SLEEPABLE(enq_last_no_enq_fails_exit, struct scx_exit_info *info)
+{
+	exit_kind = info->kind;
+}
+
 SEC(".struct_ops.link")
 struct sched_ext_ops enq_last_no_enq_fails_ops = {
 	.name			= "enq_last_no_enq_fails",
 	/* Need to define ops.enqueue() with SCX_OPS_ENQ_LAST */
 	.flags			= SCX_OPS_ENQ_LAST,
+	.exit			= (void *) enq_last_no_enq_fails_exit,
 	.timeout_ms		= 1000U,
 };
diff --git a/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c b/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c
index 2a3eda5e2c0b..73e679953e27 100644
--- a/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c
+++ b/tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c
@@ -31,8 +31,12 @@ static enum scx_test_status run(void *ctx)
 	struct bpf_link *link;
 
 	link = bpf_map__attach_struct_ops(skel->maps.enq_last_no_enq_fails_ops);
-	if (link) {
-		SCX_ERR("Incorrectly succeeded in to attaching scheduler");
+	if (!link) {
+		SCX_ERR("Incorrectly failed at attaching scheduler");
+		return SCX_TEST_FAIL;
+	}
+	if (!skel->bss->exit_kind) {
+		SCX_ERR("Incorrectly stayed loaded");
 		return SCX_TEST_FAIL;
 	}
 
@@ -50,7 +54,7 @@ static void cleanup(void *ctx)
 
 struct scx_test enq_last_no_enq_fails = {
 	.name = "enq_last_no_enq_fails",
-	.description = "Verify we fail to load a scheduler if we specify "
+	.description = "Verify we eject a scheduler if we specify "
 		       "the SCX_OPS_ENQ_LAST flag without defining "
 		       "ops.enqueue()",
 	.setup = setup,
Re: [PATCH sched_ext/for-6.12-fixes] sched_ext: Fix enq_last_no_enq_fails selftest
Posted by Tejun Heo 1 month ago
On Fri, Oct 25, 2024 at 12:19:06PM -1000, Tejun Heo wrote:
> cc9877fb7677 ("sched_ext: Improve error reporting during loading") changed
> how load failures are reported so that more error context can be
> communicated. This breaks the enq_last_no_enq_fails test as attach no longer
> fails. The scheduler is guaranteed to be ejected on attach completion with
> full error information. Update enq_last_no_enq_fails so that it checks that
> the scheduler is ejected using ops.exit().
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Vishal Chourasia <vishalc@linux.ibm.com>
> Link: http://lkml.kernel.org/r/Zxknp7RAVNjmdJSc@linux.ibm.com
> Fixes: cc9877fb7677 ("sched_ext: Improve error reporting during loading")

Applying to sched_ext/for-6.12-fixes.

Thanks.

-- 
tejun