* [PATCH] mm/damon/paddr: remove folio_put from damon_pa_invalid_damos_folio
@ 2026-06-25 1:22 Yu Qin
2026-06-25 3:25 ` SeongJae Park
2026-06-25 3:49 ` Matthew Wilcox
0 siblings, 2 replies; 3+ messages in thread
From: Yu Qin @ 2026-06-25 1:22 UTC (permalink / raw)
To: sj; +Cc: akpm, damon, linux-mm, Yu Qin
This boolean function called folio_put() implicitly. Remove the put and let
callers handle it explicitly, making the get/put pair more clear.
Signed-off-by: Yu Qin <qin.yuA@h3c.com>
---
mm/damon/paddr.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 85cd64a55..f45c7939a 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -313,15 +313,12 @@ static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio)
return scheme->ops_filters_default_reject;
}
-static bool damon_pa_invalid_damos_folio(struct folio *folio, struct damos *s)
+static inline bool damon_pa_invalid_damos_folio(struct folio *folio,
+ struct damos *s)
{
if (!folio)
return true;
- if (folio == s->last_applied) {
- folio_put(folio);
- return true;
- }
- return false;
+ return folio == s->last_applied;
}
static unsigned long damon_pa_pageout(struct damon_region *r,
@@ -353,6 +350,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r,
while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
folio = damon_get_folio(PHYS_PFN(addr));
if (damon_pa_invalid_damos_folio(folio, s)) {
+ if (folio)
+ folio_put(folio);
addr += PAGE_SIZE;
continue;
}
@@ -394,6 +393,8 @@ static inline unsigned long damon_pa_de_activate(
while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
folio = damon_get_folio(PHYS_PFN(addr));
if (damon_pa_invalid_damos_folio(folio, s)) {
+ if (folio)
+ folio_put(folio);
addr += PAGE_SIZE;
continue;
}
@@ -442,6 +443,8 @@ static unsigned long damon_pa_migrate(struct damon_region *r,
while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
folio = damon_get_folio(PHYS_PFN(addr));
if (damon_pa_invalid_damos_folio(folio, s)) {
+ if (folio)
+ folio_put(folio);
addr += PAGE_SIZE;
continue;
}
@@ -478,6 +481,8 @@ static unsigned long damon_pa_stat(struct damon_region *r,
while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
folio = damon_get_folio(PHYS_PFN(addr));
if (damon_pa_invalid_damos_folio(folio, s)) {
+ if (folio)
+ folio_put(folio);
addr += PAGE_SIZE;
continue;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/damon/paddr: remove folio_put from damon_pa_invalid_damos_folio
2026-06-25 1:22 [PATCH] mm/damon/paddr: remove folio_put from damon_pa_invalid_damos_folio Yu Qin
@ 2026-06-25 3:25 ` SeongJae Park
2026-06-25 3:49 ` Matthew Wilcox
1 sibling, 0 replies; 3+ messages in thread
From: SeongJae Park @ 2026-06-25 3:25 UTC (permalink / raw)
To: Yu Qin; +Cc: SeongJae Park, akpm, damon, linux-mm
Hi Yu,
On Thu, 25 Jun 2026 09:22:01 +0800 Yu Qin <qin.yuA@h3c.com> wrote:
> This boolean function called folio_put() implicitly. Remove the put and let
> callers handle it explicitly, making the get/put pair more clear.
Thank you for this patch. I agree explicit get/put pair could look clearer for
some people. But, to some perspectives, doing NULL check and putting a folio
that already determined as invalid may look awkward. Given the fact tht NULL
check was already done inside the validity checck, doing the NULL check again
makes it even look inefficient.
Maybe just a matter of taste, but my taste is unfortunately closer to the
second perspective.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/damon/paddr: remove folio_put from damon_pa_invalid_damos_folio
2026-06-25 1:22 [PATCH] mm/damon/paddr: remove folio_put from damon_pa_invalid_damos_folio Yu Qin
2026-06-25 3:25 ` SeongJae Park
@ 2026-06-25 3:49 ` Matthew Wilcox
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2026-06-25 3:49 UTC (permalink / raw)
To: Yu Qin; +Cc: sj, akpm, damon, linux-mm
On Thu, Jun 25, 2026 at 09:22:01AM +0800, Yu Qin wrote:
> This boolean function called folio_put() implicitly. Remove the put and let
> callers handle it explicitly, making the get/put pair more clear.
I don't think this is a good change. It's perfectly fine to have a
function which always puts the ref that is passed to it. Rust can do
it, for example. I do wish we had an __attribute__ that could be used
to warn both the compiler and the user that this was the model being
implemented, but GCC doesn't have it yet.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-25 3:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-25 1:22 [PATCH] mm/damon/paddr: remove folio_put from damon_pa_invalid_damos_folio Yu Qin
2026-06-25 3:25 ` SeongJae Park
2026-06-25 3:49 ` Matthew Wilcox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.