tools/testing/selftests/powerpc/pmu/count_stcx_fail.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/pmu/count_stcx_fail.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/pmu/count_stcx_fail.c- Extension
.c- Size
- 3782 bytes
- Lines
- 162
- 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
stdio.hstdbool.hstring.hsys/prctl.hevent.hutils.hlib.h
Detected Declarations
function setup_eventfunction do_count_loopfunction determine_overheadfunction test_bodyfunction count_ll_scfunction main
Annotated Snippet
if (current < overhead) {
printf("Replacing overhead %llu with %llu\n", overhead, current);
overhead = current;
}
}
return overhead;
}
#define PM_MRK_STCX_FAIL 0x03e158
#define PM_STCX_FAIL 0x01e058
static int test_body(void)
{
struct event events[3];
u64 overhead;
// The STCX_FAIL event we use works on Power8 or later
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
setup_event(&events[0], PERF_COUNT_HW_INSTRUCTIONS, PERF_TYPE_HARDWARE, "instructions");
setup_event(&events[1], PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "cycles");
setup_event(&events[2], PM_STCX_FAIL, PERF_TYPE_RAW, "stcx_fail");
if (event_open(&events[0])) {
perror("perf_event_open");
return -1;
}
if (event_open_with_group(&events[1], events[0].fd)) {
perror("perf_event_open");
return -1;
}
if (event_open_with_group(&events[2], events[0].fd)) {
perror("perf_event_open");
return -1;
}
overhead = determine_overhead(events);
printf("Overhead of null loop: %llu instructions\n", overhead);
/* Run for 1Mi instructions */
FAIL_IF(do_count_loop(events, 1000000, overhead, true));
/* Run for 10Mi instructions */
FAIL_IF(do_count_loop(events, 10000000, overhead, true));
/* Run for 100Mi instructions */
FAIL_IF(do_count_loop(events, 100000000, overhead, true));
/* Run for 1Bi instructions */
FAIL_IF(do_count_loop(events, 1000000000, overhead, true));
/* Run for 16Bi instructions */
FAIL_IF(do_count_loop(events, 16000000000, overhead, true));
event_close(&events[0]);
event_close(&events[1]);
return 0;
}
static int count_ll_sc(void)
{
return eat_cpu(test_body);
}
int main(void)
{
return test_harness(count_ll_sc, "count_ll_sc");
}
Annotation
- Immediate include surface: `stdio.h`, `stdbool.h`, `string.h`, `sys/prctl.h`, `event.h`, `utils.h`, `lib.h`.
- Detected declarations: `function setup_event`, `function do_count_loop`, `function determine_overhead`, `function test_body`, `function count_ll_sc`, `function main`.
- 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.