tools/testing/selftests/sched_ext/hotplug.bpf.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/sched_ext/hotplug.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/sched_ext/hotplug.bpf.c- Extension
.c- Size
- 1348 bytes
- Lines
- 62
- 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.hhotplug_test.h
Detected Declarations
function BPF_STRUCT_OPSfunction exit_from_hotplugfunction BPF_STRUCT_OPS_SLEEPABLEfunction BPF_STRUCT_OPS_SLEEPABLE
Annotated Snippet
#include <scx/common.bpf.h>
char _license[] SEC("license") = "GPL";
#include "hotplug_test.h"
UEI_DEFINE(uei);
void BPF_STRUCT_OPS(hotplug_exit, struct scx_exit_info *ei)
{
UEI_RECORD(uei, ei);
}
static void exit_from_hotplug(s32 cpu, bool onlining)
{
/*
* Ignored, just used to verify that we can invoke blocking kfuncs
* from the hotplug path.
*/
scx_bpf_create_dsq(0, -1);
s64 code = SCX_ECODE_ACT_RESTART | HOTPLUG_EXIT_RSN;
if (onlining)
code |= HOTPLUG_ONLINING;
scx_bpf_exit(code, "hotplug event detected (%d going %s)", cpu,
onlining ? "online" : "offline");
}
void BPF_STRUCT_OPS_SLEEPABLE(hotplug_cpu_online, s32 cpu)
{
exit_from_hotplug(cpu, true);
}
void BPF_STRUCT_OPS_SLEEPABLE(hotplug_cpu_offline, s32 cpu)
{
exit_from_hotplug(cpu, false);
}
SEC(".struct_ops.link")
struct sched_ext_ops hotplug_cb_ops = {
.cpu_online = (void *) hotplug_cpu_online,
.cpu_offline = (void *) hotplug_cpu_offline,
.exit = (void *) hotplug_exit,
.name = "hotplug_cbs",
.timeout_ms = 1000U,
};
SEC(".struct_ops.link")
struct sched_ext_ops hotplug_nocb_ops = {
.exit = (void *) hotplug_exit,
.name = "hotplug_nocbs",
.timeout_ms = 1000U,
};
Annotation
- Immediate include surface: `scx/common.bpf.h`, `hotplug_test.h`.
- Detected declarations: `function BPF_STRUCT_OPS`, `function exit_from_hotplug`, `function BPF_STRUCT_OPS_SLEEPABLE`, `function BPF_STRUCT_OPS_SLEEPABLE`.
- 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.