Re: [PATCH v2 12/14] sched_ext: Factor out scx_dsq_list_node cursor initialization into INIT_DSQ_LIST_CURSOR

Emil Tsalapatis
2025-11-10T23:56:59Z

On Mon, Nov 10, 2025 at 3:56 PM Tejun Heo <tj@kernel.org> wrote:
>
> Factor out scx_dsq_list_node cursor initialization into INIT_DSQ_LIST_CURSOR
> macro in preparation for additional users.
>
> Cc: Dan Schatzberg <schatzberg.dan@gmail.com>
> Cc: Emil Tsalapatis <etsal@meta.com>
> Acked-by: Andrea Righi <arighi@nvidia.com>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>

> include/linux/sched/ext.h | 7 +++++++
> kernel/sched/ext.c | 5 ++---
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h
> index 4b501ad7a3fc..3f6bf2875431 100644
> --- a/include/linux/sched/ext.h
> +++ b/include/linux/sched/ext.h
> @@ -149,6 +149,13 @@ struct scx_dsq_list_node {
> u32 priv; /* can be used by iter cursor */
> };
>
> +#define INIT_DSQ_LIST_CURSOR(__node, __flags, __priv) \
> + (struct scx_dsq_list_node) { \
> + .node = LIST_HEAD_INIT((__node).node), \
> + .flags = SCX_DSQ_LNODE_ITER_CURSOR | (__flags), \
> + .priv = (__priv), \
> + }
> +
> /*
> * The following is embedded in task_struct and contains all fields necessary
> * for a task to be scheduled by SCX.
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index d16525abf9e0..82f0d2202b99 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -6249,9 +6249,8 @@ __bpf_kfunc int bpf_iter_scx_dsq_new(struct bpf_iter_scx_dsq *it, u64 dsq_id,
> if (!kit->dsq)
> return -ENOENT;
>
> - INIT_LIST_HEAD(&kit->cursor.node);
> - kit->cursor.flags = SCX_DSQ_LNODE_ITER_CURSOR | flags;
> - kit->cursor.priv = READ_ONCE(kit->dsq->seq);
> + kit->cursor = INIT_DSQ_LIST_CURSOR(kit->cursor, flags,
> + READ_ONCE(kit->dsq->seq));
>
> return 0;
> }
> --
> 2.51.2
>
>