From: Tejun Heo <tj@kernel.org>
To: Emil Tsalapatis <emil@etsalapatis.com>
Cc: sched-ext@lists.linux.dev, changwoo@igalia.com,
arighi@nvidia.com, void@manifault.com
Subject: Re: [PATCH v2 3/3] tools/sched_ext: add arena based scheduler
Date: Thu, 15 Jan 2026 22:02:42 -1000 [thread overview]
Message-ID: <aWnwos_OWgMDPeXA@slm.duckdns.org> (raw)
In-Reply-To: <20260113164818.14305-4-emil@etsalapatis.com>
Hello,
On Tue, Jan 13, 2026 at 11:48:18AM -0500, Emil Tsalapatis wrote:
...
> +__hidden
> +int scx_alloc_free_idx(struct scx_allocator *alloc, __u64 idx)
> +{
> + const __u64 mask = (1 << SDT_TASK_ENTS_PER_PAGE_SHIFT) - 1;
> + sdt_desc_t *lv_desc[SDT_TASK_LEVELS];
> + sdt_desc_t * __arena *desc_children;
> + struct sdt_chunk __arena *chunk;
> + sdt_desc_t *desc;
> + struct sdt_data __arena *data;
> + __u64 level, shift, pos;
> + __u64 lv_pos[SDT_TASK_LEVELS];
> + int ret;
> + int i;
> +
> + if (!alloc)
> + return 0;
> +
> + desc = alloc->root;
> + if (unlikely(!desc))
> + return -EINVAL;
> +
> + /* To appease the verifier. */
> + for (level = zero; level < SDT_TASK_LEVELS && can_loop; level++) {
> + lv_desc[level] = NULL;
> + lv_pos[level] = 0;
> + }
> +
> + /* Find the leaf node containing the index. */
> + for (level = zero; level < SDT_TASK_LEVELS && can_loop; level++) {
> + shift = (SDT_TASK_LEVELS - 1 - level) * SDT_TASK_ENTS_PER_PAGE_SHIFT;
> + pos = (idx >> shift) & mask;
> +
> + lv_desc[level] = desc;
> + lv_pos[level] = pos;
> +
> + if (level == SDT_TASK_LEVELS - 1)
> + break;
> +
> + chunk = desc->chunk;
> +
> + desc_children = (sdt_desc_t * __arena *)chunk->descs;
> + desc = desc_children[pos];
> +
> + if (unlikely(!desc))
> + return -EINVAL;
> + }
> +
> + chunk = desc->chunk;
> +
> + pos = idx & mask;
> + data = chunk->data[pos];
> + if (likely(!data)) {
AI review flagged this. Should this be "if (likely(data)) {"?
> + data[pos] = (struct sdt_data) {
> + .tid.genn = data->tid.genn + 1,
> + };
> +
> + /* Zero out one word at a time. */
> + for (i = zero; i < alloc->pool.elem_size / 8 && can_loop; i++) {
> + data->payload[i] = 0;
> + }
> + }
Thanks.
--
tejun
next prev parent reply other threads:[~2026-01-16 8:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 16:48 [PATCH v2 0/3] tools/sched_ext: Add example C schedulers Emil Tsalapatis
2026-01-13 16:48 ` [PATCH v2 1/3] tools/sched_ext: add scx_userland scheduler Emil Tsalapatis
2026-01-13 16:48 ` [PATCH v2 2/3] tools/sched_ext: add scx_pair scheduler Emil Tsalapatis
2026-01-13 16:48 ` [PATCH v2 3/3] tools/sched_ext: add arena based scheduler Emil Tsalapatis
2026-01-16 8:02 ` Tejun Heo [this message]
2026-01-21 14:50 ` Emil Tsalapatis
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=aWnwos_OWgMDPeXA@slm.duckdns.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--cc=sched-ext@lists.linux.dev \
--cc=void@manifault.com \
/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