Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp36649iob; Mon, 2 May 2022 12:23:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKhNxh2Hwxl5zBoSKsVfT3fkfowooImRLRaM18Z5mUW+mVed4+tXd62k3Ty04qCL9QKjXk X-Received: by 2002:a2e:9108:0:b0:24f:1301:6697 with SMTP id m8-20020a2e9108000000b0024f13016697mr8433672ljg.94.1651519391685; Mon, 02 May 2022 12:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651519391; cv=none; d=google.com; s=arc-20160816; b=Zsmpzs9P/Gin8a3q0fafs2OEiCsP2bjWWJHsxCRd/0ZVh+cnMUIfG3gzuLVYLhqqHr nmcILCUbDBO3QFwYpEx9pm7ByC5H3zI3OiMPYpLHeaSOyb/+TeST4ZK4wzcGxhbuPFOA YZGCUr4bjg/Q/p01qSrL2v/Lc7uvoxczU3KCKsFhWLOlbrt+oYeVXMUIq9Yrxvi8M9OF PRDS00T/Oz8ohEvNz0e5LlwTAQQko1C0PrdJXFaX04V5J1pl4+ZC+BtfehbVL2bbLn84 RV5ipT3NJMU3PlJ3VNOiVw8K2zpxzz2TvQKxMq9n43XY94POvp6sYsbYQsjseo6gmQD/ 3ijA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6LHca2qVVWwMVfpl2M6lQukYbFn+ToVMEueej5VNym8=; b=iqP3V0TgK8vhj0EcLHSrlN5n8twojse29gzP5ccArfBz8UBWTTpIEdI6e6/wLZvR7L S+aLZ9apfN8H4kSJWr14pAvz0UGYWA0cCrfT7xlzizbO3eWgTNuELlsexUy9vQQCcHVy 2k5Nn6Se5B8uaqpxKxMR9d1CBc0u77fOMQHGVp6otN17FP+0/7OcXB8DpGPYquqxinJe /1BMxabrncklFNc6j4cYYOV+Il0+TVwIEDg3Y7qu4XRXAk+KtnpZFUV+fRKDhWgSagKd aXAZrRQUXK9/LbvYxZgQjjGOqMV0m/p5XEmjjJXwuffDkveoEbwlhWa9KQFXkmVtnZ6p 4P1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CYTSY51U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w25-20020a197b19000000b00449fff2825bsi15220026lfc.477.2022.05.02.12.22.41; Mon, 02 May 2022 12:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CYTSY51U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378825AbiD2QJj (ORCPT + 99 others); Fri, 29 Apr 2022 12:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245744AbiD2QJg (ORCPT ); Fri, 29 Apr 2022 12:09:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49657996BD for ; Fri, 29 Apr 2022 09:06:17 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id D95A46229E for ; Fri, 29 Apr 2022 16:06:16 +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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.25.1