From patchwork Fri Dec 10 22:46:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12671269 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 CC44BC433F5 for ; Fri, 10 Dec 2021 22:49:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F6B96B007D; Fri, 10 Dec 2021 17:46:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A18D6B007E; Fri, 10 Dec 2021 17:46:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36E2B6B0080; Fri, 10 Dec 2021 17:46:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 26A7A6B007D for ; Fri, 10 Dec 2021 17:46:39 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DEE6E180C3C5A for ; Fri, 10 Dec 2021 22:46:28 +0000 (UTC) X-FDA: 78903370056.22.72D80C8 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id 7B9AE1A0009 for ; Fri, 10 Dec 2021 22:46:28 +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 42D89B82A0F; Fri, 10 Dec 2021 22:46:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D744C00446; Fri, 10 Dec 2021 22:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1639176385; bh=xc+JETihgXXiqFz+VxJKnyLRp8GtucnyUYHiLi2tBko=; h=Date:From:To:Subject:In-Reply-To:From; b=wKkojB9qiP7L8VhAuqE8tbOQLuu6A7HnEMTqWibjBuoWcIShSrua/HVUrPvRy8tcJ tpBhJD9LmgkFyZ21EJ7Yv79wLepROv2EbHRqCrgT+wc0+JzDKA2fAdprQSXFQzmOSI DPsQPm+YvPun06Qrkm9f0ZZjpOdWGtj3zCmlGK/A= Date: Fri, 10 Dec 2021 14:46:25 -0800 From: Andrew Morton To: akpm@linux-foundation.org, john.stultz@linaro.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, oleksandr@natalenko.name, sj@kernel.org, stable@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org Subject: [patch 06/21] mm/damon/core: fix fake load reports due to uninterruptible sleeps Message-ID: <20211210224625.aHoRXImMJ%akpm@linux-foundation.org> In-Reply-To: <20211210144539.663efee2c80d8450e6180230@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7B9AE1A0009 X-Stat-Signature: fsz93wxnbjmiae1nw3pnfeds85g16m15 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=wKkojB9q; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1639176388-43591 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: From: SeongJae Park Subject: mm/damon/core: fix fake load reports due to uninterruptible sleeps Because DAMON sleeps in uninterruptible mode, /proc/loadavg reports fake load while DAMON is turned on, though it is doing nothing. This can confuse users[1]. To avoid the case, this commit makes DAMON sleeps in idle mode. [1] https://lore.kernel.org/all/11868371.O9o76ZdvQC@natalenko.name/ Link: https://lkml.kernel.org/r/20211126145015.15862-3-sj@kernel.org Fixes: 2224d8485492 ("mm: introduce Data Access MONitor (DAMON)") Reported-by: Oleksandr Natalenko Signed-off-by: SeongJae Park Tested-by: Oleksandr Natalenko Cc: John Stultz Cc: Thomas Gleixner Cc: Signed-off-by: Andrew Morton --- mm/damon/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/mm/damon/core.c~mm-damon-core-fix-fake-load-reports-due-to-uninterruptible-sleeps +++ a/mm/damon/core.c @@ -981,9 +981,9 @@ static unsigned long damos_wmark_wait_us static void kdamond_usleep(unsigned long usecs) { if (usecs > 100 * 1000) - schedule_timeout_interruptible(usecs_to_jiffies(usecs)); + schedule_timeout_idle(usecs_to_jiffies(usecs)); else - usleep_range(usecs, usecs + 1); + usleep_idle_range(usecs, usecs + 1); } /* Returns negative error code if it's not activated but should return */ @@ -1038,7 +1038,7 @@ static int kdamond_fn(void *data) ctx->callback.after_sampling(ctx)) done = true; - usleep_range(ctx->sample_interval, ctx->sample_interval + 1); + kdamond_usleep(ctx->sample_interval); if (ctx->primitive.check_accesses) max_nr_accesses = ctx->primitive.check_accesses(ctx);