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 B63C2C6FA83 for ; Tue, 13 Sep 2022 09:12:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A4706B0075; Tue, 13 Sep 2022 05:12:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 452E16B0078; Tue, 13 Sep 2022 05:12:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27EA96B007B; Tue, 13 Sep 2022 05:12:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0FCBC6B0075 for ; Tue, 13 Sep 2022 05:12:35 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D76DE4011B for ; Tue, 13 Sep 2022 09:12:34 +0000 (UTC) X-FDA: 79906496628.17.6ACF254 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf29.hostedemail.com (Postfix) with ESMTP id 9BED61200DA for ; Tue, 13 Sep 2022 09:12:34 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id a80so2557966pfa.4 for ; Tue, 13 Sep 2022 02:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date; bh=hx151K56M/3bv6oAI9HhJMBBMiJc3yf10YF7//PgZEk=; b=FPiNmlQPMV6NfeIj+gceFZdllChsvPQx/1lJNqCJqvVP1c58jZuGu813kkSzCyz2hx Tper+kYL1VSI/1saYTXNGGszfUXJw/+hQ49l5F35wUbzN6l3P2fCHgkoHwjUrA/dOrYe KM8zByWZ7tnHjBJt+4FJFDoqMGJ2rOU791TH/tWsF8g2wu/F0qgHUr4YwofAw6sCagNs /zYA5OGN1J2rN2Kvg9qlxnXoC3BXR8vo82K8BZzG10yRyZkz7wyfSMvaDwgGJfWDBNai wR56e95dlv9L9cWF/2Q70PbCH68161V+YbnP/71/BhGm96EC0lGcuqA/94jAnWX5YspB Br0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date; bh=hx151K56M/3bv6oAI9HhJMBBMiJc3yf10YF7//PgZEk=; b=GvyOb+jqYh50vtBY0YH59BKDShZLNXUTpGgLwVhwvnZ9Lk7DUe+TI8gviKtkcarjdq QSBx7jGJXaIn30bVT90Kx85U4XZ+8cB7lvbV7okU0VV7QPuzVN2qJ7R8OzXOcWr+iyc0 wgSizs8SPuQ+i8P5vAAzGwZEIeznjBrDIE/tTLRGMTbqQsGyyZySPrkNm3EObcsNAjxx Oc+YFtcMmxx0tO7BfzXqSgG9JmnoM9/fjhqI26JcvSnhdvCUuMYi0R8C/yQ09PdDljps g5yE/SIkh+VHsVsYpp66mIlVtStC584eQTtKavrOTBUEpRbyxCHylm2tQQNtWu+zss2y sCfQ== X-Gm-Message-State: ACgBeo0vNB6RNz/Uzv0b1vRPtEDs/xibQBUcUps8HnF+96RzEeHGmTB+ sTxhvPfDJJAKF3jXfU0JRQ== X-Google-Smtp-Source: AA6agR5+BtVH+Z9KVlL41Vvl5mVJIMp8QHiYV3uVzGpz9IGkyui/fsI188gxmT54nqYnyGte46kSbg== X-Received: by 2002:a62:2503:0:b0:538:426a:af11 with SMTP id l3-20020a622503000000b00538426aaf11mr32167439pfl.22.1663060353757; Tue, 13 Sep 2022 02:12:33 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.3]) by smtp.gmail.com with ESMTPSA id h10-20020a170902680a00b0015e8d4eb1d5sm7804661plk.31.2022.09.13.02.12.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2022 02:12:33 -0700 (PDT) From: xiakaixu1987@gmail.com X-Google-Original-From: kaixuxia@tencent.com To: sj@kernel.org, akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kaixu Xia Subject: [PATCH 3/4] mm/damon/core: simplify the kdamond stop mechanism by removing 'done' Date: Tue, 13 Sep 2022 17:11:26 +0800 Message-Id: <1663060287-30201-4-git-send-email-kaixuxia@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663060287-30201-1-git-send-email-kaixuxia@tencent.com> References: <1663060287-30201-1-git-send-email-kaixuxia@tencent.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663060354; a=rsa-sha256; cv=none; b=2IJQ+vqdLQBZ79/S/OO2cSlvOv4O8fEE28AKqX7+qCE3nllFw8GoIVXuhbXlUhb7vb20B1 wv9Vf+pWs5mGGYT/M6Tden/D20B3N18bLblMraZFrkyQDqbPLzjLgeQoA9UQu5YFQW+UM4 j/fc8giNUGY0TRp3iLWiM/r89cWYXmQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FPiNmlQP; spf=pass (imf29.hostedemail.com: domain of xiakaixu1987@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=xiakaixu1987@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663060354; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=hx151K56M/3bv6oAI9HhJMBBMiJc3yf10YF7//PgZEk=; b=i0/pGCFdz6a7wLo08m7BU/gIzpeSzJjMnqs3yOVsuPVN727INES3CtFBGWzb57r3ZsEwEZ NxNHVLYHWFOupXjvKiPeyqxOIitJqBbSq9bPx/0buZ4/cnJ9GX41JhSsCAwQrJ37bTr6TB up/TGcrSuYW6uHLZCpnFZZUmxM2h/ww= X-Stat-Signature: uzrx8ag6chxh7y6uc3ebs9rwommir53h X-Rspamd-Queue-Id: 9BED61200DA Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FPiNmlQP; spf=pass (imf29.hostedemail.com: domain of xiakaixu1987@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=xiakaixu1987@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1663060354-764268 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: Kaixu Xia When the 'kdamond_wait_activation()' function or 'after_sampling()' or 'after_aggregation()' DAMON callbacks return an error, it is unnecessary to use bool 'done' to check if kdamond should be finished. This commit simplifies the kdamond stop mechanism by removing 'done' and break the while loop directly in the cases. Signed-off-by: Kaixu Xia --- mm/damon/core.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 0b1eb945c68a..4ce860af70ec 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1165,30 +1165,25 @@ static int kdamond_fn(void *data) struct damon_region *r, *next; unsigned int max_nr_accesses = 0; unsigned long sz_limit = 0; - bool done = false; pr_debug("kdamond (%d) starts\n", current->pid); if (ctx->ops.init) ctx->ops.init(ctx); if (ctx->callback.before_start && ctx->callback.before_start(ctx)) - done = true; + goto done; sz_limit = damon_region_sz_limit(ctx); - while (!kdamond_need_stop(ctx) && !done) { - if (kdamond_wait_activation(ctx)) { - done = true; - continue; - } + while (!kdamond_need_stop(ctx)) { + if (kdamond_wait_activation(ctx)) + break; if (ctx->ops.prepare_access_checks) ctx->ops.prepare_access_checks(ctx); if (ctx->callback.after_sampling && - ctx->callback.after_sampling(ctx)) { - done = true; - continue; - } + ctx->callback.after_sampling(ctx)) + break; kdamond_usleep(ctx->sample_interval); @@ -1200,10 +1195,8 @@ static int kdamond_fn(void *data) max_nr_accesses / 10, sz_limit); if (ctx->callback.after_aggregation && - ctx->callback.after_aggregation(ctx)) { - done = true; - continue; - } + ctx->callback.after_aggregation(ctx)) + break; kdamond_apply_schemes(ctx); kdamond_reset_aggregated(ctx); kdamond_split_regions(ctx); @@ -1217,6 +1210,7 @@ static int kdamond_fn(void *data) sz_limit = damon_region_sz_limit(ctx); } } +done: damon_for_each_target(t, ctx) { damon_for_each_region_safe(r, next, t) damon_destroy_region(r, t); -- 2.27.0