Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp148662imw; Thu, 14 Jul 2022 23:25:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vjugeDF1d+/uIoyyejE/rLlMR98LLkDWUJREvVS4JJwuBtGpkoQTW8wP17rEWQMxFdde0n X-Received: by 2002:a17:902:d50a:b0:16c:5490:163c with SMTP id b10-20020a170902d50a00b0016c5490163cmr11935567plg.31.1657866353801; Thu, 14 Jul 2022 23:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657866353; cv=none; d=google.com; s=arc-20160816; b=TXCdJLj8havVeylnsOBYn3MeoWW5UqoKQEauFgweqgznzqCROhKtr1qRFPSlxunLyn qCOppk4F6DVYB9tYkmKJ6+xRC+VFHJ7lmK4oR04xJ/ckkuBt3k3rnK2eHhV2kCV53FD/ PGAAmb559iwtnFIuoRgqhwLCx0MUFd/udGVifcGWLgDE3U672k7ltY9FDnn+jA8BB4de sJjxZYUHlR94Oa4H1wB9nUbhbhJMcMfXCk6R7v0LxHSqa2N0jve4H65WfefL9eLJQMqx wLtYz+O/Wd7mGrIlhZgKRxhWf0V6G2v9huJ16R+yYDCjlxtnMGtabC3YAPOtuBh83SDa ZVNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zIyVGdRq9TetUm9wYd2r788a2plArOQXaYNyVwg5FME=; b=bg6tkXt/YsckAsB58tZeD2IDg2tF+PFHW8ql4OwV1fmM5mIc1zV3wDXaY2Zbq2y/zI HL00RZGB7LtY50eQHfrI1k0z3OOAFPfHR73vB6TGIwwXpTuDpLyKBNHn9O4tbY6+ILcp 1LZvZQImJUwVHpY9LIiNytPQQfv15KG8LxrgNRwmcT7V0aWTt/v6meGsTQvScrrGslwt FWZU9CJ24erP+l1Izl2zCTIzU7LA1FSU017YkshppPp1Xo6P68p9Smcw5YtnMMxjMYGa ASkYkUEMyohHEjCpOFT4AKL+1JmBDzYVebaX3xWtLnUgnaWGEEfx9k/4sgPDZhqrpGyb 8xpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a6544c6000000b004125addbbc9si4527181pgs.470.2022.07.14.23.25.38; Thu, 14 Jul 2022 23:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbiGOGRI (ORCPT + 99 others); Fri, 15 Jul 2022 02:17:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiGOGRH (ORCPT ); Fri, 15 Jul 2022 02:17:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7EF1DB3 for ; Thu, 14 Jul 2022 23:17:05 -0700 (PDT) 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.25.1