From: Christian Loehle <christian.loehle@arm.com>
To: Ryan Newton <rrnewton@gmail.com>, linux-kernel@vger.kernel.org
Cc: sched-ext@lists.linux.dev, tj@kernel.org, arighi@nvidia.com,
newton@meta.com
Subject: Re: [PATCH v3 2/2] sched_ext: Add a selftest for scx_bpf_dsq_peek
Date: Mon, 6 Oct 2025 18:17:50 +0100 [thread overview]
Message-ID: <54151879-f2bd-4e87-b5b5-5e916ee1e743@arm.com> (raw)
In-Reply-To: <20251006170403.3584204-3-rrnewton@gmail.com>
On 10/6/25 18:04, Ryan Newton wrote:
> From: Ryan Newton <newton@meta.com>
>
> Perform the most basic unit test: make sure an empty queue peeks as
> empty, and when we put one element in the queue, make sure peek returns
> that element.
>
> However, even this simple test is a little complicated by the different
> behavior of scx_bpf_dsq_insert in different calling contexts:
> - insert is for direct dispatch in enqueue
> - insert is delayed when called from select_cpu
>
> In this case we split the insert and the peek that verifies the
> result between enqueue/dispatch. As a second phase, we stress test by
> performing many peeks on an array of user DSQs.
>
> Note: An alternative would be to call `scx_bpf_dsq_move_to_local` on an
> empty queue, which in turn calls `flush_dispatch_buf`, in order to flush
> the buffered insert. Unfortunately, this is not viable within the
> enqueue path, as it attempts a voluntary context switch within an RCU
> read-side critical section.
>
> Signed-off-by: Ryan Newton <newton@meta.com>
> ---
> kernel/sched/ext.c | 2 +
> tools/testing/selftests/sched_ext/Makefile | 1 +
> .../selftests/sched_ext/peek_dsq.bpf.c | 265 ++++++++++++++++++
> tools/testing/selftests/sched_ext/peek_dsq.c | 230 +++++++++++++++
> 4 files changed, 498 insertions(+)
> create mode 100644 tools/testing/selftests/sched_ext/peek_dsq.bpf.c
> create mode 100644 tools/testing/selftests/sched_ext/peek_dsq.c
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 6d3537e65001..ec7e791cd4c8 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -6120,6 +6120,7 @@ __bpf_kfunc struct task_struct *scx_bpf_dsq_peek(u64 dsq_id)
> sch = rcu_dereference(scx_root);
> if (unlikely(!sch))
> return NULL;
> +
Accidental whitespace
> if (unlikely(dsq_id & SCX_DSQ_FLAG_BUILTIN)) {
> scx_error(sch, "peek disallowed on builtin DSQ 0x%llx", dsq_id);
> return NULL;
> @@ -6130,6 +6131,7 @@ __bpf_kfunc struct task_struct *scx_bpf_dsq_peek(u64 dsq_id)
> scx_error(sch, "peek on non-existent DSQ 0x%llx", dsq_id);
> return NULL;
> }
> +
Accidental whitespace
> return rcu_dereference(dsq->first_task);
> }
> [snip]
next prev parent reply other threads:[~2025-10-06 17:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-06 17:04 [PATCH v3 0/2] sched_ext: lockless peek operation for DSQs Ryan Newton
2025-10-06 17:04 ` [PATCH v3 1/2] sched_ext: Add " Ryan Newton
2025-10-06 17:26 ` Andrea Righi
2025-10-14 22:27 ` Jake Hillion
2025-10-06 17:04 ` [PATCH v3 2/2] sched_ext: Add a selftest for scx_bpf_dsq_peek Ryan Newton
2025-10-06 17:17 ` Christian Loehle [this message]
2025-10-06 17:22 ` Andrea Righi
2025-10-06 19:36 ` Andrea Righi
2025-10-06 17:20 ` [PATCH v3 0/2] sched_ext: lockless peek operation for DSQs Christian Loehle
2025-10-06 17:34 ` Ryan Newton
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=54151879-f2bd-4e87-b5b5-5e916ee1e743@arm.com \
--to=christian.loehle@arm.com \
--cc=arighi@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=newton@meta.com \
--cc=rrnewton@gmail.com \
--cc=sched-ext@lists.linux.dev \
--cc=tj@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®