From mboxrd@z Thu Jan 1 00:00:00 1970 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 0D7BAC433EF for ; Mon, 18 Jul 2022 04:48:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749576B0075; Mon, 18 Jul 2022 00:48:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F7366B0078; Mon, 18 Jul 2022 00:48:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60D546B007D; Mon, 18 Jul 2022 00:48:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4DE886B0075 for ; Mon, 18 Jul 2022 00:48:38 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0F1546F7 for ; Mon, 18 Jul 2022 04:48:38 +0000 (UTC) X-FDA: 79698989916.14.865E82E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id DBDE1140066 for ; Mon, 18 Jul 2022 04:48:36 +0000 (UTC) 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 ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of songyuanzheng@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=songyuanzheng@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658119717; a=rsa-sha256; cv=none; b=uEubnbB9H1dmz6Z4lbs9JaDRrlh+MNXEpzo7dnqRXfdK2Ebn2JdoFx89RjuSa3jwe06nAq QF329+wvaERHeD6/ZxGSNc0clpaAcGiAXLnhkKavnC5lWt/eVTOwM0UWf6cBJhBjeVpciw Aiq2ypmcCdaJ+fIFUiNOiXievHSKzfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658119717; 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:in-reply-to:references:references; bh=efyOn5Iyccp9Sn9cv+wdmggZFCofgEvrxnH26D8kk64=; b=uozNghaSYCwAGDEkfxnpHUkkClw2o/9bXx3U8whIqXIh49gvrFhYUHr0FBvsHVfiWIEEgy F5JkTVvZWnsGQUT7Pn6b0k4aX15kYN3NMNvfYtnMokSFa6g0omm/jh95ckMiGTlFsL/+j2 nuJiSK9jlpII8JUbrk2OCrhVtj8yt8M= Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of songyuanzheng@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=songyuanzheng@huawei.com X-Rspam-User: X-Stat-Signature: 1wahrboscq3jwk56efc3pp57zw5f56fk X-Rspamd-Queue-Id: DBDE1140066 X-Rspamd-Server: rspam03 X-HE-Tag: 1658119716-878043 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: 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 > .