tools/perf/tests/dso-data.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/dso-data.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/dso-data.c- Extension
.c- Size
- 9240 bytes
- Lines
- 408
- 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
dirent.hstdlib.hlinux/kernel.hlinux/types.hsys/stat.hfcntl.hstring.hsys/time.hsys/resource.hapi/fs/fs.hdso.hdsos.hmachine.hsymbol.htests.hdebug.h
Detected Declarations
struct test_data_offsetfunction dso__data_fdfunction dsos__deletefunction test__dso_datafunction open_files_cntfunction dsos__createfunction set_fd_limitfunction test__dso_data_cachefunction new_limitfunction test__dso_data_reopen
Annotated Snippet
struct test_data_offset {
off_t offset;
u8 data[10];
int size;
};
static struct test_data_offset offsets[] = {
/* Fill first cache page. */
{
.offset = 10,
.data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
.size = 10,
},
/* Read first cache page. */
{
.offset = 10,
.data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
.size = 10,
},
/* Fill cache boundary pages. */
{
.offset = DSO__DATA_CACHE_SIZE - DSO__DATA_CACHE_SIZE % 10,
.data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
.size = 10,
},
/* Read cache boundary pages. */
{
.offset = DSO__DATA_CACHE_SIZE - DSO__DATA_CACHE_SIZE % 10,
.data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
.size = 10,
},
/* Fill final cache page. */
{
.offset = TEST_FILE_SIZE - 10,
.data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
.size = 10,
},
/* Read final cache page. */
{
.offset = TEST_FILE_SIZE - 10,
.data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
.size = 10,
},
/* Read final cache page. */
{
.offset = TEST_FILE_SIZE - 3,
.data = { 7, 8, 9, 0, 0, 0, 0, 0, 0, 0 },
.size = 3,
},
};
/* move it from util/dso.c for compatibility */
static int dso__data_fd(struct dso *dso, struct machine *machine)
{
int fd = -1;
if (dso__data_get_fd(dso, machine, &fd))
dso__data_put_fd(dso);
return fd;
}
static void dsos__delete(struct dsos *dsos)
{
for (unsigned int i = 0; i < dsos->cnt; i++) {
struct dso *dso = dsos->dsos[i];
dso__data_close(dso);
unlink(dso__name(dso));
}
dsos__exit(dsos);
}
static int test__dso_data(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
struct dso *dso;
char *file = test_file(TEST_FILE_SIZE);
size_t i;
TEST_ASSERT_VAL("No test file", file);
memset(&machine, 0, sizeof(machine));
dsos__init(&machine.dsos);
dso = dso__new(file);
TEST_ASSERT_VAL("Failed to add dso", !dsos__add(&machine.dsos, dso));
TEST_ASSERT_VAL("Failed to access to dso",
dso__data_fd(dso, &machine) >= 0);
Annotation
- Immediate include surface: `dirent.h`, `stdlib.h`, `linux/kernel.h`, `linux/types.h`, `sys/stat.h`, `fcntl.h`, `string.h`, `sys/time.h`.
- Detected declarations: `struct test_data_offset`, `function dso__data_fd`, `function dsos__delete`, `function test__dso_data`, `function open_files_cnt`, `function dsos__create`, `function set_fd_limit`, `function test__dso_data_cache`, `function new_limit`, `function test__dso_data_reopen`.
- 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.