2023-03-08 08:13:06

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH v3 0/3] mm/damon/paddr: minor code improvement

Unify folio_put() to make code more clear, and also fix minor issue in
damon_pa_young().

v3:
- as SJ split the bugfix from v2, and it has merged[1], only do code
improvement
- fix a missing folio_sz update in damon_pa_young()
- add RB from SJ
- rebase on next-20230308

[1] https://lkml.kernel.org/r/[email protected]

v2:
- use goto lable in damon_pa_pageout() and refact too more functions

Kefeng Wang (3):
mm/damon/paddr: minor refactor of damon_pa_pageout()
mm/damon/paddr: minor refactor of
damon_pa_mark_accessed_or_deactivate()
mm/damon/paddr: fix missing folio_sz update in damon_pa_young()

mm/damon/paddr.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)

--
2.35.3



2023-03-08 08:13:11

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH v3 2/3] mm/damon/paddr: minor refactor of damon_pa_mark_accessed_or_deactivate()

Omit one line by unified folio_put(), and make code more clear.

Signed-off-by: Kefeng Wang <[email protected]>
---
mm/damon/paddr.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 0db724aec5cb..b22f6fbb5816 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -268,16 +268,15 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate(
if (!folio)
continue;

- if (damos_pa_filter_out(s, folio)) {
- folio_put(folio);
- continue;
- }
+ if (damos_pa_filter_out(s, folio))
+ goto put_folio;

if (mark_accessed)
folio_mark_accessed(folio);
else
folio_deactivate(folio);
applied += folio_nr_pages(folio);
+put_folio:
folio_put(folio);
}
return applied * PAGE_SIZE;
--
2.35.3


2023-03-08 08:13:15

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH v3 1/3] mm/damon/paddr: minor refactor of damon_pa_pageout()

Omit three lines by unified folio_put(), and make code more clear.

Reviewed-by: SeongJae Park <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
mm/damon/paddr.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index dd9c33fbe805..0db724aec5cb 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -238,21 +238,18 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
if (!folio)
continue;

- if (damos_pa_filter_out(s, folio)) {
- folio_put(folio);
- continue;
- }
+ if (damos_pa_filter_out(s, folio))
+ goto put_folio;

folio_clear_referenced(folio);
folio_test_clear_young(folio);
- if (!folio_isolate_lru(folio)) {
- folio_put(folio);
- continue;
- }
+ if (!folio_isolate_lru(folio))
+ goto put_folio;
if (folio_test_unevictable(folio))
folio_putback_lru(folio);
else
list_add(&folio->lru, &folio_list);
+put_folio:
folio_put(folio);
}
applied = reclaim_pages(&folio_list);
--
2.35.3


2023-03-08 08:13:20

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH v3 3/3] mm/damon/paddr: fix missing folio_sz update in damon_pa_young()

The *folio_sz in damon_pa_young() will be used(as last_folio_sz) by
__damon_pa_check_access(), so it's need to be updated, fix missing
branch.

Signed-off-by: Kefeng Wang <[email protected]>
---
mm/damon/paddr.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index b22f6fbb5816..467b99166b43 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -134,10 +134,8 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz)
}

need_lock = !folio_test_anon(folio) || folio_test_ksm(folio);
- if (need_lock && !folio_trylock(folio)) {
- folio_put(folio);
- return false;
- }
+ if (need_lock && !folio_trylock(folio))
+ goto out;

rmap_walk(folio, &rwc);

--
2.35.3


2023-03-08 18:17:25

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] mm/damon/paddr: minor code improvement

Hi Kefeng,

On Wed, 8 Mar 2023 16:33:08 +0800 Kefeng Wang <[email protected]> wrote:

> Unify folio_put() to make code more clear, and also fix minor issue in
> damon_pa_young().
>
> v3:
> - as SJ split the bugfix from v2, and it has merged[1], only do code
> improvement
> - fix a missing folio_sz update in damon_pa_young()
> - add RB from SJ
> - rebase on next-20230308
>
> [1] https://lkml.kernel.org/r/[email protected]
>
> v2:
> - use goto lable in damon_pa_pageout() and refact too more functions
>
> Kefeng Wang (3):
> mm/damon/paddr: minor refactor of damon_pa_pageout()
> mm/damon/paddr: minor refactor of
> damon_pa_mark_accessed_or_deactivate()
> mm/damon/paddr: fix missing folio_sz update in damon_pa_young()
>
> mm/damon/paddr.c | 26 ++++++++++----------------
> 1 file changed, 10 insertions(+), 16 deletions(-)

For the series,

Reviewed-by: SeongJae Park <[email protected]>

Thank you for your efforts on this, Kefeng!


Thanks,
SJ

>
> --
> 2.35.3
>