From patchwork Mon Oct 24 20:49:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682910wru; Mon, 24 Oct 2022 15:33:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5njJkDukJ0PZSN2bwU2NGpDMKBowF69anSZku+J9ZK4v76C7rsnr649vMZa1dSlAG7Dgou X-Received: by 2002:a05:6402:3548:b0:45d:6506:990a with SMTP id f8-20020a056402354800b0045d6506990amr32905750edd.218.1666650795612; Mon, 24 Oct 2022 15:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650795; cv=none; d=google.com; s=arc-20160816; b=m+/rPITfp7PAZrzWkKMH5pQXwPZCaTGVwQ+jYW5F97jHMXrej5fa8/Q76tOCR8CDK3 6cd+h3yCa4wHD+XuTFKqX4VjeQ13ylFOeBphaddNc1mm6OWf3KC0xWXK5ocLgWAA/Lh4 Xn8i183oWzwwi4G0nRtMH1s3j1caS3abVwpxYblj3VJxAgCmFR+jnjVWsPGN6qa58jpf njGNrBk5sfAhr1Ew89w36zkU4MCZDNBqx/VpHwC75FF2rU4Z+OPOafqUcEa2p5bh0srz 2rA/DiDBdV+OM7K5scKt3QhkNJCNRbAX+rCnWQPPGRPWMDlxsrNGhf1+DBWzFnPvTEJB BtAw== 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=yUphVaM1VYW9wh/A0/sAzOrAe+7BWF4145DldAvvZ7w=; b=vnEtTpLD/vZPT7teCmjRYNBDdFq2bcvo0c4ZJYeIj+XTsZNkthpfx4RIbo/+pDjI62 8ixtEbApjpRZ1goGhzDD+aRmw30MIz/oNkCTHgcJCkzX+TfWwwq9m3M0tMfIAYDrL8Wj sX7Qi4ifX0loB810OMAXgOayJj2W3Avya2fmlJUmC0A5ZbZ1i4c03JtdNqADZw8dxacG ar7H66hTQnQp0J2bku2ubKyCVKh5tOHPU0pUkzk190rtia9xO49u5Gw7K8ChWoVpiUct JzA0oMfMfO+cJQaSewonlW8gbOWh2kdRbEACNtUOBzmWVLOGIS7LYsSa55Q1ysAwWRs6 93Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FyrbHG8N; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp14-20020a1709071b0e00b00787d0dfe70csi887462ejc.981.2022.10.24.15.32.52; Mon, 24 Oct 2022 15:33:15 -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=FyrbHG8N; 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 S231444AbiJXW2y (ORCPT + 99 others); Mon, 24 Oct 2022 18:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbiJXW2Z (ORCPT ); Mon, 24 Oct 2022 18:28:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99047CC81B for ; Mon, 24 Oct 2022 13:50:41 -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 5689F615B1 for ; Mon, 24 Oct 2022 20:49:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 675DBC433C1; Mon, 24 Oct 2022 20:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644566; bh=QMVnOfjAwBASqqnveYH7trvPbLLGctoJVzDXAjo2/8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FyrbHG8NuKtPFlidl5Tt0VxBwZ8AofU8nM31c9QRt1YL5zkER4eT2t+bWyQFKhWKT wgBvSYeXCu/SEO9HBwRLFHFnApLFi4fK3uolj7j1l3IYTVqMbJk9KgSUV3eycqs+4a KC2hn7UvUBfb8XgCKTXaMLzPZiQlY0bnvM9geXmAKP5qtIgFwfRH0WCeNUfMxxVou5 cwKA6edu910iaXY07Tg93RDb/xublLsnERZAR3rBuWGnbAN69bAVk9SIA7ZSVASkRu YFpx/0viFcOmQn1UAp4gY+geKqFA3VTlxr90CWiODhwqD/L8xsvKxyTks3Ye3twMom DLxObNmljhd7Q== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/11] mm/damon/core: split out scheme stat update logic into a new function Date: Mon, 24 Oct 2022 20:49:11 +0000 Message-Id: <20221024204919.18524-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610024585096376?= X-GMAIL-MSGID: =?utf-8?q?1747610024585096376?= The function for applying a given DAMON scheme action to a given DAMON region, 'damos_apply_scheme()' is not quite short. Make it better to read by splitting out the stat update logic into a new function. Signed-off-by: SeongJae Park --- mm/damon/core.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index c1a912bc46ae..3a810c6e26bc 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -755,6 +755,16 @@ static bool damos_skip_charged_region(struct damon_target *t, return false; } +static void damos_update_stat(struct damos *s, + unsigned long sz_tried, unsigned long sz_applied) +{ + s->stat.nr_tried++; + s->stat.sz_tried += sz_tried; + if (sz_applied) + s->stat.nr_applied++; + s->stat.sz_applied += sz_applied; +} + static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, struct damon_region *r, struct damos *s) { @@ -786,11 +796,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, r->age = 0; update_stat: - s->stat.nr_tried++; - s->stat.sz_tried += sz; - if (sz_applied) - s->stat.nr_applied++; - s->stat.sz_applied += sz_applied; + damos_update_stat(s, sz, sz_applied); } static void damon_do_apply_schemes(struct damon_ctx *c,