1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * DAMON api 4 * 5 * Author: SeongJae Park <sjpark@amazon.de> 6 */ 7 8 #ifndef _DAMON_H_ 9 #define _DAMON_H_ 10 11 #include <linux/memcontrol.h> 12 #include <linux/mutex.h> 13 #include <linux/time64.h> 14 #include <linux/types.h> 15 #include <linux/random.h> 16 17 /* Minimal region size. Every damon_region is aligned by this. */ 18 #define DAMON_MIN_REGION PAGE_SIZE 19 /* Max priority score for DAMON-based operation schemes */ 20 #define DAMOS_MAX_SCORE (99) 21 22 /* Get a random number in [l, r) */ 23 static inline unsigned long damon_rand(unsigned long l, unsigned long r) 24 { 25 return l + get_random_u32_below(r - l); 26 } 27 28 /** 29 * struct damon_addr_range - Represents an address region of [@start, @end). 30 * @start: Start address of the region (inclusive). 31 * @end: End address of the region (exclusive). 32 */ 33 struct damon_addr_range { 34 unsigned long start; 35 unsigned long end; 36 }; 37 38 /** 39 * struct damon_region - Represents a monitoring target region. 40 * @ar: The address range of the region. 41 * @sampling_addr: Address of the sample for the next access check. 42 * @nr_accesses: Access frequency of this region. 43 * @list: List head for siblings. 44 * @age: Age of this region. 45 * 46 * @age is initially zero, increased for each aggregation interval, and reset 47 * to zero again if the access frequency is significantly changed. If two 48 * regions are merged into a new region, both @nr_accesses and @age of the new 49 * region are set as region size-weighted average of those of the two regions. 50 */ 51 struct damon_region { 52 struct damon_addr_range ar; 53 unsigned long sampling_addr; 54 unsigned int nr_accesses; 55 struct list_head list; 56 57 unsigned int age; 58 /* private: Internal value for age calculation. */ 59 unsigned int last_nr_accesses; 60 }; 61 62 /** 63 * struct damon_target - Represents a monitoring target. 64 * @pid: The PID of the virtual address space to monitor. 65 * @nr_regions: Number of monitoring target regions of this target. 66 * @regions_list: Head of the monitoring target regions of this target. 67 * @list: List head for siblings. 68 * 69 * Each monitoring context could have multiple targets. For example, a context 70 * for virtual memory address spaces could have multiple target processes. The 71 * @pid should be set for appropriate &struct damon_operations including the 72 * virtual address spaces monitoring operations. 73 */ 74 struct damon_target { 75 struct pid *pid; 76 unsigned int nr_regions; 77 struct list_head regions_list; 78 struct list_head list; 79 }; 80 81 /** 82 * enum damos_action - Represents an action of a Data Access Monitoring-based 83 * Operation Scheme. 84 * 85 * @DAMOS_WILLNEED: Call ``madvise()`` for the region with MADV_WILLNEED. 86 * @DAMOS_COLD: Call ``madvise()`` for the region with MADV_COLD. 87 * @DAMOS_PAGEOUT: Call ``madvise()`` for the region with MADV_PAGEOUT. 88 * @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE. 89 * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE. 90 * @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists. 91 * @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists. 92 * @DAMOS_STAT: Do nothing but count the stat. 93 * @NR_DAMOS_ACTIONS: Total number of DAMOS actions 94 */ 95 enum damos_action { 96 DAMOS_WILLNEED, 97 DAMOS_COLD, 98 DAMOS_PAGEOUT, 99 DAMOS_HUGEPAGE, 100 DAMOS_NOHUGEPAGE, 101 DAMOS_LRU_PRIO, 102 DAMOS_LRU_DEPRIO, 103 DAMOS_STAT, /* Do nothing but only record the stat */ 104 NR_DAMOS_ACTIONS, 105 }; 106 107 /** 108 * struct damos_quota - Controls the aggressiveness of the given scheme. 109 * @ms: Maximum milliseconds that the scheme can use. 110 * @sz: Maximum bytes of memory that the action can be applied. 111 * @reset_interval: Charge reset interval in milliseconds. 112 * 113 * @weight_sz: Weight of the region's size for prioritization. 114 * @weight_nr_accesses: Weight of the region's nr_accesses for prioritization. 115 * @weight_age: Weight of the region's age for prioritization. 116 * 117 * To avoid consuming too much CPU time or IO resources for applying the 118 * &struct damos->action to large memory, DAMON allows users to set time and/or 119 * size quotas. The quotas can be set by writing non-zero values to &ms and 120 * &sz, respectively. If the time quota is set, DAMON tries to use only up to 121 * &ms milliseconds within &reset_interval for applying the action. If the 122 * size quota is set, DAMON tries to apply the action only up to &sz bytes 123 * within &reset_interval. 124 * 125 * Internally, the time quota is transformed to a size quota using estimated 126 * throughput of the scheme's action. DAMON then compares it against &sz and 127 * uses smaller one as the effective quota. 128 * 129 * For selecting regions within the quota, DAMON prioritizes current scheme's 130 * target memory regions using the &struct damon_operations->get_scheme_score. 131 * You could customize the prioritization logic by setting &weight_sz, 132 * &weight_nr_accesses, and &weight_age, because monitoring operations are 133 * encouraged to respect those. 134 */ 135 struct damos_quota { 136 unsigned long ms; 137 unsigned long sz; 138 unsigned long reset_interval; 139 140 unsigned int weight_sz; 141 unsigned int weight_nr_accesses; 142 unsigned int weight_age; 143 144 /* private: */ 145 /* For throughput estimation */ 146 unsigned long total_charged_sz; 147 unsigned long total_charged_ns; 148 149 unsigned long esz; /* Effective size quota in bytes */ 150 151 /* For charging the quota */ 152 unsigned long charged_sz; 153 unsigned long charged_from; 154 struct damon_target *charge_target_from; 155 unsigned long charge_addr_from; 156 157 /* For prioritization */ 158 unsigned long histogram[DAMOS_MAX_SCORE + 1]; 159 unsigned int min_score; 160 }; 161 162 /** 163 * enum damos_wmark_metric - Represents the watermark metric. 164 * 165 * @DAMOS_WMARK_NONE: Ignore the watermarks of the given scheme. 166 * @DAMOS_WMARK_FREE_MEM_RATE: Free memory rate of the system in [0,1000]. 167 * @NR_DAMOS_WMARK_METRICS: Total number of DAMOS watermark metrics 168 */ 169 enum damos_wmark_metric { 170 DAMOS_WMARK_NONE, 171 DAMOS_WMARK_FREE_MEM_RATE, 172 NR_DAMOS_WMARK_METRICS, 173 }; 174 175 /** 176 * struct damos_watermarks - Controls when a given scheme should be activated. 177 * @metric: Metric for the watermarks. 178 * @interval: Watermarks check time interval in microseconds. 179 * @high: High watermark. 180 * @mid: Middle watermark. 181 * @low: Low watermark. 182 * 183 * If &metric is &DAMOS_WMARK_NONE, the scheme is always active. Being active 184 * means DAMON does monitoring and applying the action of the scheme to 185 * appropriate memory regions. Else, DAMON checks &metric of the system for at 186 * least every &interval microseconds and works as below. 187 * 188 * If &metric is higher than &high, the scheme is inactivated. If &metric is 189 * between &mid and &low, the scheme is activated. If &metric is lower than 190 * &low, the scheme is inactivated. 191 */ 192 struct damos_watermarks { 193 enum damos_wmark_metric metric; 194 unsigned long interval; 195 unsigned long high; 196 unsigned long mid; 197 unsigned long low; 198 199 /* private: */ 200 bool activated; 201 }; 202 203 /** 204 * struct damos_stat - Statistics on a given scheme. 205 * @nr_tried: Total number of regions that the scheme is tried to be applied. 206 * @sz_tried: Total size of regions that the scheme is tried to be applied. 207 * @nr_applied: Total number of regions that the scheme is applied. 208 * @sz_applied: Total size of regions that the scheme is applied. 209 * @qt_exceeds: Total number of times the quota of the scheme has exceeded. 210 */ 211 struct damos_stat { 212 unsigned long nr_tried; 213 unsigned long sz_tried; 214 unsigned long nr_applied; 215 unsigned long sz_applied; 216 unsigned long qt_exceeds; 217 }; 218 219 /** 220 * enum damos_filter_type - Type of memory for &struct damos_filter 221 * @DAMOS_FILTER_TYPE_ANON: Anonymous pages. 222 * @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages. 223 * @NR_DAMOS_FILTER_TYPES: Number of filter types. 224 */ 225 enum damos_filter_type { 226 DAMOS_FILTER_TYPE_ANON, 227 DAMOS_FILTER_TYPE_MEMCG, 228 NR_DAMOS_FILTER_TYPES, 229 }; 230 231 /** 232 * struct damos_filter - DAMOS action target memory filter. 233 * @type: Type of the page. 234 * @matching: If the matching page should filtered out or in. 235 * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. 236 * @list: List head for siblings. 237 * 238 * Before applying the &damos->action to a memory region, DAMOS checks if each 239 * page of the region matches to this and avoid applying the action if so. 240 * Note that the check support is up to &struct damon_operations 241 * implementation. 242 */ 243 struct damos_filter { 244 enum damos_filter_type type; 245 bool matching; 246 union { 247 unsigned short memcg_id; 248 }; 249 struct list_head list; 250 }; 251 252 /** 253 * struct damos_access_pattern - Target access pattern of the given scheme. 254 * @min_sz_region: Minimum size of target regions. 255 * @max_sz_region: Maximum size of target regions. 256 * @min_nr_accesses: Minimum ``->nr_accesses`` of target regions. 257 * @max_nr_accesses: Maximum ``->nr_accesses`` of target regions. 258 * @min_age_region: Minimum age of target regions. 259 * @max_age_region: Maximum age of target regions. 260 */ 261 struct damos_access_pattern { 262 unsigned long min_sz_region; 263 unsigned long max_sz_region; 264 unsigned int min_nr_accesses; 265 unsigned int max_nr_accesses; 266 unsigned int min_age_region; 267 unsigned int max_age_region; 268 }; 269 270 /** 271 * struct damos - Represents a Data Access Monitoring-based Operation Scheme. 272 * @pattern: Access pattern of target regions. 273 * @action: &damo_action to be applied to the target regions. 274 * @quota: Control the aggressiveness of this scheme. 275 * @wmarks: Watermarks for automated (in)activation of this scheme. 276 * @filters: Additional set of &struct damos_filter for &action. 277 * @stat: Statistics of this scheme. 278 * @list: List head for siblings. 279 * 280 * For each aggregation interval, DAMON finds regions which fit in the 281 * &pattern and applies &action to those. To avoid consuming too much 282 * CPU time or IO resources for the &action, "a is used. 283 * 284 * To do the work only when needed, schemes can be activated for specific 285 * system situations using &wmarks. If all schemes that registered to the 286 * monitoring context are inactive, DAMON stops monitoring either, and just 287 * repeatedly checks the watermarks. 288 * 289 * If all schemes that registered to a &struct damon_ctx are inactive, DAMON 290 * stops monitoring and just repeatedly checks the watermarks. 291 * 292 * Before applying the &action to a memory region, &struct damon_operations 293 * implementation could check pages of the region and skip &action to respect 294 * &filters 295 * 296 * After applying the &action to each region, &stat_count and &stat_sz is 297 * updated to reflect the number of regions and total size of regions that the 298 * &action is applied. 299 */ 300 struct damos { 301 struct damos_access_pattern pattern; 302 enum damos_action action; 303 struct damos_quota quota; 304 struct damos_watermarks wmarks; 305 struct list_head filters; 306 struct damos_stat stat; 307 struct list_head list; 308 }; 309 310 /** 311 * enum damon_ops_id - Identifier for each monitoring operations implementation 312 * 313 * @DAMON_OPS_VADDR: Monitoring operations for virtual address spaces 314 * @DAMON_OPS_FVADDR: Monitoring operations for only fixed ranges of virtual 315 * address spaces 316 * @DAMON_OPS_PADDR: Monitoring operations for the physical address space 317 * @NR_DAMON_OPS: Number of monitoring operations implementations 318 */ 319 enum damon_ops_id { 320 DAMON_OPS_VADDR, 321 DAMON_OPS_FVADDR, 322 DAMON_OPS_PADDR, 323 NR_DAMON_OPS, 324 }; 325 326 struct damon_ctx; 327 328 /** 329 * struct damon_operations - Monitoring operations for given use cases. 330 * 331 * @id: Identifier of this operations set. 332 * @init: Initialize operations-related data structures. 333 * @update: Update operations-related data structures. 334 * @prepare_access_checks: Prepare next access check of target regions. 335 * @check_accesses: Check the accesses to target regions. 336 * @reset_aggregated: Reset aggregated accesses monitoring results. 337 * @get_scheme_score: Get the score of a region for a scheme. 338 * @apply_scheme: Apply a DAMON-based operation scheme. 339 * @target_valid: Determine if the target is valid. 340 * @cleanup: Clean up the context. 341 * 342 * DAMON can be extended for various address spaces and usages. For this, 343 * users should register the low level operations for their target address 344 * space and usecase via the &damon_ctx.ops. Then, the monitoring thread 345 * (&damon_ctx.kdamond) calls @init and @prepare_access_checks before starting 346 * the monitoring, @update after each &damon_ctx.ops_update_interval, and 347 * @check_accesses, @target_valid and @prepare_access_checks after each 348 * &damon_ctx.sample_interval. Finally, @reset_aggregated is called after each 349 * &damon_ctx.aggr_interval. 350 * 351 * Each &struct damon_operations instance having valid @id can be registered 352 * via damon_register_ops() and selected by damon_select_ops() later. 353 * @init should initialize operations-related data structures. For example, 354 * this could be used to construct proper monitoring target regions and link 355 * those to @damon_ctx.adaptive_targets. 356 * @update should update the operations-related data structures. For example, 357 * this could be used to update monitoring target regions for current status. 358 * @prepare_access_checks should manipulate the monitoring regions to be 359 * prepared for the next access check. 360 * @check_accesses should check the accesses to each region that made after the 361 * last preparation and update the number of observed accesses of each region. 362 * It should also return max number of observed accesses that made as a result 363 * of its update. The value will be used for regions adjustment threshold. 364 * @reset_aggregated should reset the access monitoring results that aggregated 365 * by @check_accesses. 366 * @get_scheme_score should return the priority score of a region for a scheme 367 * as an integer in [0, &DAMOS_MAX_SCORE]. 368 * @apply_scheme is called from @kdamond when a region for user provided 369 * DAMON-based operation scheme is found. It should apply the scheme's action 370 * to the region and return bytes of the region that the action is successfully 371 * applied. 372 * @target_valid should check whether the target is still valid for the 373 * monitoring. 374 * @cleanup is called from @kdamond just before its termination. 375 */ 376 struct damon_operations { 377 enum damon_ops_id id; 378 void (*init)(struct damon_ctx *context); 379 void (*update)(struct damon_ctx *context); 380 void (*prepare_access_checks)(struct damon_ctx *context); 381 unsigned int (*check_accesses)(struct damon_ctx *context); 382 void (*reset_aggregated)(struct damon_ctx *context); 383 int (*get_scheme_score)(struct damon_ctx *context, 384 struct damon_target *t, struct damon_region *r, 385 struct damos *scheme); 386 unsigned long (*apply_scheme)(struct damon_ctx *context, 387 struct damon_target *t, struct damon_region *r, 388 struct damos *scheme); 389 bool (*target_valid)(struct damon_target *t); 390 void (*cleanup)(struct damon_ctx *context); 391 }; 392 393 /** 394 * struct damon_callback - Monitoring events notification callbacks. 395 * 396 * @before_start: Called before starting the monitoring. 397 * @after_wmarks_check: Called after each schemes' watermarks check. 398 * @after_sampling: Called after each sampling. 399 * @after_aggregation: Called after each aggregation. 400 * @before_damos_apply: Called before applying DAMOS action. 401 * @before_terminate: Called before terminating the monitoring. 402 * @private: User private data. 403 * 404 * The monitoring thread (&damon_ctx.kdamond) calls @before_start and 405 * @before_terminate just before starting and finishing the monitoring, 406 * respectively. Therefore, those are good places for installing and cleaning 407 * @private. 408 * 409 * The monitoring thread calls @after_wmarks_check after each DAMON-based 410 * operation schemes' watermarks check. If users need to make changes to the 411 * attributes of the monitoring context while it's deactivated due to the 412 * watermarks, this is the good place to do. 413 * 414 * The monitoring thread calls @after_sampling and @after_aggregation for each 415 * of the sampling intervals and aggregation intervals, respectively. 416 * Therefore, users can safely access the monitoring results without additional 417 * protection. For the reason, users are recommended to use these callback for 418 * the accesses to the results. 419 * 420 * If any callback returns non-zero, monitoring stops. 421 */ 422 struct damon_callback { 423 void *private; 424 425 int (*before_start)(struct damon_ctx *context); 426 int (*after_wmarks_check)(struct damon_ctx *context); 427 int (*after_sampling)(struct damon_ctx *context); 428 int (*after_aggregation)(struct damon_ctx *context); 429 int (*before_damos_apply)(struct damon_ctx *context, 430 struct damon_target *target, 431 struct damon_region *region, 432 struct damos *scheme); 433 void (*before_terminate)(struct damon_ctx *context); 434 }; 435 436 /** 437 * struct damon_attrs - Monitoring attributes for accuracy/overhead control. 438 * 439 * @sample_interval: The time between access samplings. 440 * @aggr_interval: The time between monitor results aggregations. 441 * @ops_update_interval: The time between monitoring operations updates. 442 * @min_nr_regions: The minimum number of adaptive monitoring 443 * regions. 444 * @max_nr_regions: The maximum number of adaptive monitoring 445 * regions. 446 * 447 * For each @sample_interval, DAMON checks whether each region is accessed or 448 * not. It aggregates and keeps the access information (number of accesses to 449 * each region) for @aggr_interval time. DAMON also checks whether the target 450 * memory regions need update (e.g., by ``mmap()`` calls from the application, 451 * in case of virtual memory monitoring) and applies the changes for each 452 * @ops_update_interval. All time intervals are in micro-seconds. 453 * Please refer to &struct damon_operations and &struct damon_callback for more 454 * detail. 455 */ 456 struct damon_attrs { 457 unsigned long sample_interval; 458 unsigned long aggr_interval; 459 unsigned long ops_update_interval; 460 unsigned long min_nr_regions; 461 unsigned long max_nr_regions; 462 }; 463 464 /** 465 * struct damon_ctx - Represents a context for each monitoring. This is the 466 * main interface that allows users to set the attributes and get the results 467 * of the monitoring. 468 * 469 * @attrs: Monitoring attributes for accuracy/overhead control. 470 * @kdamond: Kernel thread who does the monitoring. 471 * @kdamond_lock: Mutex for the synchronizations with @kdamond. 472 * 473 * For each monitoring context, one kernel thread for the monitoring is 474 * created. The pointer to the thread is stored in @kdamond. 475 * 476 * Once started, the monitoring thread runs until explicitly required to be 477 * terminated or every monitoring target is invalid. The validity of the 478 * targets is checked via the &damon_operations.target_valid of @ops. The 479 * termination can also be explicitly requested by calling damon_stop(). 480 * The thread sets @kdamond to NULL when it terminates. Therefore, users can 481 * know whether the monitoring is ongoing or terminated by reading @kdamond. 482 * Reads and writes to @kdamond from outside of the monitoring thread must 483 * be protected by @kdamond_lock. 484 * 485 * Note that the monitoring thread protects only @kdamond via @kdamond_lock. 486 * Accesses to other fields must be protected by themselves. 487 * 488 * @ops: Set of monitoring operations for given use cases. 489 * @callback: Set of callbacks for monitoring events notifications. 490 * 491 * @adaptive_targets: Head of monitoring targets (&damon_target) list. 492 * @schemes: Head of schemes (&damos) list. 493 */ 494 struct damon_ctx { 495 struct damon_attrs attrs; 496 497 /* private: internal use only */ 498 struct timespec64 last_aggregation; 499 struct timespec64 last_ops_update; 500 501 /* public: */ 502 struct task_struct *kdamond; 503 struct mutex kdamond_lock; 504 505 struct damon_operations ops; 506 struct damon_callback callback; 507 508 struct list_head adaptive_targets; 509 struct list_head schemes; 510 }; 511 512 static inline struct damon_region *damon_next_region(struct damon_region *r) 513 { 514 return container_of(r->list.next, struct damon_region, list); 515 } 516 517 static inline struct damon_region *damon_prev_region(struct damon_region *r) 518 { 519 return container_of(r->list.prev, struct damon_region, list); 520 } 521 522 static inline struct damon_region *damon_last_region(struct damon_target *t) 523 { 524 return list_last_entry(&t->regions_list, struct damon_region, list); 525 } 526 527 static inline struct damon_region *damon_first_region(struct damon_target *t) 528 { 529 return list_first_entry(&t->regions_list, struct damon_region, list); 530 } 531 532 static inline unsigned long damon_sz_region(struct damon_region *r) 533 { 534 return r->ar.end - r->ar.start; 535 } 536 537 538 #define damon_for_each_region(r, t) \ 539 list_for_each_entry(r, &t->regions_list, list) 540 541 #define damon_for_each_region_from(r, t) \ 542 list_for_each_entry_from(r, &t->regions_list, list) 543 544 #define damon_for_each_region_safe(r, next, t) \ 545 list_for_each_entry_safe(r, next, &t->regions_list, list) 546 547 #define damon_for_each_target(t, ctx) \ 548 list_for_each_entry(t, &(ctx)->adaptive_targets, list) 549 550 #define damon_for_each_target_safe(t, next, ctx) \ 551 list_for_each_entry_safe(t, next, &(ctx)->adaptive_targets, list) 552 553 #define damon_for_each_scheme(s, ctx) \ 554 list_for_each_entry(s, &(ctx)->schemes, list) 555 556 #define damon_for_each_scheme_safe(s, next, ctx) \ 557 list_for_each_entry_safe(s, next, &(ctx)->schemes, list) 558 559 #define damos_for_each_filter(f, scheme) \ 560 list_for_each_entry(f, &(scheme)->filters, list) 561 562 #define damos_for_each_filter_safe(f, next, scheme) \ 563 list_for_each_entry_safe(f, next, &(scheme)->filters, list) 564 565 #ifdef CONFIG_DAMON 566 567 struct damon_region *damon_new_region(unsigned long start, unsigned long end); 568 569 /* 570 * Add a region between two other regions 571 */ 572 static inline void damon_insert_region(struct damon_region *r, 573 struct damon_region *prev, struct damon_region *next, 574 struct damon_target *t) 575 { 576 __list_add(&r->list, &prev->list, &next->list); 577 t->nr_regions++; 578 } 579 580 void damon_add_region(struct damon_region *r, struct damon_target *t); 581 void damon_destroy_region(struct damon_region *r, struct damon_target *t); 582 int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, 583 unsigned int nr_ranges); 584 585 struct damos_filter *damos_new_filter(enum damos_filter_type type, 586 bool matching); 587 void damos_add_filter(struct damos *s, struct damos_filter *f); 588 void damos_destroy_filter(struct damos_filter *f); 589 590 struct damos *damon_new_scheme(struct damos_access_pattern *pattern, 591 enum damos_action action, struct damos_quota *quota, 592 struct damos_watermarks *wmarks); 593 void damon_add_scheme(struct damon_ctx *ctx, struct damos *s); 594 void damon_destroy_scheme(struct damos *s); 595 596 struct damon_target *damon_new_target(void); 597 void damon_add_target(struct damon_ctx *ctx, struct damon_target *t); 598 bool damon_targets_empty(struct damon_ctx *ctx); 599 void damon_free_target(struct damon_target *t); 600 void damon_destroy_target(struct damon_target *t); 601 unsigned int damon_nr_regions(struct damon_target *t); 602 603 struct damon_ctx *damon_new_ctx(void); 604 void damon_destroy_ctx(struct damon_ctx *ctx); 605 int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs); 606 void damon_set_schemes(struct damon_ctx *ctx, 607 struct damos **schemes, ssize_t nr_schemes); 608 int damon_nr_running_ctxs(void); 609 bool damon_is_registered_ops(enum damon_ops_id id); 610 int damon_register_ops(struct damon_operations *ops); 611 int damon_select_ops(struct damon_ctx *ctx, enum damon_ops_id id); 612 613 static inline bool damon_target_has_pid(const struct damon_ctx *ctx) 614 { 615 return ctx->ops.id == DAMON_OPS_VADDR || ctx->ops.id == DAMON_OPS_FVADDR; 616 } 617 618 619 int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive); 620 int damon_stop(struct damon_ctx **ctxs, int nr_ctxs); 621 622 int damon_set_region_biggest_system_ram_default(struct damon_target *t, 623 unsigned long *start, unsigned long *end); 624 625 #endif /* CONFIG_DAMON */ 626 627 #endif /* _DAMON_H */ 628