include/linux/sched/ext.h

Source file repositories/reference/linux-study-clean/include/linux/sched/ext.h

File Facts

System
Linux kernel
Corpus path
include/linux/sched/ext.h
Extension
.h
Size
9177 bytes
Lines
290
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct scx_deferred_reenq_user {
	struct list_head	node;
	u64			flags;
};

struct scx_dsq_pcpu {
	struct scx_dispatch_q	*dsq;
	struct scx_deferred_reenq_user deferred_reenq_user;
};

/*
 * A dispatch queue (DSQ) can be either a FIFO or p->scx.dsq_vtime ordered
 * queue. A built-in DSQ is always a FIFO. The built-in local DSQs are used to
 * buffer between the scheduler core and the BPF scheduler. See the
 * documentation for more details.
 */
struct scx_dispatch_q {
	raw_spinlock_t		lock;
	struct task_struct __rcu *first_task; /* lockless peek at head */
	struct list_head	list;	/* tasks in dispatch order */
	struct rb_root		priq;	/* used to order by p->scx.dsq_vtime */
	u32			nr;
	u32			seq;	/* used by BPF iter */
	u64			id;
	struct rhash_head	hash_node;
	struct llist_node	free_node;
	struct scx_sched	*sched;
	struct scx_dsq_pcpu __percpu *pcpu;
	struct rcu_head		rcu;
};

/* sched_ext_entity.flags */
enum scx_ent_flags {
	SCX_TASK_QUEUED		= 1 << 0, /* on ext runqueue */
	SCX_TASK_IN_CUSTODY	= 1 << 1, /* in custody, needs ops.dequeue() when leaving */
	SCX_TASK_RESET_RUNNABLE_AT = 1 << 2, /* runnable_at should be reset */
	SCX_TASK_DEQD_FOR_SLEEP	= 1 << 3, /* last dequeue was for SLEEP */
	SCX_TASK_SUB_INIT	= 1 << 4, /* task being initialized for a sub sched */
	SCX_TASK_IMMED		= 1 << 5, /* task is on local DSQ with %SCX_ENQ_IMMED */

	/*
	 * Bits 8 to 10 are used to carry task state:
	 *
	 * NONE		ops.init_task() not called yet
	 * INIT_BEGIN	ops.init_task() in flight; see sched_ext_dead()
	 * INIT		ops.init_task() succeeded, but task can be cancelled
	 * READY	fully initialized, but not in sched_ext
	 * ENABLED	fully initialized and in sched_ext
	 * DEAD		terminal state set by sched_ext_dead()
	 */
	SCX_TASK_STATE_SHIFT	= 8,
	SCX_TASK_STATE_BITS	= 3,
	SCX_TASK_STATE_MASK	= ((1 << SCX_TASK_STATE_BITS) - 1) << SCX_TASK_STATE_SHIFT,

	SCX_TASK_NONE		= 0 << SCX_TASK_STATE_SHIFT,
	SCX_TASK_INIT_BEGIN	= 1 << SCX_TASK_STATE_SHIFT,
	SCX_TASK_INIT		= 2 << SCX_TASK_STATE_SHIFT,
	SCX_TASK_READY		= 3 << SCX_TASK_STATE_SHIFT,
	SCX_TASK_ENABLED	= 4 << SCX_TASK_STATE_SHIFT,
	SCX_TASK_DEAD		= 5 << SCX_TASK_STATE_SHIFT,

	/*
	 * Bits 12 and 13 are used to carry reenqueue reason. In addition to
	 * %SCX_ENQ_REENQ flag, ops.enqueue() can also test for
	 * %SCX_TASK_REENQ_REASON_NONE to distinguish reenqueues.
	 *
	 * NONE		not being reenqueued
	 * KFUNC	reenqueued by scx_bpf_dsq_reenq() and friends
	 * IMMED	reenqueued due to failed ENQ_IMMED
	 * PREEMPTED	preempted while running
	 */
	SCX_TASK_REENQ_REASON_SHIFT = 12,
	SCX_TASK_REENQ_REASON_BITS = 2,
	SCX_TASK_REENQ_REASON_MASK = ((1 << SCX_TASK_REENQ_REASON_BITS) - 1) << SCX_TASK_REENQ_REASON_SHIFT,

	SCX_TASK_REENQ_NONE	= 0 << SCX_TASK_REENQ_REASON_SHIFT,
	SCX_TASK_REENQ_KFUNC	= 1 << SCX_TASK_REENQ_REASON_SHIFT,
	SCX_TASK_REENQ_IMMED	= 2 << SCX_TASK_REENQ_REASON_SHIFT,
	SCX_TASK_REENQ_PREEMPTED = 3 << SCX_TASK_REENQ_REASON_SHIFT,

	/* iteration cursor, not a task */
	SCX_TASK_CURSOR		= 1 << 31,
};

/* scx_entity.dsq_flags */
enum scx_ent_dsq_flags {
	SCX_TASK_DSQ_ON_PRIQ	= 1 << 0, /* task is queued on the priority queue of a dsq */
};

enum scx_dsq_lnode_flags {

Annotation

Implementation Notes