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 674E2C433EF for ; Wed, 30 Mar 2022 11:55:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AA6C8D0002; Wed, 30 Mar 2022 07:55:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 958C18D0001; Wed, 30 Mar 2022 07:55:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 821508D0002; Wed, 30 Mar 2022 07:55:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 75DD98D0001 for ; Wed, 30 Mar 2022 07:55:23 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 29C9F182B0300 for ; Wed, 30 Mar 2022 11:55:23 +0000 (UTC) X-FDA: 79300897326.27.42F71DF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf27.hostedemail.com (Postfix) with ESMTP id 9185740019 for ; Wed, 30 Mar 2022 11:55:22 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 921B7B81BBA; Wed, 30 Mar 2022 11:55:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF547C340EE; Wed, 30 Mar 2022 11:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648641319; bh=1HPyfRo5DHhp9R70XYYumzCEapXTyvDbHoQuEdQvgE8=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=Jl094britH6ONTd25NFMz9UnjM6d2m3/9NnfHo46z3Um8fGDWUcOui/GLBWC38RRA xdE6zLhqI6xQgQ2ZJgjbF3yoRsb7ht61yQaMVgXHfKp79I2dGR8JnZa2KUY3DGVHC7 Jp+gUYYD3n/3EEpx7/3BztsEaTT5caTyvoW60YurT+x3gYc1bV50tKoekAHRvDxLx2 Qn/ugnd6Z2FxOrF8T8+ZfHbQfAofOwn9qYza0QbhfeHznqAkPiVuHV+xUctk/M9Xno UAkVENvrobHHp5JLTjRooFbFs2hb1AtvPzz18PhHorKwvs8Ql9qGbEFbJLp7tJEwa0 Kg4JC23/KGPhQ== From: sj@kernel.org To: Jonghyeon Kim Cc: SeongJae Park , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/damon: prevent activated scheme from sleeping by deactivated schemes Date: Wed, 30 Mar 2022 11:55:16 +0000 Message-Id: <20220330115516.32126-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220330105302.32114-1-tome01@ajou.ac.kr> X-Stat-Signature: uqb976uj34a4ady1hywby6kqorgseaqq Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jl094bri; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9185740019 X-HE-Tag: 1648641322-375471 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000024, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Jonghyeon, On Wed, 30 Mar 2022 19:53:02 +0900 Jonghyeon Kim wrote: > In the DAMON, the minimum wait time of the schemes decides whether the > kernel wakes up 'kdamon_fn()'. But since the minimum wait time is > initialized to zero, there are corner cases against the original objective. > > For example, if we have several schemes for one target, and if the wait > time of the first scheme is zero, the minimum wait time will set zero, > which means 'kdamond_fn()' should wake up to apply this scheme. However, > in the following scheme, wait time can be set to non-zero. Thus, the > mininum wait time will be set to non-zero, which can cause sleeping this > interval for 'kdamon_fn()' due to one deactivated last scheme. Good catch, thanks! > > This commit prevents making DAMON monitoring inactive state due to other > deactivated schemes. > > Signed-off-by: Jonghyeon Kim Reviewed-by: SeongJae Park Thanks, SJ > --- > mm/damon/core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/mm/damon/core.c b/mm/damon/core.c > index c1e0fed4e877..5ce8d7c867f0 100644 > --- a/mm/damon/core.c > +++ b/mm/damon/core.c > @@ -1019,12 +1019,15 @@ static int kdamond_wait_activation(struct damon_ctx *ctx) > struct damos *s; > unsigned long wait_time; > unsigned long min_wait_time = 0; > + bool init_wait_time = false; > > while (!kdamond_need_stop(ctx)) { > damon_for_each_scheme(s, ctx) { > wait_time = damos_wmark_wait_us(s); > - if (!min_wait_time || wait_time < min_wait_time) > + if (!init_wait_time || wait_time < min_wait_time) { > + init_wait_time = true; > min_wait_time = wait_time; > + } > } > if (!min_wait_time) > return 0; > -- > 2.17.1 >