From patchwork Mon Jun 6 18:23:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12870786 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 BA7EBC43334 for ; Mon, 6 Jun 2022 19:24:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4438D6B0073; Mon, 6 Jun 2022 15:24:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F3446B0074; Mon, 6 Jun 2022 15:24:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BB296B0075; Mon, 6 Jun 2022 15:24:16 -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 197746B0073 for ; Mon, 6 Jun 2022 15:24:16 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F0B50337D5 for ; Mon, 6 Jun 2022 18:48:44 +0000 (UTC) X-FDA: 79548697368.11.8FBCE6A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id CA7D220048 for ; Mon, 6 Jun 2022 18:48:27 +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 B853F61359; Mon, 6 Jun 2022 18:23:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 893D2C3411E; Mon, 6 Jun 2022 18:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654539797; bh=r7qsMO+KaTvKmkx5mx/GJ+zu6Ys/r3ohlnLftZkA8x0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j8JnNnOJIAvqeARo2dlT4UcQMZ8rJ//iqmHsfN9M4cIEZNdeAnbFB8CmnMAfD9pFX UiNfXHQmu7cthP9LIT7NVUgYTjwxh/t1hCj4FGG40mXLXdsEZKL/tG0IDH3DTABqP9 CShyDuo9w395PBZ9kKneAsphx18R3r5xsL7Hz3jYc/+c3HPRj/ZDn4Qwz2F1SGZdmJ gXzn9ShGWt/0FcDEfnrA+8yjck9sc+THOzP/B3pPNFpv6TjA2w2poz0JKvp/zbN4ma hiDHiL0i65m5+wH4OQR1HgiqbAYaMe2pVD5/GLouer+Z4FjGo3NJNAhsc5AEAY1nRT M1uHWvuJ1/n6g== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 1/6] Docs/admin-guide/damon/reclaim: remove a paragraph that been obsolete due to online tuning support Date: Mon, 6 Jun 2022 18:23:05 +0000 Message-Id: <20220606182310.48781-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606182310.48781-1-sj@kernel.org> References: <20220606182310.48781-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: j59bhxtrbq8964kzr8r1xpxruhmme416 X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j8JnNnOJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CA7D220048 X-HE-Tag: 1654541307-755416 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: Commit 81a84182c343 ("Docs/admin-guide/mm/damon/reclaim: document 'commit_inputs' parameter") has documented the 'commit_inputs' parameter which allows online parameter update, but it didn't remove a paragraph saying the online parameter update is impossible. This commit removes the obsolete paragraph. Fixes: 81a84182c343 ("Docs/admin-guide/mm/damon/reclaim: document 'commit_inputs' parameter") Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/reclaim.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst index 46306f1f34b1..6510baa91109 100644 --- a/Documentation/admin-guide/mm/damon/reclaim.rst +++ b/Documentation/admin-guide/mm/damon/reclaim.rst @@ -48,12 +48,6 @@ DAMON_RECLAIM utilizes module parameters. That is, you can put ``damon_reclaim.=`` on the kernel boot command line or write proper values to ``/sys/modules/damon_reclaim/parameters/`` files. -Note that the parameter values except ``enabled`` are applied only when -DAMON_RECLAIM starts. Therefore, if you want to apply new parameter values in -runtime and DAMON_RECLAIM is already enabled, you should disable and re-enable -it via ``enabled`` parameter file. Writing of the new values to proper -parameter values should be done before the re-enablement. - Below are the description of each parameter. enabled From patchwork Mon Jun 6 18:23:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12870789 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 44B6DC433EF for ; Mon, 6 Jun 2022 19:27:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8BBD6B0072; Mon, 6 Jun 2022 15:27:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3AB16B0074; Mon, 6 Jun 2022 15:27:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B6F6B0075; Mon, 6 Jun 2022 15:27:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B436F6B0072 for ; Mon, 6 Jun 2022 15:27:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id CC44E120A69 for ; Mon, 6 Jun 2022 18:48:42 +0000 (UTC) X-FDA: 79548697284.09.B9A2E40 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 3866CA0088 for ; Mon, 6 Jun 2022 18:48:02 +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 8B76061357; Mon, 6 Jun 2022 18:23:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C168C3411F; Mon, 6 Jun 2022 18:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654539798; bh=FkFezzlzmy/eW3w7W+oLzp/buOO/S8XlonrJ1RecW3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVEWXita9mYJJ2bVaGpCS8bj2zYum/t5ksZrhBCbTdiUFJwA05V3as07feHg4NS7a +9lMHIBhu6jn/lIXBvmo6s5o9TdcSq9Erw55hjV256YgPLgvsgLTYvfIHadZoUNBY0 CEYo69rXCNH1PkU/bxjVibK/UHzKX+3iRzOe9OPq0oGPKa3fgyon7meXQog2YAXw8l gLcap2cfCMDnOo7WZRUZtOup/OL4O+N+hFK7T2bhKal26nIHrVhejWyRtSMgFRySDR /ksMIXtCK5b04ErkqJ+Ge3iJAZaybikV8w1qMU4V8GhL7oWfzeaXaBjfaSszjJvr3I XocTbLGXOBiCg== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 2/6] mm/damon/{dbgfs,sysfs}: move target_has_pid() from dbgfs to damon.h Date: Mon, 6 Jun 2022 18:23:06 +0000 Message-Id: <20220606182310.48781-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606182310.48781-1-sj@kernel.org> References: <20220606182310.48781-1-sj@kernel.org> MIME-Version: 1.0 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aVEWXita; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3866CA0088 X-Rspam-User: X-Stat-Signature: min7yh11ie3gyecjocbjy99ezr866jq5 X-HE-Tag: 1654541282-219368 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 knowing if given monitoring context's targets will have pid or not is defined and used in dbgfs only. However, the logic is also needed for sysfs. This commit moves the code to damon.h and makes both dbgfs and sysfs to use it. Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++++ mm/damon/dbgfs.c | 15 +++++---------- mm/damon/sysfs.c | 8 +++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 2765c7d99beb..b9aae19fab3e 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -525,6 +525,12 @@ bool damon_is_registered_ops(enum damon_ops_id id); int damon_register_ops(struct damon_operations *ops); int damon_select_ops(struct damon_ctx *ctx, enum damon_ops_id id); +static inline bool damon_target_has_pid(const struct damon_ctx *ctx) +{ + return ctx->ops.id == DAMON_OPS_VADDR || ctx->ops.id == DAMON_OPS_FVADDR; +} + + int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive); int damon_stop(struct damon_ctx **ctxs, int nr_ctxs); diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index a0dab8b5e45f..5ae810927309 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -275,11 +275,6 @@ static ssize_t dbgfs_schemes_write(struct file *file, const char __user *buf, return ret; } -static inline bool target_has_pid(const struct damon_ctx *ctx) -{ - return ctx->ops.id == DAMON_OPS_VADDR; -} - static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len) { struct damon_target *t; @@ -288,7 +283,7 @@ static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len) int rc; damon_for_each_target(t, ctx) { - if (target_has_pid(ctx)) + if (damon_target_has_pid(ctx)) /* Show pid numbers to debugfs users */ id = pid_vnr(t->pid); else @@ -415,7 +410,7 @@ static int dbgfs_set_targets(struct damon_ctx *ctx, ssize_t nr_targets, struct damon_target *t, *next; damon_for_each_target_safe(t, next, ctx) { - if (target_has_pid(ctx)) + if (damon_target_has_pid(ctx)) put_pid(t->pid); damon_destroy_target(t); } @@ -425,11 +420,11 @@ static int dbgfs_set_targets(struct damon_ctx *ctx, ssize_t nr_targets, if (!t) { damon_for_each_target_safe(t, next, ctx) damon_destroy_target(t); - if (target_has_pid(ctx)) + if (damon_target_has_pid(ctx)) dbgfs_put_pids(pids, nr_targets); return -ENOMEM; } - if (target_has_pid(ctx)) + if (damon_target_has_pid(ctx)) t->pid = pids[i]; damon_add_target(ctx, t); } @@ -722,7 +717,7 @@ static void dbgfs_before_terminate(struct damon_ctx *ctx) { struct damon_target *t, *next; - if (!target_has_pid(ctx)) + if (!damon_target_has_pid(ctx)) return; mutex_lock(&ctx->kdamond_lock); diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 09f9e8ca3d1f..8810e6abdb06 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2136,8 +2136,7 @@ static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) struct damon_target *t, *next; damon_for_each_target_safe(t, next, ctx) { - if (ctx->ops.id == DAMON_OPS_VADDR || - ctx->ops.id == DAMON_OPS_FVADDR) + if (damon_target_has_pid(ctx)) put_pid(t->pid); damon_destroy_target(t); } @@ -2181,8 +2180,7 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target, if (!t) return -ENOMEM; - if (ctx->ops.id == DAMON_OPS_VADDR || - ctx->ops.id == DAMON_OPS_FVADDR) { + if (damon_target_has_pid(ctx)) { t->pid = find_get_pid(sys_target->pid); if (!t->pid) goto destroy_targets_out; @@ -2210,7 +2208,7 @@ static struct damon_target *damon_sysfs_existing_target( struct pid *pid; struct damon_target *t; - if (ctx->ops.id == DAMON_OPS_PADDR) { + if (!damon_target_has_pid(ctx)) { /* Up to only one target for paddr could exist */ damon_for_each_target(t, ctx) return t; From patchwork Mon Jun 6 18:23:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12870778 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 6995DC433EF for ; Mon, 6 Jun 2022 19:22:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F24626B0075; Mon, 6 Jun 2022 15:22:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED4646B0078; Mon, 6 Jun 2022 15:22:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4E7D6B007B; Mon, 6 Jun 2022 15:22:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C3AD96B0075 for ; Mon, 6 Jun 2022 15:22:14 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id A385D6096F for ; Mon, 6 Jun 2022 18:46:25 +0000 (UTC) X-FDA: 79548691530.27.39D574C Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf07.hostedemail.com (Postfix) with ESMTP id 2305C4002A for ; Mon, 6 Jun 2022 18:46:10 +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 11C0FB81AEE; Mon, 6 Jun 2022 18:23:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EBDAC3411D; Mon, 6 Jun 2022 18:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654539798; bh=N4cT2SKfYSnDGxoyHnmUEPdoAtmbrJGcDlJlH2/OfOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=byQbhpHN3e9Y/GWGOgpUbWD+yN8h7nuKYxgeIVGGNlhspqY11BxajycI3nF/fw2gx gnOBRV2snd9eFGeOh52JoJUOt7Mog9UxiTd/BlvWENXli84MvslqSslVZb6+DBuYkt C9G+FZppmX0jtdWTZSaJ8acoyIHAHItRlX4CfXYFtctTSvDRbg8v6EWr/goMSTXD/3 4CtZhsv14/+uZz52T7rrJH8XaH06ZeVhyO3sFPERLu2WH04ERlUcjgeOMesK2hPKOc P2W98Wf+/neUZNhpHaYvPSZistrlYbWlpmoNx0trUMBWDeVnJk2oR2Mldi1E3JshPA awT6y401nW6Gw== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 3/6] mm/damon/reclaim: deduplicate 'commit_inputs' handling Date: Mon, 6 Jun 2022 18:23:07 +0000 Message-Id: <20220606182310.48781-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606182310.48781-1-sj@kernel.org> References: <20220606182310.48781-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2305C4002A Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=byQbhpHN; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Stat-Signature: qn3juy1wjzypp79r37y8gguh3hi7ip7w X-Rspam-User: X-HE-Tag: 1654541170-916996 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_RECLAIM's handling of 'commit_inputs' parameter is duplicated in 'after_aggregation()' and 'after_wmarks_check()' callbacks. This commit deduplicates the code for better maintenance. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 4b07c29effe9..c2ed962db23f 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -403,10 +403,21 @@ module_param_cb(enabled, &enabled_param_ops, &enabled, 0600); MODULE_PARM_DESC(enabled, "Enable or disable DAMON_RECLAIM (default: disabled)"); +static int damon_reclaim_handle_commit_inputs(void) +{ + int err; + + if (!commit_inputs) + return 0; + + err = damon_reclaim_apply_parameters(); + commit_inputs = false; + return err; +} + static int damon_reclaim_after_aggregation(struct damon_ctx *c) { struct damos *s; - int err = 0; /* update the stats parameter */ damon_for_each_scheme(s, c) { @@ -417,22 +428,12 @@ static int damon_reclaim_after_aggregation(struct damon_ctx *c) nr_quota_exceeds = s->stat.qt_exceeds; } - if (commit_inputs) { - err = damon_reclaim_apply_parameters(); - commit_inputs = false; - } - return err; + return damon_reclaim_handle_commit_inputs(); } static int damon_reclaim_after_wmarks_check(struct damon_ctx *c) { - int err = 0; - - if (commit_inputs) { - err = damon_reclaim_apply_parameters(); - commit_inputs = false; - } - return err; + return damon_reclaim_handle_commit_inputs(); } static int __init damon_reclaim_init(void) From patchwork Mon Jun 6 18:23:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12870785 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 18E58C433EF for ; Mon, 6 Jun 2022 19:24:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B23696B0072; Mon, 6 Jun 2022 15:24:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD3566B0073; Mon, 6 Jun 2022 15:24:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99B706B0074; Mon, 6 Jun 2022 15:24:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8701C6B0072 for ; Mon, 6 Jun 2022 15:24:10 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1CD4133848 for ; Mon, 6 Jun 2022 18:48:42 +0000 (UTC) X-FDA: 79548697284.31.57624D0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id E45DA18006B for ; Mon, 6 Jun 2022 18:48:23 +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 29C3461335; Mon, 6 Jun 2022 18:23:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 012F8C3411E; Mon, 6 Jun 2022 18:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654539799; bh=CCWdGSU3kQs8AT6sJOhE8/l+ZEj/ZV94RBpO8N3YyrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fx5nRHOpwJ+Yxn+7uRfYUixY+ueMJQJi4ydUr0eSNroY/jQ+D+CGEYzSyLqRqqChH 3vR4sIj7qlwkRCxzIYPaRH4hizlOcqX7S1vV5vLJkg4C5kUd+0Bb7xvgGrPQbRecZ3 zCgWcyMCLfZuDuIQf1i28A1DadRoCq4iSNymr5NHppJxy2dXix/DD4RaHyWUoTQJSc 0dppuhiERnt4QdaZBgw+g2i3gLGFiTAxY4DBp5c51G3iTAgLsBcZFLYiXgOU0fGil5 nRHzuR/zoa1WM748q6lvlYSeoCIYq86AhYYMbHoTfoYlPXT0YtjS6TnoA2rFLh4be2 hbDAUzZA/IPUQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 4/6] mm/damon/sysfs: deduplicate inputs applying Date: Mon, 6 Jun 2022 18:23:08 +0000 Message-Id: <20220606182310.48781-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606182310.48781-1-sj@kernel.org> References: <20220606182310.48781-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 6ob8b7ydci1g68zyug1eat5qkcukd8qo X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Fx5nRHOp; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E45DA18006B X-HE-Tag: 1654541303-190203 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 interface's DAMON context building and its online parameter update have duplicated code. This commit removes the duplicate. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 59 ++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 8810e6abdb06..c35809c6087c 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2357,6 +2357,23 @@ static inline bool damon_sysfs_kdamond_running( damon_sysfs_ctx_running(kdamond->damon_ctx); } +static int damon_sysfs_apply_inputs(struct damon_ctx *ctx, + struct damon_sysfs_context *sys_ctx) +{ + int err; + + err = damon_select_ops(ctx, sys_ctx->ops_id); + if (err) + return err; + err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs); + if (err) + return err; + err = damon_sysfs_set_targets(ctx, sys_ctx->targets); + if (err) + return err; + return damon_sysfs_set_schemes(ctx, sys_ctx->schemes); +} + /* * damon_sysfs_commit_input() - Commit user inputs to a running kdamond. * @kdamond: The kobject wrapper for the associated kdamond. @@ -2365,31 +2382,14 @@ static inline bool damon_sysfs_kdamond_running( */ static int damon_sysfs_commit_input(struct damon_sysfs_kdamond *kdamond) { - struct damon_ctx *ctx = kdamond->damon_ctx; - struct damon_sysfs_context *sys_ctx; - int err = 0; - if (!damon_sysfs_kdamond_running(kdamond)) return -EINVAL; /* TODO: Support multiple contexts per kdamond */ if (kdamond->contexts->nr != 1) return -EINVAL; - sys_ctx = kdamond->contexts->contexts_arr[0]; - - err = damon_select_ops(ctx, sys_ctx->ops_id); - if (err) - return err; - err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs); - if (err) - return err; - err = damon_sysfs_set_targets(ctx, sys_ctx->targets); - if (err) - return err; - err = damon_sysfs_set_schemes(ctx, sys_ctx->schemes); - if (err) - return err; - return err; + return damon_sysfs_apply_inputs(kdamond->damon_ctx, + kdamond->contexts->contexts_arr[0]); } /* @@ -2436,27 +2436,16 @@ static struct damon_ctx *damon_sysfs_build_ctx( if (!ctx) return ERR_PTR(-ENOMEM); - err = damon_select_ops(ctx, sys_ctx->ops_id); - if (err) - goto out; - err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs); - if (err) - goto out; - err = damon_sysfs_set_targets(ctx, sys_ctx->targets); - if (err) - goto out; - err = damon_sysfs_set_schemes(ctx, sys_ctx->schemes); - if (err) - goto out; + err = damon_sysfs_apply_inputs(ctx, sys_ctx); + if (err) { + damon_destroy_ctx(ctx); + return ERR_PTR(err); + } ctx->callback.after_wmarks_check = damon_sysfs_cmd_request_callback; ctx->callback.after_aggregation = damon_sysfs_cmd_request_callback; ctx->callback.before_terminate = damon_sysfs_before_terminate; return ctx; - -out: - damon_destroy_ctx(ctx); - return ERR_PTR(err); } static int damon_sysfs_turn_damon_on(struct damon_sysfs_kdamond *kdamond) From patchwork Mon Jun 6 18:23:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12870787 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 53E96C433EF for ; Mon, 6 Jun 2022 19:24:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE8156B0073; Mon, 6 Jun 2022 15:24:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E967E6B0075; Mon, 6 Jun 2022 15:24:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5EF46B0078; Mon, 6 Jun 2022 15:24:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C4A926B0073 for ; Mon, 6 Jun 2022 15:24:48 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D3EB434B96 for ; Mon, 6 Jun 2022 18:46:26 +0000 (UTC) X-FDA: 79548691572.13.6E7A290 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf28.hostedemail.com (Postfix) with ESMTP id 8D498C0070 for ; Mon, 6 Jun 2022 18:45:41 +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 95826B81AE8; Mon, 6 Jun 2022 18:23:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C751BC385A9; Mon, 6 Jun 2022 18:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654539800; bh=zzYotTKEGLDprg9+poMHiWB57TXnLs8veIXqbVZJakQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cxG50trjbZk11hd8BkFPwMnPsdUMaKaDxA2TDSM1UP6LsoVQ2+0tCUFnSFT9JTdgi /Lfe0F+d4rorgHfn5Dn1QZm0yd2Of6JsN4IBr2lSKmC05oOsOFOKb9RXwNYBUX3sNz jccl9HwJ5MX8yhA+qInAi3jwKf9gVkYG0SB5R4cJOQfzGvXYDNq+kEXV8PuK5rGnre 7Ne08FyMzxIoQvddB01DsviJGOfNDDCKiqalHx8+QnvFVUzsqzqilvFWYw0I9e+WGj 7YZe6OK5GXKeiLIZqpS5L2VACnDfO3ic+5RciciQeU/GEi2W+xdaXzBT3/cNwJtX2C tbYobf3tbGxGQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 5/6] mm/damon/reclaim: make 'enabled' checking timer simpler Date: Mon, 6 Jun 2022 18:23:09 +0000 Message-Id: <20220606182310.48781-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606182310.48781-1-sj@kernel.org> References: <20220606182310.48781-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8D498C0070 X-Stat-Signature: r8a7rpogb9u8i3hsy36o5wzmuodt1tgm Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cxG50trj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1654541141-893040 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_RECLAIM's 'enabled' parameter store callback ('enabled_store()') schedules the parameter check timer ('damon_reclaim_timer') if the parameter is set as 'Y'. Then, the timer schedules itself to check if user has set the parameter as 'N'. It's unnecessarily complex. This commit makes it simpler by making the parameter store callback to schedule the timer regardless of the parameter value and disabling the timer's self scheduling. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index c2ed962db23f..38da28803d75 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -353,7 +353,6 @@ static int damon_reclaim_turn(bool on) return 0; } -#define ENABLE_CHECK_INTERVAL_MS 1000 static struct delayed_work damon_reclaim_timer; static void damon_reclaim_timer_fn(struct work_struct *work) { @@ -367,10 +366,6 @@ static void damon_reclaim_timer_fn(struct work_struct *work) else enabled = last_enabled; } - - if (enabled) - schedule_delayed_work(&damon_reclaim_timer, - msecs_to_jiffies(ENABLE_CHECK_INTERVAL_MS)); } static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn); @@ -388,9 +383,7 @@ static int enabled_store(const char *val, if (!damon_reclaim_initialized) return rc; - if (enabled) - schedule_delayed_work(&damon_reclaim_timer, 0); - + schedule_delayed_work(&damon_reclaim_timer, 0); return 0; } From patchwork Mon Jun 6 18:23:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12870777 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 B7513C43334 for ; Mon, 6 Jun 2022 19:21:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35E6E6B0074; Mon, 6 Jun 2022 15:21:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E8566B0075; Mon, 6 Jun 2022 15:21:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B07B6B0078; Mon, 6 Jun 2022 15:21:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0AA7F6B0074 for ; Mon, 6 Jun 2022 15:21:46 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id B090C80961 for ; Mon, 6 Jun 2022 18:46:25 +0000 (UTC) X-FDA: 79548691530.26.A3A815F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf05.hostedemail.com (Postfix) with ESMTP id 8344410003C for ; Mon, 6 Jun 2022 18:45:46 +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 6641AB81AEF; Mon, 6 Jun 2022 18:23:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B6CEC341C0; Mon, 6 Jun 2022 18:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654539801; bh=FuYn5OaBm/cdGtgDHAKwyk/NB5Y5Xx2dRB0uYwvqtbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lTHVR2x65cV9HsW/o06kyp604ujtkTQmRbApF/mteXZb9eHjqhKmnuXWcYEHlCnV0 uG4U1ETDaKCJWJLDC1+U6ibmwsX41DXZrlz5Ykx1WxkxFxr1mpOO0qglWWJPINaTmO gCO6OF+KZfvll4FZEn4kZX2wve2tNfgC3rNmoTcpeWvPkENWytqks6ck4QbcDdjrbx cB/X8Gk5dJbFUNsfW0eyVU/cF0oT39DRJruw2S1DVjbErlNXgInirmdDaxq0h4reA/ NjomkYMDQCaoMCoJLdc8i1TftJA6JO5BQDo+r6z8ODW3TdFJVS6hPeScHtK7dLsQPa NEL/3ariFGPiA== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 6/6] mm/damon/reclaim: add 'damon_reclaim_' prefix to 'enabled_store()' Date: Mon, 6 Jun 2022 18:23:10 +0000 Message-Id: <20220606182310.48781-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606182310.48781-1-sj@kernel.org> References: <20220606182310.48781-1-sj@kernel.org> MIME-Version: 1.0 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lTHVR2x6; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Stat-Signature: c3q316encfezfeh3rbzxbo656h8mmpy9 X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8344410003C X-HE-Tag: 1654541146-209642 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: This commit adds 'damon_reclaim_' prefix to 'enabled_store()', so that we can distinguish it easily from the stack trace using 'faddr2line.sh' like tools. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 38da28803d75..e69b807fefe4 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -371,7 +371,7 @@ static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn); static bool damon_reclaim_initialized; -static int enabled_store(const char *val, +static int damon_reclaim_enabled_store(const char *val, const struct kernel_param *kp) { int rc = param_set_bool(val, kp); @@ -388,7 +388,7 @@ static int enabled_store(const char *val, } static const struct kernel_param_ops enabled_param_ops = { - .set = enabled_store, + .set = damon_reclaim_enabled_store, .get = param_get_bool, };