tools/testing/selftests/damon/drgn_dump_damon_status.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/damon/drgn_dump_damon_status.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/damon/drgn_dump_damon_status.py- Extension
.py- Size
- 6660 bytes
- Lines
- 228
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
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
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env drgn
# SPDX-License-Identifier: GPL-2.0
'''
Read DAMON context data and dump as a json string.
'''
import drgn
from drgn import FaultError, NULL, Object, cast, container_of, execscript, offsetof, reinterpret, sizeof
from drgn.helpers.common import *
from drgn.helpers.linux import *
import json
import sys
if "prog" not in globals():
try:
prog = drgn.get_default_prog()
except drgn.NoDefaultProgramError:
prog = drgn.program_from_kernel()
drgn.set_default_prog(prog)
def to_dict(object, attr_name_converter):
d = {}
for attr_name, converter in attr_name_converter:
d[attr_name] = converter(getattr(object, attr_name))
return d
def ops_to_dict(ops):
return to_dict(ops, [
['id', int],
])
def intervals_goal_to_dict(goal):
return to_dict(goal, [
['access_bp', int],
['aggrs', int],
['min_sample_us', int],
['max_sample_us', int],
])
def attrs_to_dict(attrs):
return to_dict(attrs, [
['sample_interval', int],
['aggr_interval', int],
['ops_update_interval', int],
['intervals_goal', intervals_goal_to_dict],
['min_nr_regions', int],
['max_nr_regions', int],
])
def addr_range_to_dict(addr_range):
return to_dict(addr_range, [
['start', int],
['end', int],
])
def region_to_dict(region):
return to_dict(region, [
['ar', addr_range_to_dict],
['sampling_addr', int],
['nr_accesses', int],
['nr_accesses_bp', int],
['age', int],
])
def regions_to_list(regions):
return [region_to_dict(r)
for r in list_for_each_entry(
'struct damon_region', regions.address_of_(), 'list')]
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
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.