From patchwork Wed Oct 26 22:59:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp524739wru; Wed, 26 Oct 2022 16:01:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4p1IJgJdJ8ojwTozdPVZIntSQPLgZe+I6sFkRY2JHXPimoZppRTa3m+6BJr9oQLUhSNKOH X-Received: by 2002:a63:4f15:0:b0:455:ede1:d8c9 with SMTP id d21-20020a634f15000000b00455ede1d8c9mr40030186pgb.452.1666825317825; Wed, 26 Oct 2022 16:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666825317; cv=none; d=google.com; s=arc-20160816; b=kvx8WXfKdLo+E6d2yeLzj8n9pTXjphjiFSfZozbeNkh/OvUqI2xM0TgAdCltApWgJ2 Y+q5lu9WDSXbtNXjOEObF0JfnyRGRwD9bMjxNZIq50Ci45v1DbwvwHo1lZ8AaKWk4r7L T6DdLNVkfDXmy75u5obsMAl9R9wB6vUSFX2Bdq8fr4xN36MfVn/t1Au3pmT7K96unDjd VIrGqyimJir/tXiKl6oKiWCqJMCXvLMPbfetDsAdXQTQsf2F1a88GBaRAJ5KqzrArRpS vXyYRJnaCbA9iSHbwNCur/pZhBDIrZXKq1HuNrmvFYAZQReDX9TEGUCAbeHzLwSuN0j+ yFDA== 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=Va1Hl4/fiX1YGx5FEpII3Lr4FPSzB5T720IHaaDi5rk=; b=0/IY1aZEh3VRnwv5DAWP9BPuiHZuP2M7MsD2yGDhxRLWLjIJcu4uW5RQel7C6od20N grxCCb7BCAPkqmGVDV7IPX+H3/46pPHwjysf4xkBzfKcU6zlHOth+PICcXjLsUhLCRv4 HkeGEbRF4+ZM1+uxDyfSZIbQTSABoKfgvXi1gUvZFPRhM8U7Q25KNHTYfhU1VlCeWDIh Y3gNcUIYDkXKxUZ6Me59pLndj6/3tVPLUVQvgoAwN6L1Zun1RFNA+0Oz3gq7QtZrloWt NcLvThczW9YbZ2guohZYAGp2BC/kyRzqSt+szYjEA+OCS55mFSjwYCJVXGWpFk8sFlt/ 3uVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r6Eyv8ff; 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 z12-20020a17090ad78c00b0020db4eeaed5si1446295pju.137.2022.10.26.16.01.44; Wed, 26 Oct 2022 16:01:57 -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=r6Eyv8ff; 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 S234046AbiJZXAI (ORCPT + 99 others); Wed, 26 Oct 2022 19:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbiJZW77 (ORCPT ); Wed, 26 Oct 2022 18:59:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3C5C26569 for ; Wed, 26 Oct 2022 15:59:52 -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 AC4E2620DC for ; Wed, 26 Oct 2022 22:59:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B58E6C43142; Wed, 26 Oct 2022 22:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666825191; bh=JpR/JpSFcvX/01k1C+QGg0rBNnZER7RU6+E6N5NVTO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6Eyv8ffq85heYOnigGBCrI+z0CZ4/IyyIB+YPDQDNJr+24gdpnLwQ302W4TFpqyE 5PQSq5YVSY+94t/kcpD7m9+o9jvI/FY4BYFd0+W9bHrzsmGY6GI8uVrq3mV9rcjRmN hvtwew5+HkJ8S2WsXBTfP9t2ch6LmFZtXk+MMmVxUGPLhHE2XSGGUP1y+Wl/1C0mhA CD1fMCaw9yw3bWwDBGNYTqGQ6za5fGkEaUIrJrrazMtESzldt4aujvwPTKMP2i7JEw 3hx82Iuk66RtdFldolTjr0JN5VVAl0a+BGfrNSkmoMLSrijYWfDanoNknERIUi3044 JlEfEkO6oAyjg== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH v2 03/12] mm/damon/core: split out scheme stat update logic into a new function Date: Wed, 26 Oct 2022 22:59:34 +0000 Message-Id: <20221026225943.100429-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221026225943.100429-1-sj@kernel.org> References: <20221026225943.100429-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?1747793024505087216?= X-GMAIL-MSGID: =?utf-8?q?1747793024505087216?= 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 Signed-off-by: Andrew Morton --- 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,