From patchwork Fri Apr 29 16:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12832415 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 8DE14C433EF for ; Fri, 29 Apr 2022 16:06:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D22E66B0080; Fri, 29 Apr 2022 12:06:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C83276B0081; Fri, 29 Apr 2022 12:06:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B23896B0082; Fri, 29 Apr 2022 12:06:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 8F2356B0081 for ; Fri, 29 Apr 2022 12:06:19 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 64FE96072D for ; Fri, 29 Apr 2022 16:06:19 +0000 (UTC) X-FDA: 79410393678.01.578AB4E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id 9A94A40013 for ; Fri, 29 Apr 2022 16:06:09 +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 A7A59B83642; Fri, 29 Apr 2022 16:06:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1535C385A7; Fri, 29 Apr 2022 16:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651248376; bh=dPUAlly+rInfVlu/ufebngY5ioNrRJjd5E6QpTd4Srg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CYTSY51Ulp0QzoV2sDDdn8KZsT+ADsb++kwqoUqlkbCnn1OiUkZP/5BnOm1IrdGg0 apCvBrHNZHDI1Lk0CSW2zYGJIYZFPp805kh9YUf1lb6uVDV3MBFc3HSee/xCOQW1wo 3nch0GQE60Agc3hIYAjae0fzGvrUKnCITX0A1JwsmT+NZXaR4MSmre0HnoFnBEmB54 fUhIrZuVC9p0iigmRl5oLwLkJ/hLX1ddk+YMSaXXPa5cH/YgUkrZuft+N2S0zaU6Ox fDWjnElzn3XPezgyVBs2eakE3exicQTJaP4cv9mwonlBwbBgbDDpSK5kPb5iNMtKdl EjO9Mgdm3wDzg== From: sj@kernel.org To: akpm@linux-foundation.org Cc: linux-damon@amazon.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 02/14] mm/damon/core: finish kdamond as soon as any callback returns an error Date: Fri, 29 Apr 2022 16:05:54 +0000 Message-Id: <20220429160606.127307-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220429160606.127307-1-sj@kernel.org> References: <20220429160606.127307-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9A94A40013 X-Stat-Signature: h633849kfao1n1kki9zwoxig6ddkjf6k Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CYTSY51U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1651248369-957825 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 When 'after_sampling()' or 'after_aggregation()' DAMON callbacks return an error, kdamond continues the remaining loop once. It makes no much sense to run the remaining part while something wrong already happened. The context might be corrupted or having invalid data. This commit therefore makes kdamond skips the remaining works and immediately finish in the cases. Signed-off-by: SeongJae Park --- mm/damon/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index e28fbc3a1969..18c08e90563e 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1141,8 +1141,10 @@ static int kdamond_fn(void *data) if (ctx->ops.prepare_access_checks) ctx->ops.prepare_access_checks(ctx); if (ctx->callback.after_sampling && - ctx->callback.after_sampling(ctx)) + ctx->callback.after_sampling(ctx)) { done = true; + continue; + } kdamond_usleep(ctx->sample_interval); @@ -1154,8 +1156,10 @@ static int kdamond_fn(void *data) max_nr_accesses / 10, sz_limit); if (ctx->callback.after_aggregation && - ctx->callback.after_aggregation(ctx)) + ctx->callback.after_aggregation(ctx)) { done = true; + continue; + } kdamond_apply_schemes(ctx); kdamond_reset_aggregated(ctx); kdamond_split_regions(ctx);