mm/damon/core: split damos application logic into a new function
The DAMOS action applying function, 'damon_do_apply_schemes()', is still long and not easy to read. Split out the code for applying a single action to a single region into a new function for better readability. Link: https://lkml.kernel.org/r/20221026225943.100429-3-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
2ea3498980
commit
e63a30c51f
|
@ -755,36 +755,16 @@ static bool damos_skip_charged_region(struct damon_target *t,
|
|||
return false;
|
||||
}
|
||||
|
||||
static void damon_do_apply_schemes(struct damon_ctx *c,
|
||||
struct damon_target *t,
|
||||
struct damon_region *r)
|
||||
static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
|
||||
struct damon_region *r, struct damos *s)
|
||||
{
|
||||
struct damos *s;
|
||||
|
||||
damon_for_each_scheme(s, c) {
|
||||
struct damos_quota *quota = &s->quota;
|
||||
unsigned long sz;
|
||||
unsigned long sz = damon_sz_region(r);
|
||||
struct timespec64 begin, end;
|
||||
unsigned long sz_applied = 0;
|
||||
|
||||
if (!s->wmarks.activated)
|
||||
continue;
|
||||
|
||||
/* Check the quota */
|
||||
if (quota->esz && quota->charged_sz >= quota->esz)
|
||||
continue;
|
||||
|
||||
if (damos_skip_charged_region(t, &r, s))
|
||||
continue;
|
||||
|
||||
if (!damos_valid_target(c, t, r, s))
|
||||
continue;
|
||||
|
||||
/* Apply the scheme */
|
||||
sz = damon_sz_region(r);
|
||||
if (c->ops.apply_scheme) {
|
||||
if (quota->esz &&
|
||||
quota->charged_sz + sz > quota->esz) {
|
||||
if (quota->esz && quota->charged_sz + sz > quota->esz) {
|
||||
sz = ALIGN_DOWN(quota->esz - quota->charged_sz,
|
||||
DAMON_MIN_REGION);
|
||||
if (!sz)
|
||||
|
@ -812,6 +792,31 @@ update_stat:
|
|||
s->stat.nr_applied++;
|
||||
s->stat.sz_applied += sz_applied;
|
||||
}
|
||||
|
||||
static void damon_do_apply_schemes(struct damon_ctx *c,
|
||||
struct damon_target *t,
|
||||
struct damon_region *r)
|
||||
{
|
||||
struct damos *s;
|
||||
|
||||
damon_for_each_scheme(s, c) {
|
||||
struct damos_quota *quota = &s->quota;
|
||||
|
||||
if (!s->wmarks.activated)
|
||||
continue;
|
||||
|
||||
/* Check the quota */
|
||||
if (quota->esz && quota->charged_sz >= quota->esz)
|
||||
continue;
|
||||
|
||||
if (damos_skip_charged_region(t, &r, s))
|
||||
continue;
|
||||
|
||||
if (!damos_valid_target(c, t, r, s))
|
||||
continue;
|
||||
|
||||
damos_apply_scheme(c, t, r, s);
|
||||
}
|
||||
}
|
||||
|
||||
/* Shouldn't be called if quota->ms and quota->sz are zero */
|
||||
|
|
Loading…
Reference in New Issue