From: SeongJae Park <sj@kernel.org>
To: Alex Rusuf <yorha.op@gmail.com>
Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [PATCH v2] mm/damon/core: Fix return value from damos_wmark_metric_value
Date: Sun, 28 Apr 2024 11:57:17 -0700 [thread overview]
Message-ID: <20240428185717.60110-1-sj@kernel.org> (raw)
In-Reply-To: <20240428184159.188535-1-yorha.op@gmail.com>
Hi Alex,
On Sun, 28 Apr 2024 21:41:59 +0300 Alex Rusuf <yorha.op@gmail.com> wrote:
> damos_wmark_metric_value's return value is 'unsigned long', so
> returning -EINVAL as 'unsigned long' may turn out to be
> very different from the expected one (using 2's complement) and
> treat as usual matric's value. So, fix that, checking if
> returned value is not 0.
>
> Fixes: ee801b7dd782 ("mm/damon/schemes: activate schemes based on a watermarks mechanism")
> Signed-off-by: Alex Rusuf <yorha.op@gmail.com>
> ---
We usually post new revisions of patches as new thread, instead of reply to
previous revision. If you want to kindly letting reviewers understand the
revision history of the patch, you could put the summary of the changes in each
revisions here[1].
[1] https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#the-canonical-patch-format
> mm/damon/core.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 6d503c1c125e..53d33b2fa0b9 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -1480,12 +1480,17 @@ 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_get_wmark_metric_value(enum damos_wmark_metric metric,
> + unsigned long *metric_value)
> {
> + if (metric == DAMOS_WMARK_NONE)
> + return -EINVAL;
> +
Below switch-case will handle this case too. How about removing this if
statement?
> 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 +1505,9 @@ static unsigned long damos_wmark_wait_us(struct damos *scheme)
> {
> unsigned long metric;
>
> - if (scheme->wmarks.metric == DAMOS_WMARK_NONE)
> + if (damos_get_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
Thanks,
SJ
next prev parent reply other threads:[~2024-04-28 18:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-04-28 19:17 ` Alex Rusuf
2024-04-28 19:36 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240428185717.60110-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--cc=yorha.op@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.