mm/damon/sysfs-schemes.c
Source file repositories/reference/linux-study-clean/mm/damon/sysfs-schemes.c
File Facts
- System
- Linux kernel
- Corpus path
mm/damon/sysfs-schemes.c- Extension
.c- Size
- 81966 bytes
- Lines
- 3155
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/numa.hsysfs-common.h
Detected Declarations
struct damos_sysfs_probestruct damos_sysfs_probesstruct damon_sysfs_scheme_regionstruct damon_sysfs_scheme_regionsstruct damon_sysfs_statsstruct damon_sysfs_scheme_filterstruct damos_sysfs_filter_type_namestruct damon_sysfs_scheme_filtersstruct damon_sysfs_watermarksstruct damos_sysfs_wmark_metric_namestruct damos_sysfs_quota_goalstruct damos_sysfs_qgoal_metric_namestruct damos_sysfs_quota_goalsstruct damon_sysfs_weightsstruct damon_sysfs_quotasstruct damos_sysfs_qgoal_tuner_namestruct damon_sysfs_access_patternstruct damos_sysfs_deststruct damos_sysfs_destsstruct damon_sysfs_schemestruct damos_sysfs_action_nameenum damos_sysfs_filter_handle_layerfunction hits_showfunction damos_sysfs_probe_releasefunction damos_sysfs_probes_rm_dirsfunction damos_sysfs_probes_add_dirsfunction damos_sysfs_probes_releasefunction damos_sysfs_region_add_dirsfunction damos_sysfs_region_rm_dirsfunction start_showfunction end_showfunction nr_accesses_showfunction age_showfunction sz_filter_passed_showfunction damon_sysfs_scheme_region_releasefunction damon_sysfs_scheme_regions_allocfunction total_bytes_showfunction damon_sysfs_scheme_regions_rm_dirsfunction list_for_each_entry_safefunction damon_sysfs_scheme_regions_releasefunction nr_tried_showfunction sz_tried_showfunction nr_applied_showfunction sz_applied_showfunction sz_ops_filter_passed_showfunction qt_exceeds_showfunction nr_snapshots_showfunction max_nr_snapshots_show
Annotated Snippet
struct damos_sysfs_probe {
struct kobject kobj;
unsigned char hits;
};
static struct damos_sysfs_probe *damos_sysfs_probe_alloc(unsigned char hits)
{
struct damos_sysfs_probe *probe;
probe = kzalloc_obj(*probe);
if (!probe)
return NULL;
probe->hits = hits;
return probe;
}
static ssize_t hits_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
struct damos_sysfs_probe *probe = container_of(kobj,
struct damos_sysfs_probe, kobj);
return sysfs_emit(buf, "%hhu\n", probe->hits);
}
static void damos_sysfs_probe_release(struct kobject *kobj)
{
struct damos_sysfs_probe *probe = container_of(kobj,
struct damos_sysfs_probe, kobj);
kfree(probe);
}
static struct kobj_attribute damos_sysfs_probe_hits_attr =
__ATTR_RO_MODE(hits, 0400);
static struct attribute *damos_sysfs_probe_attrs[] = {
&damos_sysfs_probe_hits_attr.attr,
NULL,
};
ATTRIBUTE_GROUPS(damos_sysfs_probe);
static const struct kobj_type damos_sysfs_probe_ktype = {
.release = damos_sysfs_probe_release,
.sysfs_ops = &kobj_sysfs_ops,
.default_groups = damos_sysfs_probe_groups,
};
/*
* probes directory
*/
struct damos_sysfs_probes {
struct kobject kobj;
struct damos_sysfs_probe **probes_arr;
int nr;
};
static struct damos_sysfs_probes *damos_sysfs_probes_alloc(void)
{
return kzalloc_obj(struct damos_sysfs_probes);
}
static void damos_sysfs_probes_rm_dirs(struct damos_sysfs_probes *probes)
{
struct damos_sysfs_probe **probes_arr = probes->probes_arr;
int i;
for (i = 0; i < probes->nr; i++)
kobject_put(&probes_arr[i]->kobj);
probes->nr = 0;
kfree(probes_arr);
probes->probes_arr = NULL;
}
static int damos_sysfs_probes_add_dirs(struct damos_sysfs_probes *probes,
struct damon_ctx *ctx, struct damon_region *region)
{
struct damon_probe *probe;
struct damos_sysfs_probe **probes_arr;
int i = 0;
damon_for_each_probe(probe, ctx)
i++;
if (!i)
return 0;
probes_arr = kmalloc_objs(*probes_arr, i);
if (!probes_arr)
Annotation
- Immediate include surface: `linux/slab.h`, `linux/numa.h`, `sysfs-common.h`.
- Detected declarations: `struct damos_sysfs_probe`, `struct damos_sysfs_probes`, `struct damon_sysfs_scheme_region`, `struct damon_sysfs_scheme_regions`, `struct damon_sysfs_stats`, `struct damon_sysfs_scheme_filter`, `struct damos_sysfs_filter_type_name`, `struct damon_sysfs_scheme_filters`, `struct damon_sysfs_watermarks`, `struct damos_sysfs_wmark_metric_name`.
- Atlas domain: Core OS / Memory Management.
- 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.