From patchwork Wed Mar 30 10:53:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghyeon Kim X-Patchwork-Id: 12795687 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 9DA04C433F5 for ; Wed, 30 Mar 2022 10:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C684A8D0002; Wed, 30 Mar 2022 06:53:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C17388D0001; Wed, 30 Mar 2022 06:53:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB7628D0002; Wed, 30 Mar 2022 06:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id 98B6E8D0001 for ; Wed, 30 Mar 2022 06:53:15 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5AA921828D812 for ; Wed, 30 Mar 2022 10:53:15 +0000 (UTC) X-FDA: 79300740750.21.D67141D Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf07.hostedemail.com (Postfix) with ESMTP id 80E2F40008 for ; Wed, 30 Mar 2022 10:53:14 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id t5so18367040pfg.4 for ; Wed, 30 Mar 2022 03:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajou.ac.kr; s=google; h=from:to:cc:subject:date:message-id; bh=09LiY6XuBkhT7pabOtfcUnjYwotME+n6Ic9O13LnSSA=; b=YVcf70VGphWsI/5biiq1XHZ2pbFA79z1X1ISPB7HVxClJ1DTfdktvBdsuBEh41nt/T fXyFFu+jysgu+abv/RqgPyBi7t7ZjVa0eLu5LSwHwmKeh83/vd/rv8UIm7z8T9U2nmjZ wVv0SO4Od6P9tVsBsfVr1xQFwK8h2e7jzAwQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=09LiY6XuBkhT7pabOtfcUnjYwotME+n6Ic9O13LnSSA=; b=NQTlLpzm80rvaUZRT6XJId/oCPFqo/Vk5yC78djWV8PcLS8nGUzyKasluER8czLs1J LJFY7SIzmmVC9yklehpnaFL8P7OujeDAeqpqrvvVCNAUmCic9zDNKUYSa61H72txWn7z pRxJUWGRnErKhIW2bvc06tphuuFvswyMMV8WhHJbVlW/MUyr2c01HqQ8KkVpzUK7QBcP /12grTd/Gh4X03U5qPC2evACMR44ss821sQVvR1W3gbZpDOKfUjsXbKP32SwQFhNoX/6 Oq8LHuZXY+1UyVzEMnioDCUG2bgBU41wAZpEd0HNWT+lrZ5znUn4EXlgypzX4uCJsmYV XZ4Q== X-Gm-Message-State: AOAM533qIp9KqFjUsFEZ9Zvs7kNWXnyif8QRMcwWWqu4ItRcZw6I4pYM hvMqvimz59UcOMZ2IEXWfDOdwQ== X-Google-Smtp-Source: ABdhPJyFVgfcMCHcqtfZCNB0z/EGqFUB/eVb7kFxzaNAfKtXvkx/kpQBdPGb6Y6QUVuVfK4opXM6NA== X-Received: by 2002:a63:78ca:0:b0:398:ae5:6515 with SMTP id t193-20020a6378ca000000b003980ae56515mr5763459pgc.345.1648637592923; Wed, 30 Mar 2022 03:53:12 -0700 (PDT) Received: from localhost.localdomain ([210.107.197.32]) by smtp.googlemail.com with ESMTPSA id ij17-20020a17090af81100b001c67c964d93sm7373967pjb.2.2022.03.30.03.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 03:53:12 -0700 (PDT) From: Jonghyeon Kim To: SeongJae Park Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jonghyeon Kim Subject: [PATCH] mm/damon: prevent activated scheme from sleeping by deactivated schemes Date: Wed, 30 Mar 2022 19:53:02 +0900 Message-Id: <20220330105302.32114-1-tome01@ajou.ac.kr> X-Mailer: git-send-email 2.17.1 X-Rspam-User: X-Stat-Signature: 9o8qj7xujqw47kgz66zd3grprgbdg94t Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=ajou.ac.kr header.s=google header.b=YVcf70VG; spf=pass (imf07.hostedemail.com: domain of tome01@ajou.ac.kr designates 209.85.210.177 as permitted sender) smtp.mailfrom=tome01@ajou.ac.kr; dmarc=pass (policy=reject) header.from=ajou.ac.kr X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 80E2F40008 X-HE-Tag: 1648637594-771970 X-Bogosity: Ham, tests=bogofilter, spamicity=0.028999, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. This commit prevents making DAMON monitoring inactive state due to other deactivated schemes. Signed-off-by: Jonghyeon Kim Reviewed-by: SeongJae Park --- 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;