mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 09:55:19 +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;
|
struct kobject kobj;
|
||||||
enum damos_action action;
|
enum damos_action action;
|
||||||
struct damon_sysfs_access_pattern *access_pattern;
|
struct damon_sysfs_access_pattern *access_pattern;
|
||||||
|
unsigned long apply_interval_us;
|
||||||
struct damon_sysfs_quotas *quotas;
|
struct damon_sysfs_quotas *quotas;
|
||||||
struct damon_sysfs_watermarks *watermarks;
|
struct damon_sysfs_watermarks *watermarks;
|
||||||
struct damon_sysfs_scheme_filters *filters;
|
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(
|
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),
|
struct damon_sysfs_scheme *scheme = kmalloc(sizeof(*scheme),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
@ -1153,6 +1154,7 @@ static struct damon_sysfs_scheme *damon_sysfs_scheme_alloc(
|
||||||
return NULL;
|
return NULL;
|
||||||
scheme->kobj = (struct kobject){};
|
scheme->kobj = (struct kobject){};
|
||||||
scheme->action = action;
|
scheme->action = action;
|
||||||
|
scheme->apply_interval_us = apply_interval_us;
|
||||||
return scheme;
|
return scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1356,6 +1358,25 @@ static ssize_t action_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||||
return -EINVAL;
|
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)
|
static void damon_sysfs_scheme_release(struct kobject *kobj)
|
||||||
{
|
{
|
||||||
kfree(container_of(kobj, struct damon_sysfs_scheme, 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 =
|
static struct kobj_attribute damon_sysfs_scheme_action_attr =
|
||||||
__ATTR_RW_MODE(action, 0600);
|
__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[] = {
|
static struct attribute *damon_sysfs_scheme_attrs[] = {
|
||||||
&damon_sysfs_scheme_action_attr.attr,
|
&damon_sysfs_scheme_action_attr.attr,
|
||||||
|
&damon_sysfs_scheme_apply_interval_us_attr.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
ATTRIBUTE_GROUPS(damon_sysfs_scheme);
|
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;
|
schemes->schemes_arr = schemes_arr;
|
||||||
|
|
||||||
for (i = 0; i < nr_schemes; i++) {
|
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) {
|
if (!scheme) {
|
||||||
damon_sysfs_schemes_rm_dirs(schemes);
|
damon_sysfs_schemes_rm_dirs(schemes);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -1613,8 +1642,8 @@ static struct damos *damon_sysfs_mk_scheme(
|
||||||
.low = sysfs_wmarks->low,
|
.low = sysfs_wmarks->low,
|
||||||
};
|
};
|
||||||
|
|
||||||
scheme = damon_new_scheme(&pattern, sysfs_scheme->action, 0, "a,
|
scheme = damon_new_scheme(&pattern, sysfs_scheme->action,
|
||||||
&wmarks);
|
sysfs_scheme->apply_interval_us, "a, &wmarks);
|
||||||
if (!scheme)
|
if (!scheme)
|
||||||
return NULL;
|
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->pattern.max_age_region = access_pattern->age->max;
|
||||||
|
|
||||||
scheme->action = sysfs_scheme->action;
|
scheme->action = sysfs_scheme->action;
|
||||||
|
scheme->apply_interval_us = sysfs_scheme->apply_interval_us;
|
||||||
|
|
||||||
scheme->quota.ms = sysfs_quotas->ms;
|
scheme->quota.ms = sysfs_quotas->ms;
|
||||||
scheme->quota.sz = sysfs_quotas->sz;
|
scheme->quota.sz = sysfs_quotas->sz;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user