Skip to content

Commit 4acd715

Browse files
sjp38akpm00
authored andcommitted
mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function
'damon_sysfs_schemes_update_stats()' is coupled with both damon_sysfs_kdamond and damon_sysfs_schemes. It's a wide range of types dependency. It makes splitting the logics a little bit distracting. Split the function so that each function is coupled with smaller range of types. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d332fe1 commit 4acd715

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

mm/damon/sysfs.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,25 +2246,13 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
22462246
mutex_unlock(&ctx->kdamond_lock);
22472247
}
22482248

2249-
/*
2250-
* damon_sysfs_upd_schemes_stats() - Update schemes stats sysfs files.
2251-
* @kdamond: The kobject wrapper that associated to the kdamond thread.
2252-
*
2253-
* This function reads the schemes stats of specific kdamond and update the
2254-
* related values for sysfs files. This function should be called from DAMON
2255-
* callbacks while holding ``damon_syfs_lock``, to safely access the DAMON
2256-
* contexts-internal data and DAMON sysfs variables.
2257-
*/
2258-
static int damon_sysfs_upd_schemes_stats(struct damon_sysfs_kdamond *kdamond)
2249+
static void damon_sysfs_schemes_update_stats(
2250+
struct damon_sysfs_schemes *sysfs_schemes,
2251+
struct damon_ctx *ctx)
22592252
{
2260-
struct damon_ctx *ctx = kdamond->damon_ctx;
2261-
struct damon_sysfs_schemes *sysfs_schemes;
22622253
struct damos *scheme;
22632254
int schemes_idx = 0;
22642255

2265-
if (!ctx)
2266-
return -EINVAL;
2267-
sysfs_schemes = kdamond->contexts->contexts_arr[0]->schemes;
22682256
damon_for_each_scheme(scheme, ctx) {
22692257
struct damon_sysfs_stats *sysfs_stats;
22702258

@@ -2279,6 +2267,25 @@ static int damon_sysfs_upd_schemes_stats(struct damon_sysfs_kdamond *kdamond)
22792267
sysfs_stats->sz_applied = scheme->stat.sz_applied;
22802268
sysfs_stats->qt_exceeds = scheme->stat.qt_exceeds;
22812269
}
2270+
}
2271+
2272+
/*
2273+
* damon_sysfs_upd_schemes_stats() - Update schemes stats sysfs files.
2274+
* @kdamond: The kobject wrapper that associated to the kdamond thread.
2275+
*
2276+
* This function reads the schemes stats of specific kdamond and update the
2277+
* related values for sysfs files. This function should be called from DAMON
2278+
* callbacks while holding ``damon_syfs_lock``, to safely access the DAMON
2279+
* contexts-internal data and DAMON sysfs variables.
2280+
*/
2281+
static int damon_sysfs_upd_schemes_stats(struct damon_sysfs_kdamond *kdamond)
2282+
{
2283+
struct damon_ctx *ctx = kdamond->damon_ctx;
2284+
2285+
if (!ctx)
2286+
return -EINVAL;
2287+
damon_sysfs_schemes_update_stats(
2288+
kdamond->contexts->contexts_arr[0]->schemes, ctx);
22822289
return 0;
22832290
}
22842291

0 commit comments

Comments
 (0)