From patchwork Wed Oct 26 22:59:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13021338 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 C078EC433FE for ; Wed, 26 Oct 2022 23:00:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FF698E000A; Wed, 26 Oct 2022 18:59:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 427148E0008; Wed, 26 Oct 2022 18:59:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B5658E000A; Wed, 26 Oct 2022 18:59:56 -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 EF7828E0008 for ; Wed, 26 Oct 2022 18:59:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D18E5140361 for ; Wed, 26 Oct 2022 22:59:55 +0000 (UTC) X-FDA: 80064619950.04.211B05C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 8098EA0037 for ; Wed, 26 Oct 2022 22:59:55 +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 dfw.source.kernel.org (Postfix) with ESMTPS id CE25E620E3; Wed, 26 Oct 2022 22:59:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 486D0C43142; Wed, 26 Oct 2022 22:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666825194; bh=ntGtZw3yOs+uZ3gGOlcjovkmvzOGben11U2Vk6cgNsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=apA/DBpn9ihjONGTe+7Tm+CF2VK2nXdQwrRSROG0uPjYVHC6AfMycLiYCPgw4tSV2 Bjryu70eLbWJwZ3NnTsY4AVkIq6TUoB9gxxBJDdYo6uGFuIOdvOmyM2ICd2Cwgeqh1 bTgFL7CxZRZOpao4OYSzJN/iSg34iczbkjbdwE9d9E28XH99UhR/tWLjlRWvTEmtqF FMSuaipMVFPhD+vCFcKCokDIHnrMv8uH4EJ1suKOml4QfwTOj3gtr8C5rM00UCydjr ZzzldyJunEtbF2+KVU4QrINjXm4ToX4LMI7rLviAU6jxY6ZWlaCORklG3p0m8AeQtA 2CdoglM3N20DQ== 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 09/12] mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function Date: Wed, 26 Oct 2022 22:59:40 +0000 Message-Id: <20221026225943.100429-10-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=1666825195; a=rsa-sha256; cv=none; b=Dg5qKP6lMpympImKwegtF49uclR0mPkf5hnbw5uVDICbYljAmMcMYn34XMruFyYbbGrZda tbwyXerad5VOwGnj+8WwIyyg1MuCPjNBFlqQ6HJ1Xhp1+XSjpVoQD4xDH3owQ1/jB8sg1w A0h0Rrh9sM3yaKhg+OwL6SW7qra0uZQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="apA/DBpn"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666825195; 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=qUSrIwHgZDAo1NHeBpiMarlvnzTJFFsWb8HHUCN9sbs=; b=MsC3D9AfvIAAAGyynyKvwg1F+cuBTwivXF0tIgg3M0fVzs2hTyP1upaByEXwm766jrUZrT go9SORWCd+J68s9hYqJNhwoErQ2RHcBxfQKeCLXhioJwbURC42dzG0e5fJNe/jof42UyhS k4yggs9/gLVIJyrXrq9O64uzMYMkVBA= X-Rspamd-Queue-Id: 8098EA0037 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="apA/DBpn"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: 735kb5gkdc3b56gzpfawsfejzic97pj3 X-HE-Tag: 1666825195-364683 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: 'damon_sysfs_schemes_update_stats()' is coupled with both damon_sysfs_kdamond and damon_sysfs_schemes. It's a wide range of types dependency. It makes splitting the logics a little bit distracting. Split the function so that each function is coupled with smaller range of types. Signed-off-by: SeongJae Park Signed-off-by: Andrew Morton --- mm/damon/sysfs.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 129743292e17..082c55e68e0e 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2204,6 +2204,25 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx) mutex_unlock(&ctx->kdamond_lock); } +static void damon_sysfs_schemes_update_stats( + struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx) +{ + struct damos *scheme; + int schemes_idx = 0; + + damon_for_each_scheme(scheme, ctx) { + struct damon_sysfs_stats *sysfs_stats; + + sysfs_stats = sysfs_schemes->schemes_arr[schemes_idx++]->stats; + sysfs_stats->nr_tried = scheme->stat.nr_tried; + sysfs_stats->sz_tried = scheme->stat.sz_tried; + sysfs_stats->nr_applied = scheme->stat.nr_applied; + sysfs_stats->sz_applied = scheme->stat.sz_applied; + sysfs_stats->qt_exceeds = scheme->stat.qt_exceeds; + } +} + /* * damon_sysfs_upd_schemes_stats() - Update schemes stats sysfs files. * @kdamond: The kobject wrapper that associated to the kdamond thread. @@ -2216,23 +2235,11 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx) static int damon_sysfs_upd_schemes_stats(struct damon_sysfs_kdamond *kdamond) { struct damon_ctx *ctx = kdamond->damon_ctx; - struct damon_sysfs_schemes *sysfs_schemes; - struct damos *scheme; - int schemes_idx = 0; if (!ctx) return -EINVAL; - sysfs_schemes = kdamond->contexts->contexts_arr[0]->schemes; - damon_for_each_scheme(scheme, ctx) { - struct damon_sysfs_stats *sysfs_stats; - - sysfs_stats = sysfs_schemes->schemes_arr[schemes_idx++]->stats; - sysfs_stats->nr_tried = scheme->stat.nr_tried; - sysfs_stats->sz_tried = scheme->stat.sz_tried; - sysfs_stats->nr_applied = scheme->stat.nr_applied; - sysfs_stats->sz_applied = scheme->stat.sz_applied; - sysfs_stats->qt_exceeds = scheme->stat.qt_exceeds; - } + damon_sysfs_schemes_update_stats( + kdamond->contexts->contexts_arr[0]->schemes, ctx); return 0; }