tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c- Extension
.c- Size
- 13249 bytes
- Lines
- 670
- 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_atomic.hlibarena/common.hlibarena/asan.hlibarena/spmc.h
Detected Declarations
function spmc_tests_enabledfunction spmc_tests_enabledfunction spmc_common_initfunction spmc_common_finifunction spmc_quiesce_on_ownerfunction bpf_forfunction spmc_quiesce_on_stealerfunction spmc_update_statsfunction spmc_validate_owner_emptyfunction spmc_validate_all_seenfunction spmc_singleval_tryconsumefunction spmc_singleval_ownerfunction spmc_singleval_stealerfunction spmc_wait_for_stealers_to_startfunction bpf_forfunction spmc_waste_timefunction spmc_resize_ownerfunction spmc_resize_stealerfunction spmc_wait_for_round_stealsfunction bpf_forfunction spmc_burst_owner_roundfunction spmc_burst_ownerfunction spmc_burst_stealer
Annotated Snippet
if (test_abort) {
err = -EINTR;
break;
}
cur = smp_load_acquire(&stealer_epoch);
if (cur > target) {
err = -EINVAL;
test_abort = true;
break;
}
if (cur == target)
return 0;
}
test_abort = true;
return err;
}
static int spmc_update_stats(u64 val, bool owner)
{
u64 total;
total = expected_total;
if (val >= total || val >= TEST_SPMC_MAX_VALUES) {
test_abort = true;
return -EINVAL;
}
if (__sync_fetch_and_add(&seen[val], 1) != 0) {
test_abort = true;
return -EINVAL;
}
__sync_fetch_and_add(&total_seen, 1);
if (owner)
__sync_fetch_and_add(&pops, 1);
else
__sync_fetch_and_add(&steals, 1);
return 0;
}
static int spmc_validate_owner_empty(void)
{
u64 val;
int ret;
ret = spmc_owned_remove(spmc, &val);
if (ret != -ENOENT) {
test_abort = true;
/* Change a 0 return value into -EINVAL. */
return ret ?: -EINVAL;
}
return 0;
}
__weak
int spmc_validate_all_seen(void)
{
u64 i, total;
total = expected_total;
if (total_seen != total)
goto err;
if (pops + steals != total)
goto err;
for (i = zero; i < total && can_loop; i++) {
if (seen[i % TEST_SPMC_MAX_VALUES] != 1)
goto err;
}
return 0;
err:
test_abort = true;
return -EINVAL;
}
/*
* Single value benchmark. The owner adds an item then races with
* the stealers for it. This way directly race between owner and
* stealers on the same slot.
*/
Annotation
- Immediate include surface: `bpf_atomic.h`, `libarena/common.h`, `libarena/asan.h`, `libarena/spmc.h`.
- Detected declarations: `function spmc_tests_enabled`, `function spmc_tests_enabled`, `function spmc_common_init`, `function spmc_common_fini`, `function spmc_quiesce_on_owner`, `function bpf_for`, `function spmc_quiesce_on_stealer`, `function spmc_update_stats`, `function spmc_validate_owner_empty`, `function spmc_validate_all_seen`.
- 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.