include/linux/damon.h

Source file repositories/reference/linux-study-clean/include/linux/damon.h

File Facts

System
Linux kernel
Corpus path
include/linux/damon.h
Extension
.h
Size
41088 bytes
Lines
1091
Domain
Core OS
Bucket
Core Kernel Interface
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct damon_addr_range {
	unsigned long start;
	unsigned long end;
};

/**
 * struct damon_size_range - Represents size for filter to operate on [@min, @max].
 * @min:	Min size (inclusive).
 * @max:	Max size (inclusive).
 */
struct damon_size_range {
	unsigned long min;
	unsigned long max;
};

/**
 * struct damon_region - Represents a monitoring target region.
 * @ar:			The address range of the region.
 * @sampling_addr:	Address of the sample for the next access check.
 * @nr_accesses:	Access frequency of this region.
 * @nr_accesses_bp:	@nr_accesses in basis point (0.01%) that updated for
 *			each sampling interval.
 * @probe_hits:		Number of probe-positive region samples.
 * @list:		List head for siblings.
 * @age:		Age of this region.
 *
 * For any use case, @ar should be non-zero positive size.
 *
 * @nr_accesses is reset to zero for every &damon_attrs->aggr_interval and be
 * increased for every &damon_attrs->sample_interval if an access to the region
 * during the last sampling interval is found.  The update of this field should
 * not be done with direct access but with the helper function,
 * damon_update_region_access_rate().
 *
 * @nr_accesses_bp is another representation of @nr_accesses in basis point
 * (1 in 10,000) that updated for every &damon_attrs->sample_interval in a
 * manner similar to moving sum.  By the algorithm, this value becomes
 * @nr_accesses * 10000 for every &struct damon_attrs->aggr_interval.  This can
 * be used when the aggregation interval is too huge and therefore cannot wait
 * for it before getting the access monitoring results.
 *
 * @age is initially zero, increased for each aggregation interval, and reset
 * to zero again if the access frequency is significantly changed.  If two
 * regions are merged into a new region, both @nr_accesses and @age of the new
 * region are set as region size-weighted average of those of the two regions.
 */
struct damon_region {
	struct damon_addr_range ar;
	unsigned long sampling_addr;
	unsigned int nr_accesses;
	unsigned int nr_accesses_bp;
	unsigned char probe_hits[DAMON_MAX_PROBES];
	struct list_head list;

	unsigned int age;
/* private: Internal value for age calculation. */
	unsigned int last_nr_accesses;
};

/**
 * struct damon_target - Represents a monitoring target.
 * @pid:		The PID of the virtual address space to monitor.
 * @nr_regions:		Number of monitoring target regions of this target.
 * @regions_list:	Head of the monitoring target regions of this target.
 * @list:		List head for siblings.
 * @obsolete:		Whether the commit destination target is obsolete.
 *
 * Each monitoring context could have multiple targets.  For example, a context
 * for virtual memory address spaces could have multiple target processes.  The
 * @pid should be set for appropriate &struct damon_operations including the
 * virtual address spaces monitoring operations.
 *
 * @obsolete is used only for damon_commit_targets() source targets, to specify
 * the matching destination targets are obsolete.  Read damon_commit_targets()
 * to see how it is handled.
 */
struct damon_target {
	struct pid *pid;
	unsigned int nr_regions;
	struct list_head regions_list;
	struct list_head list;
	bool obsolete;
};

/**
 * enum damos_action - Represents an action of a Data Access Monitoring-based
 * Operation Scheme.
 *
 * @DAMOS_WILLNEED:	Call ``madvise()`` for the region with MADV_WILLNEED.
 * @DAMOS_COLD:		Call ``madvise()`` for the region with MADV_COLD.

Annotation

Implementation Notes