tools/testing/selftests/bpf/prog_tests/timer_start_delete_race.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/timer_start_delete_race.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/timer_start_delete_race.c- Extension
.c- Size
- 3217 bytes
- Lines
- 138
- 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
sched.hpthread.htest_progs.htimer_start_delete_race.skel.h
Detected Declarations
struct ctxfunction test_timer_start_delete_race
Annotated Snippet
struct ctx {
struct timer_start_delete_race *skel;
volatile bool start;
volatile bool stop;
int errors;
};
static void *start_timer_thread(void *arg)
{
struct ctx *ctx = arg;
cpu_set_t cpuset;
int fd, i;
CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
while (!ctx->start && !ctx->stop)
usleep(1);
if (ctx->stop)
return NULL;
fd = bpf_program__fd(ctx->skel->progs.start_timer);
for (i = 0; i < ITERATIONS && !ctx->stop; i++) {
LIBBPF_OPTS(bpf_test_run_opts, opts);
int err;
err = bpf_prog_test_run_opts(fd, &opts);
if (err || opts.retval) {
ctx->errors++;
break;
}
}
return NULL;
}
static void *delete_elem_thread(void *arg)
{
struct ctx *ctx = arg;
cpu_set_t cpuset;
int fd, i;
CPU_ZERO(&cpuset);
CPU_SET(1, &cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
while (!ctx->start && !ctx->stop)
usleep(1);
if (ctx->stop)
return NULL;
fd = bpf_program__fd(ctx->skel->progs.delete_elem);
for (i = 0; i < ITERATIONS && !ctx->stop; i++) {
LIBBPF_OPTS(bpf_test_run_opts, opts);
int err;
err = bpf_prog_test_run_opts(fd, &opts);
if (err || opts.retval) {
ctx->errors++;
break;
}
}
return NULL;
}
void test_timer_start_delete_race(void)
{
struct timer_start_delete_race *skel;
pthread_t threads[2];
struct ctx ctx = {};
int err;
skel = timer_start_delete_race__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel_open_and_load"))
return;
ctx.skel = skel;
err = pthread_create(&threads[0], NULL, start_timer_thread, &ctx);
if (!ASSERT_OK(err, "create start_timer_thread")) {
ctx.stop = true;
goto cleanup;
}
err = pthread_create(&threads[1], NULL, delete_elem_thread, &ctx);
if (!ASSERT_OK(err, "create delete_elem_thread")) {
Annotation
- Immediate include surface: `sched.h`, `pthread.h`, `test_progs.h`, `timer_start_delete_race.skel.h`.
- Detected declarations: `struct ctx`, `function test_timer_start_delete_race`.
- 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.