Re: [PATCH sched_ext/for-7.2] sched_ext: add p->scx.tid and SCX_OPS_TID_TO_TASK lookup

Andrea Righi
2026-04-19T18:31:42Z

On Sun, Apr 19, 2026 at 08:12:02AM -1000, Tejun Heo wrote:
> Hello,
>
> On Sun, Apr 19, 2026 at 07:02:47PM +0200, Andrea Righi wrote:
> > I'm wondering if we should have a teardown function, called before disabling
> > SCX_OPS_TID_TO_TASK and destroying scx_tid_hash, to explicitly remove all the
> > scx_tid_hash entries via rhashtable_remove_fast().
>
> rhashtable_remove_fast() doesn't clear tid_hash_node.next either - it
> just unlinks from the bucket chain, leaving obj->next at whatever the
> chain successor or nulls-marker put there. So explicit drain wouldn't
> give us a cleaner post-state.
>
> And the stale pointer is never read. After the static key is disabled,
> scx_post_fork/sched_ext_dead/scx_bpf_tid_to_task all gate on the key and
> skip the hash. On re-enable, rhashtable_init() creates fresh buckets and
> task iteration re-inserts each live task via
> rhashtable_lookup_insert_fast(), which unconditionally does
>
> RCU_INIT_POINTER(obj->next, head);
>
> at include/linux/rhashtable.h:838. Lookups always traverse from
> ht->tbl[hash], never from an embedded node.

Ah, I missed the unconditional re-init, then we should be fine.
Thanks for clarifying it.

-Andrea