mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 17:35:20 +02:00
UPSTREAM: wqmm/damon/sysfs-schemes: support DAMOS apply interval
Update DAMON sysfs interface to support DAMOS apply intervals by adding a
new file, 'apply_interval_us' in each scheme directory. Users can set and
get the interval for each scheme in microseconds by writing to and reading
from the file.
Link: https://lkml.kernel.org/r/20230916020945.47296-7-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
(cherry picked from commit a2a9f68e35
)
Bug:361213181
Change-Id: I72b23f180559edf31d22852d31e7bdc2993a7b97
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Zhanbo Xiong <xiongzhanbo@xiaomi.corp-partner.google.com>
This commit is contained in:
parent
80b60d5dfa
commit
9980217de9
|
@ -1124,6 +1124,7 @@ struct damon_sysfs_scheme {
|
|||
struct kobject kobj;
|
||||
enum damos_action action;
|
||||
struct damon_sysfs_access_pattern *access_pattern;
|
||||
unsigned long apply_interval_us;
|
||||
struct damon_sysfs_quotas *quotas;
|
||||
struct damon_sysfs_watermarks *watermarks;
|
||||
struct damon_sysfs_scheme_filters *filters;
|
||||
|
@ -1144,7 +1145,7 @@ static const char * const damon_sysfs_damos_action_strs[] = {
|
|||
};
|
||||
|
||||
static struct damon_sysfs_scheme *damon_sysfs_scheme_alloc(
|
||||
enum damos_action action)
|
||||
enum damos_action action, unsigned long apply_interval_us)
|
||||
{
|
||||
struct damon_sysfs_scheme *scheme = kmalloc(sizeof(*scheme),
|
||||
GFP_KERNEL);
|
||||
|
@ -1153,6 +1154,7 @@ static struct damon_sysfs_scheme *damon_sysfs_scheme_alloc(
|
|||
return NULL;
|
||||
scheme->kobj = (struct kobject){};
|
||||
scheme->action = action;
|
||||
scheme->apply_interval_us = apply_interval_us;
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
@ -1356,6 +1358,25 @@ static ssize_t action_store(struct kobject *kobj, struct kobj_attribute *attr,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static ssize_t apply_interval_us_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
struct damon_sysfs_scheme *scheme = container_of(kobj,
|
||||
struct damon_sysfs_scheme, kobj);
|
||||
|
||||
return sysfs_emit(buf, "%lu\n", scheme->apply_interval_us);
|
||||
}
|
||||
|
||||
static ssize_t apply_interval_us_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct damon_sysfs_scheme *scheme = container_of(kobj,
|
||||
struct damon_sysfs_scheme, kobj);
|
||||
int err = kstrtoul(buf, 0, &scheme->apply_interval_us);
|
||||
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static void damon_sysfs_scheme_release(struct kobject *kobj)
|
||||
{
|
||||
kfree(container_of(kobj, struct damon_sysfs_scheme, kobj));
|
||||
|
@ -1364,8 +1385,12 @@ static void damon_sysfs_scheme_release(struct kobject *kobj)
|
|||
static struct kobj_attribute damon_sysfs_scheme_action_attr =
|
||||
__ATTR_RW_MODE(action, 0600);
|
||||
|
||||
static struct kobj_attribute damon_sysfs_scheme_apply_interval_us_attr =
|
||||
__ATTR_RW_MODE(apply_interval_us, 0600);
|
||||
|
||||
static struct attribute *damon_sysfs_scheme_attrs[] = {
|
||||
&damon_sysfs_scheme_action_attr.attr,
|
||||
&damon_sysfs_scheme_apply_interval_us_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(damon_sysfs_scheme);
|
||||
|
@ -1416,7 +1441,11 @@ static int damon_sysfs_schemes_add_dirs(struct damon_sysfs_schemes *schemes,
|
|||
schemes->schemes_arr = schemes_arr;
|
||||
|
||||
for (i = 0; i < nr_schemes; i++) {
|
||||
scheme = damon_sysfs_scheme_alloc(DAMOS_STAT);
|
||||
/*
|
||||
* apply_interval_us as 0 means same to aggregation interval
|
||||
* (same to before-apply_interval behavior)
|
||||
*/
|
||||
scheme = damon_sysfs_scheme_alloc(DAMOS_STAT, 0);
|
||||
if (!scheme) {
|
||||
damon_sysfs_schemes_rm_dirs(schemes);
|
||||
return -ENOMEM;
|
||||
|
@ -1613,8 +1642,8 @@ static struct damos *damon_sysfs_mk_scheme(
|
|||
.low = sysfs_wmarks->low,
|
||||
};
|
||||
|
||||
scheme = damon_new_scheme(&pattern, sysfs_scheme->action, 0, "a,
|
||||
&wmarks);
|
||||
scheme = damon_new_scheme(&pattern, sysfs_scheme->action,
|
||||
sysfs_scheme->apply_interval_us, "a, &wmarks);
|
||||
if (!scheme)
|
||||
return NULL;
|
||||
|
||||
|
@ -1644,6 +1673,7 @@ static void damon_sysfs_update_scheme(struct damos *scheme,
|
|||
scheme->pattern.max_age_region = access_pattern->age->max;
|
||||
|
||||
scheme->action = sysfs_scheme->action;
|
||||
scheme->apply_interval_us = sysfs_scheme->apply_interval_us;
|
||||
|
||||
scheme->quota.ms = sysfs_quotas->ms;
|
||||
scheme->quota.sz = sysfs_quotas->sz;
|
||||
|
|
Loading…
Reference in New Issue
Block a user