All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] DAMON: Fix return value from damos_wmark_metric_value
@ 2024-04-28 15:49 Alex Rusuf
  2024-04-28 16:57 ` SeongJae Park
  2024-04-28 18:41 ` [PATCH v2] mm/damon/core: " Alex Rusuf
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Rusuf @ 2024-04-28 15:49 UTC (permalink / raw)
  To: damon; +Cc: sj

Signed-off-by: Alex Rusuf <yorha.op@gmail.com>
---
 mm/damon/core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 6d503c1c125e..994ccd272555 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1480,12 +1480,14 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)
 	return true;
 }
 
-static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric)
+static int damos_wmark_metric_value(enum damos_wmark_metric metric,
+				    unsigned long *metric_value)
 {
 	switch (metric) {
 	case DAMOS_WMARK_FREE_MEM_RATE:
-		return global_zone_page_state(NR_FREE_PAGES) * 1000 /
+		*metric_value = global_zone_page_state(NR_FREE_PAGES) * 1000 /
 		       totalram_pages();
+		return 0;
 	default:
 		break;
 	}
@@ -1500,10 +1502,10 @@ static unsigned long damos_wmark_wait_us(struct damos *scheme)
 {
 	unsigned long metric;
 
-	if (scheme->wmarks.metric == DAMOS_WMARK_NONE)
+	if (scheme->wmarks.metric == DAMOS_WMARK_NONE ||
+	    damos_wmark_metric_value(scheme->wmarks.metric, &metric))
 		return 0;
 
-	metric = damos_wmark_metric_value(scheme->wmarks.metric);
 	/* higher than high watermark or lower than low watermark */
 	if (metric > scheme->wmarks.high || scheme->wmarks.low > metric) {
 		if (scheme->wmarks.activated)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-28 19:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-28 15:49 [PATCH] DAMON: Fix return value from damos_wmark_metric_value Alex Rusuf
2024-04-28 16:57 ` SeongJae Park
2024-04-28 18:46   ` Kirito Asuna
2024-04-28 18:41 ` [PATCH v2] mm/damon/core: " Alex Rusuf
2024-04-28 18:57   ` SeongJae Park
2024-04-28 19:17     ` Alex Rusuf
2024-04-28 19:36       ` SeongJae Park

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.