linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yuanzheng Song <songyuanzheng@huawei.com>
To: <sj@kernel.org>, <akpm@linux-foundation.org>
Cc: <damon@lists.linux.dev>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] mm/damon/reclaim: fix 'enabled' is incorrectly set because 'system_wq' is not initialized
Date: Fri, 15 Jul 2022 06:16:09 +0000	[thread overview]
Message-ID: <20220715061609.48463-1-songyuanzheng@huawei.com> (raw)

The 'enabled' will be incorrectly set because the 'system_wq'
might not initialized yet. This results in 'enabled=true',
but the 'damon_reclaim_timer' is inactive. So fix it by moving
the judgment logic of the 'damon_reclaim_initialized' to the
start position of the enable_store().

Fixes: 294928293813 ("mm/damon/reclaim: schedule 'damon_reclaim_timer' only after 'system_wq' is initialized")
Signed-off-by: Yuanzheng Song <songyuanzheng@huawei.com>
---
 mm/damon/reclaim.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
index e69b807fefe4..b13d5a02bf2e 100644
--- a/mm/damon/reclaim.c
+++ b/mm/damon/reclaim.c
@@ -374,13 +374,14 @@ static bool damon_reclaim_initialized;
 static int damon_reclaim_enabled_store(const char *val,
 		const struct kernel_param *kp)
 {
-	int rc = param_set_bool(val, kp);
-
-	if (rc < 0)
-		return rc;
+	int rc;
 
 	/* system_wq might not initialized yet */
 	if (!damon_reclaim_initialized)
+		return -EINVAL;
+
+	rc = param_set_bool(val, kp);
+	if (rc < 0)
 		return rc;
 
 	schedule_delayed_work(&damon_reclaim_timer, 0);
-- 
2.25.1



             reply	other threads:[~2022-07-15  6:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15  6:16 Yuanzheng Song [this message]
2022-07-15 17:07 ` SeongJae Park
2022-07-18  4:48   ` songyuanzheng

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=20220715061609.48463-1-songyuanzheng@huawei.com \
    --to=songyuanzheng@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox