kernel/sched/ext_cid.h
Source file repositories/reference/linux-study-clean/kernel/sched/ext_cid.h
File Facts
- System
- Linux kernel
- Corpus path
kernel/sched/ext_cid.h- Extension
.h- Size
- 9303 bytes
- Lines
- 272
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- 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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct scx_schedfunction scx_errorfunction __scx_cid_to_cpufunction __scx_cid_to_cpufunction scx_errorfunction scx_errorfunction scx_is_cid_typefunction __scx_cmask_containsfunction __scx_cmask_initfunction scx_cmask_initfunction scx_cmask_reframefunction __scx_cmask_setfunction scx_cmask_testfunction SCX_CMASK_NR_WORDS
Annotated Snippet
#ifndef _KERNEL_SCHED_EXT_CID_H
#define _KERNEL_SCHED_EXT_CID_H
struct scx_sched;
/*
* Cid space (total is always num_possible_cpus()) is laid out with
* topology-annotated cids first, then no-topo cids at the tail. The
* topology-annotated block covers the cpus that were online when scx_cid_init()
* ran and remains valid even after those cpus go offline. The tail block covers
* possible-but-not-online cpus and carries all-(-1) topo info (see
* scx_cid_topo); callers detect it via the -1 sentinels.
*
* See the comment above the table definitions in ext_cid.c for the
* memory-ordering and visibility contract.
*/
extern s16 *scx_cid_to_cpu_tbl;
extern s16 *scx_cpu_to_cid_tbl;
extern struct scx_cid_topo *scx_cid_topo;
extern struct btf_id_set8 scx_kfunc_ids_init;
void scx_cmask_clear(struct scx_cmask *m);
void scx_cmask_fill(struct scx_cmask *m);
void scx_cmask_and(struct scx_cmask *dst, const struct scx_cmask *src);
void scx_cmask_or(struct scx_cmask *dst, const struct scx_cmask *src);
void scx_cmask_or_racy(struct scx_cmask *dst, const struct scx_cmask *src);
void scx_cmask_copy(struct scx_cmask *dst, const struct scx_cmask *src);
void scx_cmask_copy_racy(struct scx_cmask *dst, const struct scx_cmask *src);
void scx_cmask_andnot(struct scx_cmask *dst, const struct scx_cmask *src);
bool scx_cmask_subset(const struct scx_cmask *sub, const struct scx_cmask *super);
bool scx_cmask_intersects(const struct scx_cmask *a, const struct scx_cmask *b);
bool scx_cmask_empty(const struct scx_cmask *m);
s32 scx_cid_init(struct scx_sched *sch);
int scx_cid_kfunc_init(void);
void scx_cpumask_to_cmask(const struct cpumask *src, struct scx_cmask *dst);
/**
* cid_valid - Verify a cid value, to be used on ops input args
* @sch: scx_sched to abort on error
* @cid: cid which came from a BPF ops
*
* Return true if @cid is in [0, num_possible_cpus()). On failure, trigger
* scx_error() and return false.
*/
static inline bool cid_valid(struct scx_sched *sch, s32 cid)
{
if (likely(cid >= 0 && cid < num_possible_cpus()))
return true;
scx_error(sch, "invalid cid %d", cid);
return false;
}
/**
* __scx_cid_to_cpu - Unchecked cid->cpu table lookup
* @cid: cid to look up. Must be in [0, num_possible_cpus()).
*
* Intended for callsites that have already validated @cid and that hold a
* non-NULL @sch from scx_prog_sched() - a live sched implies the table has
* been allocated, so no NULL check is needed here.
*/
static inline s32 __scx_cid_to_cpu(s32 cid)
{
/* READ_ONCE pairs with WRITE_ONCE in scx_cid_arrays_alloc() */
return READ_ONCE(scx_cid_to_cpu_tbl)[cid];
}
/**
* __scx_cpu_to_cid - Unchecked cpu->cid table lookup
* @cpu: cpu to look up. Must be a valid possible cpu id.
*
* Same usage constraints as __scx_cid_to_cpu().
*/
static inline s32 __scx_cpu_to_cid(s32 cpu)
{
return READ_ONCE(scx_cpu_to_cid_tbl)[cpu];
}
/**
* scx_cid_to_cpu - Translate @cid to its cpu
* @sch: scx_sched for error reporting
* @cid: cid to look up
*
* Return the cpu for @cid or a negative errno on failure. Invalid cid triggers
* scx_error() on @sch. The cid arrays are allocated on first scheduler enable
* and never freed, so the returned cpu is stable for the lifetime of the loaded
* scheduler.
*/
static inline s32 scx_cid_to_cpu(struct scx_sched *sch, s32 cid)
{
if (!cid_valid(sch, cid))
Annotation
- Detected declarations: `struct scx_sched`, `function scx_error`, `function __scx_cid_to_cpu`, `function __scx_cid_to_cpu`, `function scx_error`, `function scx_error`, `function scx_is_cid_type`, `function __scx_cmask_contains`, `function __scx_cmask_init`, `function scx_cmask_init`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.