Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/sysfs-schemes: implement max_nr_snapshots file

Add a new DAMON sysfs file for setting and getting the newly introduced
per-DAMON-snapshot level DAMOS deactivation control parameter,
max_nr_snapshots. The file has a name same to the parameter and placed
under the damos stat directory.

Link: https://lkml.kernel.org/r/20251216080128.42991-9-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
204ab9ab 84e425c6

+28
+28
mm/damon/sysfs-schemes.c
··· 205 205 unsigned long sz_ops_filter_passed; 206 206 unsigned long qt_exceeds; 207 207 unsigned long nr_snapshots; 208 + unsigned long max_nr_snapshots; 208 209 }; 209 210 210 211 static struct damon_sysfs_stats *damon_sysfs_stats_alloc(void) ··· 276 275 return sysfs_emit(buf, "%lu\n", stats->nr_snapshots); 277 276 } 278 277 278 + static ssize_t max_nr_snapshots_show(struct kobject *kobj, 279 + struct kobj_attribute *attr, char *buf) 280 + { 281 + struct damon_sysfs_stats *stats = container_of(kobj, 282 + struct damon_sysfs_stats, kobj); 283 + 284 + return sysfs_emit(buf, "%lu\n", stats->max_nr_snapshots); 285 + } 286 + 287 + static ssize_t max_nr_snapshots_store(struct kobject *kobj, 288 + struct kobj_attribute *attr, const char *buf, size_t count) 289 + { 290 + struct damon_sysfs_stats *stats = container_of(kobj, 291 + struct damon_sysfs_stats, kobj); 292 + unsigned long max_nr_snapshots, err = kstrtoul(buf, 0, &max_nr_snapshots); 293 + 294 + if (err) 295 + return err; 296 + stats->max_nr_snapshots = max_nr_snapshots; 297 + return count; 298 + } 299 + 279 300 static void damon_sysfs_stats_release(struct kobject *kobj) 280 301 { 281 302 kfree(container_of(kobj, struct damon_sysfs_stats, kobj)); ··· 324 301 static struct kobj_attribute damon_sysfs_stats_nr_snapshots_attr = 325 302 __ATTR_RO_MODE(nr_snapshots, 0400); 326 303 304 + static struct kobj_attribute damon_sysfs_stats_max_nr_snapshots_attr = 305 + __ATTR_RW_MODE(max_nr_snapshots, 0600); 306 + 327 307 static struct attribute *damon_sysfs_stats_attrs[] = { 328 308 &damon_sysfs_stats_nr_tried_attr.attr, 329 309 &damon_sysfs_stats_sz_tried_attr.attr, ··· 335 309 &damon_sysfs_stats_sz_ops_filter_passed_attr.attr, 336 310 &damon_sysfs_stats_qt_exceeds_attr.attr, 337 311 &damon_sysfs_stats_nr_snapshots_attr.attr, 312 + &damon_sysfs_stats_max_nr_snapshots_attr.attr, 338 313 NULL, 339 314 }; 340 315 ATTRIBUTE_GROUPS(damon_sysfs_stats); ··· 2759 2732 damon_destroy_scheme(scheme); 2760 2733 return NULL; 2761 2734 } 2735 + scheme->max_nr_snapshots = sysfs_scheme->stats->max_nr_snapshots; 2762 2736 return scheme; 2763 2737 } 2764 2738