mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mm/damon/sysfs: add min,max files under probe filter directory
In future, DAMON sysfs interface will support data attribute probe filter types that have range arguments like the newly added hugepage_size type filter. To prepare such supports, add two new DAMON sysfs files, min and max, under the probe filter directory. Link: https://lore.kernel.org/20260915143359.91472-5-sj@kernel.org Signed-off-by: SJ Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: David Hildenbrand <david@kernel.org> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org>
This commit is contained in:
parent
71fb2abf32
commit
e63813b893
|
|
@ -975,6 +975,8 @@ struct damon_sysfs_filter {
|
|||
bool matching;
|
||||
bool allow;
|
||||
char *path;
|
||||
unsigned long range_min;
|
||||
unsigned long range_max;
|
||||
};
|
||||
|
||||
static struct damon_sysfs_filter *damon_sysfs_filter_alloc(void)
|
||||
|
|
@ -1127,6 +1129,44 @@ static ssize_t path_store(struct kobject *kobj,
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t min_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
struct damon_sysfs_filter *filter = container_of(kobj,
|
||||
struct damon_sysfs_filter, kobj);
|
||||
|
||||
return sysfs_emit(buf, "%lu\n", filter->range_min);
|
||||
}
|
||||
|
||||
static ssize_t min_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct damon_sysfs_filter *filter = container_of(kobj,
|
||||
struct damon_sysfs_filter, kobj);
|
||||
int err = kstrtoul(buf, 0, &filter->range_min);
|
||||
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static ssize_t max_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
struct damon_sysfs_filter *filter = container_of(kobj,
|
||||
struct damon_sysfs_filter, kobj);
|
||||
|
||||
return sysfs_emit(buf, "%lu\n", filter->range_max);
|
||||
}
|
||||
|
||||
static ssize_t max_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct damon_sysfs_filter *filter = container_of(kobj,
|
||||
struct damon_sysfs_filter, kobj);
|
||||
int err = kstrtoul(buf, 0, &filter->range_max);
|
||||
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static void damon_sysfs_filter_release(struct kobject *kobj)
|
||||
{
|
||||
struct damon_sysfs_filter *filter = container_of(kobj,
|
||||
|
|
@ -1148,11 +1188,19 @@ static struct kobj_attribute damon_sysfs_filter_allow_attr =
|
|||
static struct kobj_attribute damon_sysfs_filter_path_attr =
|
||||
__ATTR_RW_MODE(path, 0600);
|
||||
|
||||
static struct kobj_attribute damon_sysfs_filter_min_attr =
|
||||
__ATTR_RW_MODE(min, 0600);
|
||||
|
||||
static struct kobj_attribute damon_sysfs_filter_max_attr =
|
||||
__ATTR_RW_MODE(max, 0600);
|
||||
|
||||
static struct attribute *damon_sysfs_filter_attrs[] = {
|
||||
&damon_sysfs_filter_type_attr.attr,
|
||||
&damon_sysfs_filter_matching_attr.attr,
|
||||
&damon_sysfs_filter_allow_attr.attr,
|
||||
&damon_sysfs_filter_path_attr.attr,
|
||||
&damon_sysfs_filter_min_attr.attr,
|
||||
&damon_sysfs_filter_max_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(damon_sysfs_filter);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user