From patchwork Fri Jul 15 06:16:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanzheng Song X-Patchwork-Id: 12918768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C394C433EF for ; Fri, 15 Jul 2022 06:17:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A202D9401CC; Fri, 15 Jul 2022 02:17:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D14A9401A5; Fri, 15 Jul 2022 02:17:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C0209401CC; Fri, 15 Jul 2022 02:17:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 79B5C9401A5 for ; Fri, 15 Jul 2022 02:17:10 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 4967D1201A1 for ; Fri, 15 Jul 2022 06:17:10 +0000 (UTC) X-FDA: 79688326620.02.9977495 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf05.hostedemail.com (Postfix) with ESMTP id A5EB2100048 for ; Fri, 15 Jul 2022 06:17:08 +0000 (UTC) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lkh1C0SQDzlVvF; Fri, 15 Jul 2022 14:15:27 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 15 Jul 2022 14:17:03 +0800 From: Yuanzheng Song To: , CC: , , 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 Message-ID: <20220715061609.48463-1-songyuanzheng@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500026.china.huawei.com (7.185.36.106) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657865829; a=rsa-sha256; cv=none; b=qYJQ3nRfc441Xa70HJHY+R5cpT0ROAquqGjM3R7sjB2CbSSy7pkFKsfIs4F4778AKF4hvX tvnEYwF0s5uDLpdJfRud5oi55smm0jxuO+cpDBJ+zmq6ShGlZYGkSxmpwbraeWN0+ElY7m H8ir28ZbULrw7s2srx98/es0Xw0JLM4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of songyuanzheng@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=songyuanzheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657865829; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=zIyVGdRq9TetUm9wYd2r788a2plArOQXaYNyVwg5FME=; b=McSSulZ2/Ro0eB1Hr+eRE45auu+N3Oah98kk9km2E5yW4yGg7U6LQD/FspBD5tzJZEviTk kZOloZI0vFw7wZXRSQiOpsxT1Jb6xw8HqhXN81xNrwwiMlaZZ0D0+HuijsQdyKeScf4Njg Xx4WmbxVl3zbX+OFhy+IFSfwYz2Tm7M= X-Rspam-User: X-Rspamd-Queue-Id: A5EB2100048 Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of songyuanzheng@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=songyuanzheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam04 X-Stat-Signature: a65z8wbyj1heg8rsiwxojyoq158jgfsw X-HE-Tag: 1657865828-905051 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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);