tools/sched_ext/include/scx/cid.bpf.h
Source file repositories/reference/linux-study-clean/tools/sched_ext/include/scx/cid.bpf.h
File Facts
- System
- Linux kernel
- Corpus path
tools/sched_ext/include/scx/cid.bpf.h- Extension
.h- Size
- 17176 bytes
- Lines
- 679
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
bpf_arena_common.bpf.h
Detected Declarations
function Copyrightfunction __cmask_initfunction bpf_forfunction cmask_initfunction cmask_reframefunction cmask_testfunction pointersfunction cmask_clearfunction cmask_test_and_setfunction cmask_test_and_clearfunction __cmask_setfunction __cmask_clearfunction __cmask_test_and_setfunction __cmask_test_and_clearfunction cmask_zerofunction bpf_forfunction cmask_op_wordfunction cmask_opfunction bpf_forfunction cmask_andfunction cmask_orfunction cmask_copyfunction cmask_andnotfunction cmask_equalfunction bpf_forfunction cmask_subsetfunction cmask_for_eachfunction bpf_forfunction cmask_first_setfunction cmask_weightfunction bpf_forfunction cmask_intersectsfunction bpf_forfunction cmask_next_and_set_wrapfunction bpf_forfunction cmask_next_set_wrapfunction cmask_next_and_set_wrapfunction cmask_from_cpumask
Annotated Snippet
#ifndef __SCX_CID_BPF_H
#define __SCX_CID_BPF_H
#include "bpf_arena_common.bpf.h"
#ifndef BIT_U64
#define BIT_U64(nr) (1ULL << (nr))
#endif
#ifndef GENMASK_U64
#define GENMASK_U64(h, l) ((~0ULL << (l)) & (~0ULL >> (63 - (h))))
#endif
/*
* Storage cap for bounded loops over bits[]. Sized to cover NR_CPUS=8192 with
* one extra word for head-misalignment. Increase if deployment targets larger
* NR_CPUS.
*/
#ifndef CMASK_MAX_WORDS
#define CMASK_MAX_WORDS 129
#endif
/*
* Mirrors SCX_CMASK_NR_WORDS in kernel/sched/ext_types.h. The u64 cast keeps
* the +63 from wrapping when @nr_cids is near U32_MAX, so cmask_reframe()
* bounds-checking the result against alloc_words catches the overflow instead
* of seeing a small value.
*/
#define CMASK_NR_WORDS(nr_cids) ((u32)(((u64)(nr_cids) + 63) / 64 + 1))
static __always_inline bool __cmask_contains(u32 cid, const struct scx_cmask __arena *m)
{
return cid >= m->base && cid < m->base + m->nr_cids;
}
static __always_inline u64 __arena *__cmask_word(u32 cid, const struct scx_cmask __arena *m)
{
return (u64 __arena *)&m->bits[cid / 64 - m->base / 64];
}
/**
* __cmask_init - Initialize @m with explicit storage capacity
* @m: cmask to initialize
* @base: first cid of the active range
* @nr_cids: number of cids in the active range
* @alloc_cids: storage capacity in cids, at least @nr_cids
*
* Use when storage is sized larger than the initial active range. All of
* bits[] is zeroed.
*/
static __always_inline void __cmask_init(struct scx_cmask __arena *m, u32 base,
u32 nr_cids, u32 alloc_cids)
{
u32 alloc_words, i;
if (unlikely(nr_cids > alloc_cids)) {
scx_bpf_error("__cmask_init: nr_cids=%u exceeds alloc_cids=%u",
nr_cids, alloc_cids);
return;
}
alloc_words = CMASK_NR_WORDS(alloc_cids);
m->base = base;
m->nr_cids = nr_cids;
m->alloc_words = alloc_words;
bpf_for(i, 0, CMASK_MAX_WORDS) {
if (i >= alloc_words)
break;
m->bits[i] = 0;
}
}
/**
* cmask_init - Initialize @m on tight storage
* @m: cmask to initialize
* @base: first cid of the active range
* @nr_cids: number of cids in the active range
*
* All of bits[] is zeroed.
*/
static __always_inline void cmask_init(struct scx_cmask __arena *m, u32 base, u32 nr_cids)
{
__cmask_init(m, base, nr_cids, nr_cids);
}
/**
* cmask_reframe - Reshape @m's active range without resizing storage
* @m: cmask to reframe
* @base: new active range base
* @nr_cids: new active range length, must fit within @m->alloc_words
Annotation
- Immediate include surface: `bpf_arena_common.bpf.h`.
- Detected declarations: `function Copyright`, `function __cmask_init`, `function bpf_for`, `function cmask_init`, `function cmask_reframe`, `function cmask_test`, `function pointers`, `function cmask_clear`, `function cmask_test_and_set`, `function cmask_test_and_clear`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.