mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
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>
This commit is contained in:
parent
84e425c68e
commit
204ab9ab93
|
|
@ -205,6 +205,7 @@ struct damon_sysfs_stats {
|
|||
unsigned long sz_ops_filter_passed;
|
||||
unsigned long qt_exceeds;
|
||||
unsigned long nr_snapshots;
|
||||
unsigned long max_nr_snapshots;
|
||||
};
|
||||
|
||||
static struct damon_sysfs_stats *damon_sysfs_stats_alloc(void)
|
||||
|
|
@ -275,6 +276,28 @@ static ssize_t nr_snapshots_show(struct kobject *kobj,
|
|||
return sysfs_emit(buf, "%lu\n", stats->nr_snapshots);
|
||||
}
|
||||
|
||||
static ssize_t max_nr_snapshots_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
struct damon_sysfs_stats *stats = container_of(kobj,
|
||||
struct damon_sysfs_stats, kobj);
|
||||
|
||||
return sysfs_emit(buf, "%lu\n", stats->max_nr_snapshots);
|
||||
}
|
||||
|
||||
static ssize_t max_nr_snapshots_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct damon_sysfs_stats *stats = container_of(kobj,
|
||||
struct damon_sysfs_stats, kobj);
|
||||
unsigned long max_nr_snapshots, err = kstrtoul(buf, 0, &max_nr_snapshots);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
stats->max_nr_snapshots = max_nr_snapshots;
|
||||
return count;
|
||||
}
|
||||
|
||||
static void damon_sysfs_stats_release(struct kobject *kobj)
|
||||
{
|
||||
kfree(container_of(kobj, struct damon_sysfs_stats, kobj));
|
||||
|
|
@ -301,6 +324,9 @@ static struct kobj_attribute damon_sysfs_stats_qt_exceeds_attr =
|
|||
static struct kobj_attribute damon_sysfs_stats_nr_snapshots_attr =
|
||||
__ATTR_RO_MODE(nr_snapshots, 0400);
|
||||
|
||||
static struct kobj_attribute damon_sysfs_stats_max_nr_snapshots_attr =
|
||||
__ATTR_RW_MODE(max_nr_snapshots, 0600);
|
||||
|
||||
static struct attribute *damon_sysfs_stats_attrs[] = {
|
||||
&damon_sysfs_stats_nr_tried_attr.attr,
|
||||
&damon_sysfs_stats_sz_tried_attr.attr,
|
||||
|
|
@ -309,6 +335,7 @@ static struct attribute *damon_sysfs_stats_attrs[] = {
|
|||
&damon_sysfs_stats_sz_ops_filter_passed_attr.attr,
|
||||
&damon_sysfs_stats_qt_exceeds_attr.attr,
|
||||
&damon_sysfs_stats_nr_snapshots_attr.attr,
|
||||
&damon_sysfs_stats_max_nr_snapshots_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(damon_sysfs_stats);
|
||||
|
|
@ -2732,6 +2759,7 @@ static struct damos *damon_sysfs_mk_scheme(
|
|||
damon_destroy_scheme(scheme);
|
||||
return NULL;
|
||||
}
|
||||
scheme->max_nr_snapshots = sysfs_scheme->stats->max_nr_snapshots;
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user