Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2969414imw; Sun, 17 Jul 2022 22:22:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t+W3we6sGXFpY+PTTjCwZ2aPGbPrRrp6TE1JEXhNbV4LGhjLcNlk2OwqdV0JOqhVRb+RTl X-Received: by 2002:a05:6402:c44:b0:431:52cc:f933 with SMTP id cs4-20020a0564020c4400b0043152ccf933mr34846153edb.41.1658121725128; Sun, 17 Jul 2022 22:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658121725; cv=none; d=google.com; s=arc-20160816; b=TOARhV0culpsnXPgRLpw67FSotpI1yN5wiGVEmVA8aUKMc3NMg6MrswyYTFc1Cj/Pe pUtUh6uOQ+IghAYVOkbt6vug+i6ECp9HqEQxLSvYn3jfgiSVItbbYVSr9yj1OAo8e80s W9DyuDoWXZwRmUVGsQF4WJ1qcdVIWyxaG0maB6N67xijB8/Ug4pLqPru6+I8MULH1x+t u8LeL0Mkk+/h8+faSgcHYreYX/Mg3MUSBJTVBQaVsfr+VnImZ+p8M4jJnS80wVZPHFIe qCR82LE/q3ZPXNpbuMeHcPZX1Rl8OfRmXtcd0iGwoUcw5vITCqFlC3cxVsHf9zrzUpY6 CdJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=efyOn5Iyccp9Sn9cv+wdmggZFCofgEvrxnH26D8kk64=; b=eONMb22o5Bj6q3h294PYPkS7VeBtU4W6FYSLimygyYCZfHtAHma/tYHcznrK2vQ35r UHFfVFS1jN3rR0KP9nF7t2mPbAjVhhor0Ii6oPLqO4TWib/gDFOH0PnO1wSb4XvsIPxY A3am7LsMoPXp9JdRR6YuEgJXtYnP7m9xrfqVd31LYGQOu/yACDJVKbvaWbhcXbTjr07x 5ggwF8VAOJeNwPqfMW+8sTTXrIKxYiqfiD+wvKUn8Oy9WKw912QiL5kmdzlSgMiAdPoX bHlpSw70OXYo8vWWHXsk89kLO0L4JdfVFSmpgkf0HeBCKE1N8z6h4c1UETBGKUQ6QaMw mI/w== 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 hd33-20020a17090796a100b006ff09d27800si15863959ejc.536.2022.07.17.22.21.40; Sun, 17 Jul 2022 22:22:05 -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 S233061AbiGREsh (ORCPT + 99 others); Mon, 18 Jul 2022 00:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbiGREsf (ORCPT ); Mon, 18 Jul 2022 00:48:35 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A031710574 for ; Sun, 17 Jul 2022 21:48:34 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LmTtR3xvKzjX0R; Mon, 18 Jul 2022 12:45:51 +0800 (CST) Received: from [10.174.179.110] (10.174.179.110) 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; Mon, 18 Jul 2022 12:48:32 +0800 Message-ID: <250ec3d9-6fec-a051-6d9a-24b265fa0a57@huawei.com> Date: Mon, 18 Jul 2022 12:48:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH] mm/damon/reclaim: fix 'enabled' is incorrectly set because 'system_wq' is not initialized Content-Language: en-US To: SeongJae Park CC: , , , References: <20220715170736.126498-1-sj@kernel.org> From: songyuanzheng In-Reply-To: <20220715170736.126498-1-sj@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.110] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 Hello SJ, Thank you very much for your reply, through your reply let me understand this principle, so please ignore this patch. Thanks, Yuanzheng On 2022/7/16 1:07, SeongJae Park wrote: > Hello Yuanzheng, > > > On Fri, 15 Jul 2022 06:16:09 +0000 Yuanzheng Song wrote: > >> 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(). > Thank you for this patch! > > In the case, however, 'damon_reclaim_init()' will activate > 'damon_reclaim_timer', which will check the 'enabled' and start DAMON later. > So 'enabled' will inconsistently set while DAMON_RECLAIM is not really enabled > for a moment, but those will eventually be consistent. This patch could reduce > the duration of the inconsistent state. > > However, this would break boot-time DAMON_RECLAIM enabling, which adds > 'damon_reclaim.enabled=true' to the kernel parameter, as this change will set > 'enabled' as 'false' in the early 'damon_reclaim_enabled_store()', so that the > later 'damon_reclaim_initialized()' activated 'damon_reclaim_timer' shows > 'enabled' as 'false' and therefore doesn't start DAMON. > > If there is anything I'm missing, please let me know. > > > Thanks, > SJ > >> 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 > .