Skip to content

KFunc scx_bpf_tid_to_task

v7.2

Look up a task by its SCX task ID.

Definition

Unavailable if sched_ext_ops.update_idle is implemented and SCX_OPS_KEEP_BUILTIN_IDLE is not set.

Parameters

tid: task ID previously read from p->scx.tid

Returns

The task with the given tid, or NULL if no such task exists. The returned pointer is valid until the end of the current RCU read section (KF_RCU_PROTECTED). Requires SCX_OPS_TID_TO_TASK to be set on the root scheduler; otherwise an error is raised and NULL returned.

Signature

struct task_struct *scx_bpf_tid_to_task(u64 tid)

Note

The pointer returned by the kfunc may be NULL. Hence, it forces the user to do a NULL check on the pointer returned from the kfunc before making use of it (dereferencing or passing to another helper).

Note

This kfunc is RCU protected. This means that the kfunc can be called from RCU read-side critical section. If a program isn't called from RCU read-side critical section, such as sleepable programs, the bpf_rcu_read_lock and bpf_rcu_read_unlock to protect the calls to such KFuncs.

Usage

Docs could be improved

This part of the docs is incomplete, contributions are very welcome

Program types

The following program types can make use of this kfunc:

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome