* [PATCH 1/2] mm/damon/core: copy nr_accesses when splitting region
@ 2023-11-19 17:15 SeongJae Park
2023-11-19 17:15 ` [PATCH 2/2] mm/damon/core-test: test damon_split_region_at()'s access rate copying SeongJae Park
0 siblings, 1 reply; 2+ messages in thread
From: SeongJae Park @ 2023-11-19 17:15 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-mm, linux-kernel
Regions split function ('damon_split_region_at()') is called at the
beginning of an aggregation interval, and when DAMOS applying the
actions and charging quota. Because 'nr_accesses' fields of all regions
are reset at the beginning of each aggregation interval, and DAMOS was
applying the action at the end of each aggregation interval, there was
no need to copy the 'nr_accesses' field to the split-out region.
However, commit 42f994b71404 ("mm/damon/core: implement scheme-specific
apply interval") made DAMOS applies action on its own timing interval.
Hence, 'nr_accesses' should also copied to split-out regions, but the
commit didn't. Fix it by copying it.
Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Cc-ing stable@ is not needed, since the commit that introduced the issue has
merged in v6.7 merge window.
mm/damon/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 6262d55904e7..ce1562783e7e 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1225,6 +1225,7 @@ static void damon_split_region_at(struct damon_target *t,
new->age = r->age;
new->last_nr_accesses = r->last_nr_accesses;
new->nr_accesses_bp = r->nr_accesses_bp;
+ new->nr_accesses = r->nr_accesses;
damon_insert_region(new, r, damon_next_region(r), t);
}
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] mm/damon/core-test: test damon_split_region_at()'s access rate copying
2023-11-19 17:15 [PATCH 1/2] mm/damon/core: copy nr_accesses when splitting region SeongJae Park
@ 2023-11-19 17:15 ` SeongJae Park
0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2023-11-19 17:15 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Brendan Higgins, David Gow, damon, linux-mm,
kunit-dev, linux-kselftest, linux-kernel
damon_split_region_at() should set access rate related fields of the
resulting regions same. It may forgotten, and actually there was the
mistake before. Test it with the unit test case for the function.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/core-test.h | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h
index 649adf91ebc5..e6a01ea2ec54 100644
--- a/mm/damon/core-test.h
+++ b/mm/damon/core-test.h
@@ -122,18 +122,25 @@ static void damon_test_split_at(struct kunit *test)
{
struct damon_ctx *c = damon_new_ctx();
struct damon_target *t;
- struct damon_region *r;
+ struct damon_region *r, *r_new;
t = damon_new_target();
r = damon_new_region(0, 100);
+ r->nr_accesses_bp = 420000;
+ r->nr_accesses = 42;
+ r->last_nr_accesses = 15;
damon_add_region(r, t);
damon_split_region_at(t, r, 25);
KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
- r = damon_next_region(r);
- KUNIT_EXPECT_EQ(test, r->ar.start, 25ul);
- KUNIT_EXPECT_EQ(test, r->ar.end, 100ul);
+ r_new = damon_next_region(r);
+ KUNIT_EXPECT_EQ(test, r_new->ar.start, 25ul);
+ KUNIT_EXPECT_EQ(test, r_new->ar.end, 100ul);
+
+ KUNIT_EXPECT_EQ(test, r->nr_accesses_bp, r_new->nr_accesses_bp);
+ KUNIT_EXPECT_EQ(test, r->nr_accesses, r_new->nr_accesses);
+ KUNIT_EXPECT_EQ(test, r->last_nr_accesses, r_new->last_nr_accesses);
damon_free_target(t);
damon_destroy_ctx(c);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-19 17:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-19 17:15 [PATCH 1/2] mm/damon/core: copy nr_accesses when splitting region SeongJae Park
2023-11-19 17:15 ` [PATCH 2/2] mm/damon/core-test: test damon_split_region_at()'s access rate copying SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox