tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/sched_ext/dsp_local_on.bpf.c- Extension
.c- Size
- 1582 bytes
- Lines
- 69
- 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
scx/common.bpf.h
Detected Declarations
function BPF_STRUCT_OPSfunction BPF_STRUCT_OPSfunction BPF_STRUCT_OPSfunction BPF_STRUCT_OPS
Annotated Snippet
#include <scx/common.bpf.h>
char _license[] SEC("license") = "GPL";
const volatile s32 nr_cpus;
UEI_DEFINE(uei);
struct {
__uint(type, BPF_MAP_TYPE_QUEUE);
__uint(max_entries, 8192);
__type(value, s32);
} queue SEC(".maps");
s32 BPF_STRUCT_OPS(dsp_local_on_select_cpu, struct task_struct *p,
s32 prev_cpu, u64 wake_flags)
{
return prev_cpu;
}
void BPF_STRUCT_OPS(dsp_local_on_enqueue, struct task_struct *p,
u64 enq_flags)
{
s32 pid = p->pid;
if (bpf_map_push_elem(&queue, &pid, 0))
scx_bpf_error("Failed to enqueue %s[%d]", p->comm, p->pid);
}
void BPF_STRUCT_OPS(dsp_local_on_dispatch, s32 cpu, struct task_struct *prev)
{
s32 pid, target;
struct task_struct *p;
if (bpf_map_pop_elem(&queue, &pid))
return;
p = bpf_task_from_pid(pid);
if (!p)
return;
if (p->nr_cpus_allowed == nr_cpus && !is_migration_disabled(p))
target = bpf_get_prandom_u32() % nr_cpus;
else
target = scx_bpf_task_cpu(p);
scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0);
bpf_task_release(p);
}
void BPF_STRUCT_OPS(dsp_local_on_exit, struct scx_exit_info *ei)
{
UEI_RECORD(uei, ei);
}
SEC(".struct_ops.link")
struct sched_ext_ops dsp_local_on_ops = {
.select_cpu = (void *) dsp_local_on_select_cpu,
.enqueue = (void *) dsp_local_on_enqueue,
.dispatch = (void *) dsp_local_on_dispatch,
.exit = (void *) dsp_local_on_exit,
.name = "dsp_local_on",
.timeout_ms = 1000U,
};
Annotation
- Immediate include surface: `scx/common.bpf.h`.
- Detected declarations: `function BPF_STRUCT_OPS`, `function BPF_STRUCT_OPS`, `function BPF_STRUCT_OPS`, `function BPF_STRUCT_OPS`.
- 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.