lkml.org 
[lkml]   [2022]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC PATCH 08/11] mm/damon/sysfs-schemes: implement scheme filters
Date
On Thu, 24 Nov 2022 21:21:11 +0000 SeongJae Park <sj@kernel.org> wrote:

> Implement scheme filters functionality of DAMON sysfs interface by
> making the code reads the values of files under the filter directories
> and pass that to DAMON using DAMON kernel API.
>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
> mm/damon/sysfs-schemes.c | 85 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 84 insertions(+), 1 deletion(-)
>
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 7f2bab617156..6f014b328e6f 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
[...]
> +static int damon_sysfs_memcg_path_to_id(char *memcg_path, unsigned short *id)
> +{
> + struct mem_cgroup *memcg;
> + char *path;
> +
> + if (!memcg_path)
> + return -EINVAL;
> +
> + path = kmalloc(sizeof(*path) * PATH_MAX, GFP_KERNEL);
> + if (!path)
> + return -ENOMEM;
> +
> + for (memcg = mem_cgroup_iter(NULL, NULL, NULL); memcg;
> + memcg = mem_cgroup_iter(NULL, memcg, NULL)) {
> + if (damon_sysfs_memcg_path_eq(memcg, path, memcg_path)) {
> + *id = mem_cgroup_id(memcg);

Forgot mentioning this. Removed memcgs can still be iterated, so this can
result in getting id of already removed cgroup. If the user input is valid but
there is a removed memcg that has same path, this could be confused.

Removed memcg would have id 0. The next version of this will handle the case.


Thanks,
SJ

> + break;
> + }
> + }
> +
> + kfree(path);
> + return 0;
> +}

\
 
 \ /
  Last update: 2022-11-30 20:27    [W:0.067 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site