Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp265904rwi; Tue, 18 Oct 2022 17:30:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64GbZ65zkey6COk+EHJe6QfD+dYtp2rQAtTEEMIsmGk1BqkyTDJP03NncDH+kHFNamamOl X-Received: by 2002:a65:5a0b:0:b0:46b:158e:ad7c with SMTP id y11-20020a655a0b000000b0046b158ead7cmr4949252pgs.272.1666139450565; Tue, 18 Oct 2022 17:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666139450; cv=none; d=google.com; s=arc-20160816; b=nXm4ex7DUS8Pq0B//u4rBT8hkawG5j7wcaQJbtM/f6FAOAaHRhEfRnIDIOfBlkSeNI FYVWccfEdSJb2dn9eg6yNDBMXub4dL/9841QZzixfpTwkq3iAClXa9r6IY1A0TOZKOGj gekD6gvgREcxNaJe8z0sdf0nPf7vSF3LYnK7ADDFZOBJnlqj5jio3BxPrmWV2Z/l/zAt q6wtbp2mJ716+cNm0KTppZcIEagX7jcczsscjQiXKo9MSotvmG58YoOBlzqXUlWUCxD6 2AxgkJ0jzmUwfQKywJ66BeBuZNHUOCbETXoExZdi9DLOe6J2K94txIIC+JDUig5tAyPH VfBQ== 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=apyLQDdOvGp2emAMJI7hAEeB3OV5+1lsOAT++3Tcg80=; b=nZyvB4YwR4xj9sVR4p3X1N+FNZvxWbF2fcoXHt31CQDb3/bGVKU3DVvXlh9J485cLG X9WbY1MWnycLTmQpPL8RF7KYVXirMOLdUqJPMcckniUhP9piwPeaKmintirZNFTkmNrN kCxCT4g9sjLLMV1C+vk5tvfHU+WlVaeUBwJul0aJHBG813JKSGTlYI0lTZXfn4CXsixZ 4vGkwtHgx0iiSN2K9VJATm8PKu1AVXGFeRsu17T2f9iVc6Kb1UAYNwJ/RwOPdxdxpxpD Wx13x489M7Zq+2ujbRXZEK+kG48R6UiJhTiU3dx1W+Ds4nIFpJKLx33yKMZ28i9lcaSn AHNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nAAHDU7I; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot3-20020a17090b3b4300b0020ade3b9825si18294570pjb.52.2022.10.18.17.30.31; Tue, 18 Oct 2022 17:30:50 -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=nAAHDU7I; 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 S229868AbiJSANf (ORCPT + 99 others); Tue, 18 Oct 2022 20:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiJSAN0 (ORCPT ); Tue, 18 Oct 2022 20:13:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC58CCF181 for ; Tue, 18 Oct 2022 17:13:25 -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 3BF826173E for ; Wed, 19 Oct 2022 00:13:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC371C4347C; Wed, 19 Oct 2022 00:13:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666138405; bh=NhB5q6GWy35Ngqzu+zzoT7ZIWK8McTIGgP7rtWh58k4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nAAHDU7I6mkr0GDQcxxNJpSGpHNIxZZ76iNdS3Ntg8O7v25hder/BrwKr/J49yG2h KNJDI9MMXhaskiFZ71axg0bSTaqWjPLQ45HbZM09lQxLJZDb3FHb1ynHFKKVFSyWoP /YGaWGTV0GH9UfFXClAy7Ed6GArzvahx4Frx/y4i6Zbng9lSPIfvKgN7TITSDHsdXo VauZbzXPqNUDxOS4Z148iWXypUdEeZNo6kAbdD5tzPvEqzgu+xLIV9+J0B7aFwI02j AYjOTGw1OwDywujwOqI5T7scoJ3/lmDm1rH651EHfy/XNesEj+lymee+3V/f2JG304 zsnZ0g7EW6b2g== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 04/18] mm/damon/core: split out scheme stat update logic into a new function Date: Wed, 19 Oct 2022 00:13:03 +0000 Message-Id: <20221019001317.104270-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019001317.104270-1-sj@kernel.org> References: <20221019001317.104270-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index e777a751295f..7fa88dda711d 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -748,6 +748,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) { @@ -779,11 +789,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, @@ -808,7 +814,6 @@ static void damon_do_apply_schemes(struct damon_ctx *c, if (!damos_valid_target(c, t, r, s)) continue; - /* Apply the scheme */ damos_apply_scheme(c, t, r, s); } } -- 2.25.1