tools/perf/arch/x86/tests/amd-ibs-period.c
Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/tests/amd-ibs-period.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/arch/x86/tests/amd-ibs-period.c- Extension
.c- Size
- 30705 bytes
- Lines
- 1032
- 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.hsys/syscall.hsys/mman.hsys/ioctl.hsys/utsname.hstring.harch-tests.hlinux/perf_event.htests/tests.h../perf-sys.hpmu.hpmus.hdebug.hutil.hstrbuf.h../util/env.h
Detected Declarations
struct ibs_configsstruct ibs_periodstruct ibs_ioctlstruct ibs_l3missonlyfunction dummy_workload_1function dummy_workload_2function sched_affinefunction copy_sample_datafunction rb_readfunction rb_skipfunction period_equalfunction period_higherfunction rb_drain_samplesfunction perf_event_openfunction fetch_prepare_attrfunction op_prepare_attrfunction __ibs_config_testfunction ibs_config_testfunction __ibs_period_constraint_testfunction ibs_period_constraint_testfunction __ibs_ioctl_testfunction ibs_ioctl_testfunction ibs_freq_neg_testfunction __ibs_l3missonly_testfunction ibs_l3missonly_testfunction get_perf_event_max_sample_ratefunction kernel_v6_15_or_newerfunction test__amd_ibs_period
Annotated Snippet
struct ibs_configs {
/* Input */
unsigned long config;
/* Expected output */
unsigned long period;
int fd;
};
/*
* Somehow first Fetch event with sample period = 0x10 causes 0
* samples. So start with large period and decrease it gradually.
*/
struct ibs_configs fetch_configs[] = {
{ .config = 0xffff, .period = 0xffff0, .fd = FD_SUCCESS },
{ .config = 0x1000, .period = 0x10000, .fd = FD_SUCCESS },
{ .config = 0xff, .period = 0xff0, .fd = FD_SUCCESS },
{ .config = 0x1, .period = 0x10, .fd = FD_SUCCESS },
{ .config = 0x0, .period = -1, .fd = FD_ERROR },
{ .config = 0x10000, .period = -1, .fd = FD_ERROR },
};
struct ibs_configs op_configs[] = {
{ .config = 0x0, .period = -1, .fd = FD_ERROR },
{ .config = 0x1, .period = -1, .fd = FD_ERROR },
{ .config = 0x8, .period = -1, .fd = FD_ERROR },
{ .config = 0x9, .period = 0x90, .fd = FD_SUCCESS },
{ .config = 0xf, .period = 0xf0, .fd = FD_SUCCESS },
{ .config = 0x1000, .period = 0x10000, .fd = FD_SUCCESS },
{ .config = 0xffff, .period = 0xffff0, .fd = FD_SUCCESS },
{ .config = 0x10000, .period = -1, .fd = FD_ERROR },
{ .config = 0x100000, .period = 0x100000, .fd = FD_SUCCESS },
{ .config = 0xf00000, .period = 0xf00000, .fd = FD_SUCCESS },
{ .config = 0xf0ffff, .period = 0xfffff0, .fd = FD_SUCCESS },
{ .config = 0x1f0ffff, .period = 0x1fffff0, .fd = FD_SUCCESS },
{ .config = 0x7f0ffff, .period = 0x7fffff0, .fd = FD_SUCCESS },
{ .config = 0x8f0ffff, .period = -1, .fd = FD_ERROR },
{ .config = 0x17f0ffff, .period = -1, .fd = FD_ERROR },
};
static int __ibs_config_test(int ibs_type, struct ibs_configs *config, int *nr_samples)
{
struct perf_event_attr attr;
int fd, i;
void *rb;
int ret = 0;
if (ibs_type == IBS_FETCH)
fetch_prepare_attr(&attr, config->config, 0, 0);
else
op_prepare_attr(&attr, config->config, 0, 0);
/* CPU0, All processes */
fd = perf_event_open(&attr, -1, 0, -1, 0);
if (config->fd == FD_ERROR) {
if (fd != -1) {
close(fd);
return -1;
}
return 0;
}
if (fd <= -1)
return -1;
rb = mmap(NULL, PERF_MMAP_TOTAL_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if (rb == MAP_FAILED) {
pr_debug("mmap() failed. [%m]\n");
return -1;
}
ioctl(fd, PERF_EVENT_IOC_RESET, 0);
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
i = 5;
while (i--) {
dummy_workload_1(1000000);
ret = rb_drain_samples(rb, config->period, nr_samples,
period_equal);
if (ret)
break;
}
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
munmap(rb, PERF_MMAP_TOTAL_SIZE);
close(fd);
return ret;
}
Annotation
- Immediate include surface: `sched.h`, `sys/syscall.h`, `sys/mman.h`, `sys/ioctl.h`, `sys/utsname.h`, `string.h`, `arch-tests.h`, `linux/perf_event.h`.
- Detected declarations: `struct ibs_configs`, `struct ibs_period`, `struct ibs_ioctl`, `struct ibs_l3missonly`, `function dummy_workload_1`, `function dummy_workload_2`, `function sched_affine`, `function copy_sample_data`, `function rb_read`, `function rb_skip`.
- 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.