tools/mm/page-types.c
Source file repositories/reference/linux-study-clean/tools/mm/page-types.c
File Facts
- System
- Linux kernel
- Corpus path
tools/mm/page-types.c- Extension
.c- Size
- 30969 bytes
- Lines
- 1393
- 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.hstdlib.hunistd.hstdint.hstdarg.hstring.hgetopt.hlimits.hassert.hftw.htime.hsetjmp.hsignal.hinttypes.hsys/types.herrno.hfcntl.hsys/mount.hsys/statfs.hsys/mman.h../../include/uapi/linux/magic.h../../include/uapi/linux/kernel-page-flags.hapi/fs/fs.h
Detected Declarations
function pages2mbfunction fatalfunction checked_openfunction do_u64_readfunction kpageflags_readfunction kpagecgroup_readfunction kpagecount_readfunction pagemap_readfunction pagemap_pfnfunction pagemap_swap_offsetfunction show_page_rangefunction flush_page_rangefunction show_pagefunction show_summaryfunction bit_mask_okfunction expand_overloaded_flagsfunction well_known_flagsfunction kpageflags_flagsfunction prepare_hwpoison_fdfunction hwpoison_pagefunction unpoison_pagefunction mark_page_idlefunction hash_slotfunction add_pagefunction walk_pfnfunction walk_swapfunction walk_vmafunction walk_taskfunction add_addr_rangefunction walk_addr_rangesfunction usagefunction parse_numberfunction parse_pidfunction show_filefunction sigbus_handlerfunction walk_file_rangefunction walk_filefunction walk_treefunction walk_page_cachefunction parse_filefunction parse_cgroupfunction parse_addr_rangefunction add_bits_filterfunction parse_flag_namefunction parse_flag_namesfunction parse_bits_maskfunction parse_kpageflagsfunction describe_flags
Annotated Snippet
if (!page_flag_names[i]) {
if (present)
fatal("unknown flag bit %d\n", i);
continue;
}
buf[j++] = present ? page_flag_names[i][0] : '_';
}
return buf;
}
static char *page_flag_longname(uint64_t flags)
{
static char buf[1024];
size_t i, n;
for (i = 0, n = 0; i < ARRAY_SIZE(page_flag_names); i++) {
if (!page_flag_names[i])
continue;
if ((flags >> i) & 1)
n += snprintf(buf + n, sizeof(buf) - n, "%s,",
page_flag_names[i] + 2);
}
if (n)
n--;
buf[n] = '\0';
return buf;
}
/*
* page list and summary
*/
static void show_page_range(unsigned long voffset, unsigned long offset,
unsigned long size, uint64_t flags,
uint64_t cgroup, uint64_t mapcnt)
{
static uint64_t flags0;
static uint64_t cgroup0;
static uint64_t mapcnt0;
static unsigned long voff;
static unsigned long index;
static unsigned long count;
if (flags == flags0 && cgroup == cgroup0 && mapcnt == mapcnt0 &&
offset == index + count && size && voffset == voff + count) {
count += size;
return;
}
if (count) {
if (opt_pid)
printf("%lx\t", voff);
if (opt_file)
printf("%lx\t", voff);
if (opt_list_cgroup)
printf("@%" PRIu64 "\t", cgroup0);
if (opt_list_mapcnt)
printf("%" PRIu64 "\t", mapcnt0);
printf("%lx\t%lx\t%s\n",
index, count, page_flag_name(flags0));
}
flags0 = flags;
cgroup0 = cgroup;
mapcnt0 = mapcnt;
index = offset;
voff = voffset;
count = size;
}
static void flush_page_range(void)
{
show_page_range(0, 0, 0, 0, 0, 0);
}
static void show_page(unsigned long voffset, unsigned long offset,
uint64_t flags, uint64_t cgroup, uint64_t mapcnt)
{
if (opt_pid)
printf("%lx\t", voffset);
if (opt_file)
printf("%lx\t", voffset);
if (opt_list_cgroup)
printf("@%" PRIu64 "\t", cgroup);
if (opt_list_mapcnt)
printf("%" PRIu64 "\t", mapcnt);
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `unistd.h`, `stdint.h`, `stdarg.h`, `string.h`, `getopt.h`, `limits.h`.
- Detected declarations: `function pages2mb`, `function fatal`, `function checked_open`, `function do_u64_read`, `function kpageflags_read`, `function kpagecgroup_read`, `function kpagecount_read`, `function pagemap_read`, `function pagemap_pfn`, `function pagemap_swap_offset`.
- 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.