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: 13021336 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 3860AC38A2D for ; Wed, 26 Oct 2022 23:00:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4DC28E0005; Wed, 26 Oct 2022 18:59:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD4428E000A; Wed, 26 Oct 2022 18:59:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 979E68E0008; Wed, 26 Oct 2022 18:59:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7EFB98E0005 for ; Wed, 26 Oct 2022 18:59:54 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 46C9C80EFF for ; Wed, 26 Oct 2022 22:59:54 +0000 (UTC) X-FDA: 80064619908.24.5A8C024 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf20.hostedemail.com (Postfix) with ESMTP id A1B6E1C0009 for ; Wed, 26 Oct 2022 22:59:53 +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 5D29DB82472; Wed, 26 Oct 2022 22:59:52 +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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666825193; a=rsa-sha256; cv=none; b=eE+16SbKVktTagW9otm/qw9biCwt9I3iGbUl1wfmeF6R5J8xwovO/xo6tSUXGQRC+mGTV5 LygcWyrh9vnT/61zfowt7owY5DE+OHeZ0J3qE/NKDWLL4QoSRgIYd3SOfKhhnHQLxLWGCe 8rOPv1KMBghWBbEcJ86JpTlUtuFjfFk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=r6Eyv8ff; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666825193; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Va1Hl4/fiX1YGx5FEpII3Lr4FPSzB5T720IHaaDi5rk=; b=PNWGOkFICiOeA58Lvoe6BM197QEuWg0K/S7jb0dsFB/ERn1OqzQkQJeQKpIsjByhoJ+psz 9cRaqlWxTdjphaBcDfbEdl5YtS0Lhce6vFzNs0UL0fYGR5MugAWnNs3+uL/ar8zjbmhBnv gAN9j171SZ1d0FuM5hKMVXanWAhSNek= X-Stat-Signature: r39oxh9axerejzpkjpnmbzpaj6y8k1ta X-Rspamd-Queue-Id: A1B6E1C0009 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=r6Eyv8ff; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1666825193-233515 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: 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,