From patchwork Tue Jun 18 18:17:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702817 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 133A9C27C4F for ; Tue, 18 Jun 2024 18:18:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 875F28D0040; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D2A78D004B; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CCBE8D0047; Tue, 18 Jun 2024 14:18:26 -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 5B2ED8D0036 for ; Tue, 18 Jun 2024 14:18:23 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 14CC180987 for ; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) X-FDA: 82244819286.03.0B7B0A5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id D084E160019 for ; Tue, 18 Jun 2024 18:18:20 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rkohSxYo; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734696; a=rsa-sha256; cv=none; b=EhrXWNjHTOAUjTFeIRulvaR0e4A/5JWT7VRqH+opH3kl86OEHE7xhEuIqZdJPJpHaDAMi7 yd2SctZnRW4csjWwdHy7oHpxs3/GD/nrDF5Q3thAYrWAAOc3FItaz4xzdaMNp0hzjucmPX idmlgC73451Cq1D/apYrhbhQuGiyo4k= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rkohSxYo; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1718734695; 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=4Olb4eAhnSZNbvkfoM5pKR9yW2Wt1Y7pa2nNIcSLxGM=; b=Bah4gJ72aBuhCY1ZXcp08MlpIqxeJl84o1eEIJEfmRA+2Hwb6Iv/n4YX3tToBfA8fWPxNU 1vD0k09WmFPxLWJFRhgzMOzkHxRllnCn7XuN126q+e3nmgFaY4i6YanQiczGrWZ9ZH4Xtu EyDO/T4vUJFWU/zAEodUosWQEzjsXV8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 123E4CE1C03; Tue, 18 Jun 2024 18:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D542BC4AF48; Tue, 18 Jun 2024 18:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734697; bh=7hRdxjHOSIuwrdZCOKzvtYTSDa0l/gnw+9kuPa/0bZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rkohSxYoVet+2VnInROCLHYvbmT/IcPl8P0ZgsPJ3X5uqKAAALvILpaMNTgGw2HL+ pA+wVpDtiRRJCmbVDvwOy8kIDC3Ybx/M7EllPDu5PiuRpxWxCTL1Q0o//xVXjeXAGc PyxuRULZuqMY6uvSC9/eijvV1adFiBJ7alMLDXzn7OXN4Zl0nxghlYw9X1AKmLb/8K rMXmH7ZDhYb7tpjfcBqUr0HQacYPAy6ttPJ76I2ENZCQwJaXxJVzD1oE9uKvrub2Wt 6v82xCBHrO/7cykYCj+gtLR88OKpLBk1gH6iTcPcMlSflBWhDl/2OVHuce76tLx/hu h+yFlMoGobSuQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/12] mm/damon/core: implement DAMOS quota goals online commit function Date: Tue, 18 Jun 2024 11:17:58 -0700 Message-Id: <20240618181809.82078-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D084E160019 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: uxuy7qdfuwi881nxfj9fjy5ywntth3rn X-HE-Tag: 1718734700-858941 X-HE-Meta: U2FsdGVkX18I+WVfideR9TlzRn9QVwOj9+/xG42ypXj3VTv3+d3mO5HXSkmht+LzB3xhdyU+3Yv0thPKVb0fV0NmlNpcceOM5oBnSFjl7CTF87biAqxrf1ihi4WsxIjW6iSV5x3SbQ7GnZuPW9d6Sqc9c0l/31PdSAn8mqchJJNoXc/dVzAggGpKLgBKuLPVsV1K/BlovP24J6QS8tQ/2bJZnf6MhpPdZJJPNDoHYQzVoUx6vvz6Z6NpK5oKbFtpGrWS2ARspEKdleUOem2hmqt1nBYZT8bCBIUFUC9jop3Rd5CAFMX1AvaPOcXWClu3PP+bB7DyMDYubgFRBaxgZRFFZZyBYHxeERFui++lNP/+BB92zRfEJDNNmjHh/v9tjql2Cm4rXq7fabvg9s9w+LEyFkQgAxOIPthcPpL/OC5zHGO45QfGwth24rob6wc78VlscMPKkcHjj2rrCwOmd7w/a4DjoOr+PtsQLtO/y7Sjsz73YD8HIPlHHuZSWH1DBdwHMtjeFdpPLpHhRksFsaKG+orkkO2248IY40juQMqt3sLEryqheFaLOGO2+ne6wrmq7UTuKA5OyMAAfnHmlA6B6CYVeuSIeiYBQk9Uj0t9R4E0W7pdrtYkv/HOGffYRuP91+Fvpk8UVCAu2IEhf6frxr4OSwHV3rhPgZ51XwlJiNjRTuRZt36Tlkoni7yDXJ+s7jry5wkaxpj8vKtesjcTp68L754Gjay8g0pdjf5wZpj/bsGTg30OXCOjowTwcdmSuiD+1BnlLE9liUq6vF8BZ3fG7hqDB34DJmFnZ/pJ+B1uabBVh1x3rImxvC7Ipk55Qb/CUmKoiNjEQeaZQzmWYKtQ+d6PBYg2BrnFUn7kJe39kyS4G9djDHTXYj6B9R4YFvVk6KiGTm7xwqHezCW+sT4KZO6DvmuNvEb1XeJS6pKRV36a0UR5v+EIGWawPlLdzVmQK3QL3iWNEUp EmXMIQWG oH6NbbWnFTLK9Y8xAa6bP6pnB7PJv4FK25aIPQ0cMU/8zga0YXneUnsPI19gxQ65/tbjyOmq9Iwb5ouGhCqPBpZPsfuF0PRowTH61yV4z1ctdU2+XrdwKmAPR9b/Z+vzVEtckHbjio1ZdcV2mYSFdtnZflxNFwRGQpfNDf3uZ/pcYpiOeY6ARq98pN9babPqC/dm2nUhEHBk1Po1T1cE/Tx3bdsdHlhRyphloADwlsg7a4ms= 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: List-Subscribe: List-Unsubscribe: Implement functions for supporting online DAMOS quota goals parameters update. The function receives two DAMOS quota structs. One is the struct that currently being used by a kdamond and therefore to be updated. The other one contains the parameters to be applied to the first one. The function applies the new parameters to the destination struct while keeping/updating the internal status. The function should be called from parameters-update safe place, like DAMON callbacks. Signed-off-by: SeongJae Park --- include/linux/damon.h | 1 + mm/damon/core.c | 59 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 3d62d98d6359..ce12c9f1b4e4 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -742,6 +742,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, int target_nid); void damon_add_scheme(struct damon_ctx *ctx, struct damos *s); void damon_destroy_scheme(struct damos *s); +int damos_commit_quota_goals(struct damos_quota *dst, struct damos_quota *src); struct damon_target *damon_new_target(void); void damon_add_target(struct damon_ctx *ctx, struct damon_target *t); diff --git a/mm/damon/core.c b/mm/damon/core.c index c0ec5be4f56e..b538a31fbd83 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -666,6 +666,65 @@ void damon_set_schemes(struct damon_ctx *ctx, struct damos **schemes, damon_add_scheme(ctx, schemes[i]); } +static struct damos_quota_goal *damos_nth_quota_goal( + int n, struct damos_quota *q) +{ + struct damos_quota_goal *goal; + int i = 0; + + damos_for_each_quota_goal(goal, q) { + if (i++ == n) + return goal; + } + return NULL; +} + +static void damos_commit_quota_goal( + struct damos_quota_goal *dst, struct damos_quota_goal *src) +{ + dst->metric = src->metric; + dst->target_value = src->target_value; + if (dst->metric == DAMOS_QUOTA_USER_INPUT) + dst->current_value = src->current_value; + /* keep last_psi_total as is, since it will be updated in next cycle */ +} + +/** + * damos_commit_quota_goals() - Commit DAMOS quota goals to another quota. + * @dst: The commit destination DAMOS quota. + * @src: The commit source DAMOS quota. + * + * Copies user-specified parameters for quota goals from @src to @dst. Users + * should use this function for quota goals-level parameters update of running + * DAMON contexts, instead of manual in-place updates. + * + * This function should be called from parameters-update safe context, like + * DAMON callbacks. + */ +int damos_commit_quota_goals(struct damos_quota *dst, struct damos_quota *src) +{ + struct damos_quota_goal *dst_goal, *next, *src_goal, *new_goal; + int i = 0, j = 0; + + damos_for_each_quota_goal_safe(dst_goal, next, dst) { + src_goal = damos_nth_quota_goal(i++, src); + if (src_goal) + damos_commit_quota_goal(dst_goal, src_goal); + else + damos_destroy_quota_goal(dst_goal); + } + damos_for_each_quota_goal_safe(src_goal, next, src) { + if (j++ < i) + continue; + new_goal = damos_new_quota_goal( + src_goal->metric, src_goal->target_value); + if (!new_goal) + return -ENOMEM; + damos_add_quota_goal(dst, new_goal); + } + return 0; +} + /** * damon_nr_running_ctxs() - Return number of currently running contexts. */ From patchwork Tue Jun 18 18:17:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702811 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 864F7C27C4F for ; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC7B08D0034; Tue, 18 Jun 2024 14:18:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D76278D0001; Tue, 18 Jun 2024 14:18:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C171F8D0034; Tue, 18 Jun 2024 14:18:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A10B58D0001 for ; Tue, 18 Jun 2024 14:18:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 165E8809CA for ; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) X-FDA: 82244819202.08.1354929 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 570232001C for ; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CkmS4eEK; spf=pass (imf13.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734695; 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=fmD+YHeUU7T1BfTsvkZhw/pfGl8QivhafcPBkn4teHU=; b=c0khmUp6XN7v+4lF2+xVpJ469HVf1U5kUXYQk7pM5k/RNoHhhVJuBhaF813R3w3MqO3Ckb CwyHtYig+HtgfnjJtmeHvxhWj5fxc80b9YlvOe1kDbCCnwZ4adZ9XcUJ4sVK4MKCeSeke9 /xDIxCYYWW9ZKoMJqgAXV+O/z25y0uw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CkmS4eEK; spf=pass (imf13.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734695; a=rsa-sha256; cv=none; b=DQWz8ZuV58otzU9jgmxTA2ZVzvXAKVXenMagEKiYKGe6Zt5VB1kco9oxkntj80Fbnm+/PS dqT2h7J2WfRRHe6p+LgYhcVMId/sW5ezKovBK4SOQO/plM0l+ky0jMceZUmQs7Dj98pEjh ND6bYccsU6rc6U6iV/FLbXbqv1YoxZM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4769261A18; Tue, 18 Jun 2024 18:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8474BC4AF4D; Tue, 18 Jun 2024 18:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734698; bh=q0VgTmMSaytJbmDQpkmd078K1WOntRHHU6KIbNuTpyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkmS4eEK+RGfSEGakhprTqdICLAAHvNYxJWUiXjUbGGUa5c6g2ophuL2Wu8Lj0a1C cI9uAFIlIZxeUzwJuzK504OugxjO/3Ua7SB5qS1eWPxpLYzM+b31bBJlf48dwAJUno /Y5k6Mf1WepHXE6coENrRieznOFyab+/mDECE0L80avhvug04yb3GIYBOLReoLH64A QJ8ex2EB7T5XB9Vk0xWSgyVRRuou818fpVCzffjhpE3ITKdfNS6sl6kdzkMpaoJgy3 3La4c8cUV4YbnnKB/FkY7lwXSo7AfKK8M3YucH1dnjULop/2RDwwZjnHy278NioxT2 +JswtLTRyuriw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/12] mm/damon/core: implement DAMON context commit function Date: Tue, 18 Jun 2024 11:17:59 -0700 Message-Id: <20240618181809.82078-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 570232001C X-Stat-Signature: zwekgja7hjnzbfjmj58w6tsfefmst31i X-Rspam-User: X-HE-Tag: 1718734699-426288 X-HE-Meta: U2FsdGVkX1/wvcUaU2/kF/0jznLlUsxLBXpGoq41SIl9OoNzHKhCYrUKZuOcCaMGsl9/38JqT4xKBtKUtfw5nEtuWjTwNL/vo6xCPaE5vhct2WYZIaPBi1wKTAHUMwlAzcif2UqjMocPQgcnE7Hi6MxA3CrKsQezx1fv2213Rj+8p6LiMJr9vE9n4Es1WeWBwAGHlV3ZjFZouXcWd9V/chGp3L7D4KNtcwqACm4/g4M88lJsryp78b+pMhLaMWV4P/UtBLTaGeKeqF+gsInq/TrqUo6D8TSAusPXUWIm3OlsecO8TQIwW9Ykyln6lsmCM6mEiSWqAHvoGPtnoFG3Rt+nidrcEg5vl8myavrR8mHoNUZ+pN/J6Ee+YXPgWZp+BNdoeengYjG5+PbyCbFWPStpjVjzmqfRxRevDcOLk2qz0NRkl/Rc0+xxpYfJywnNKLNTzxc5L2t3O4xxoZG0nx923CVLnjWYP4EJQPGN2dfXU0A9XzwSuJFMbYCn7K/0k2HSjAKdaEYQUnK1rDP85MO2gsr8jBavqvtsR5MhWww5lshM5mZE0pfPq/sYhZs59EIOdQ1SGJckVTEwyGWB8nQe2dqDq1scYpsXSZK8H0gOyncNaiKPHPr4UMBR6jNjvD/h43byBQ79Z+JdvIfBscfGUXZTVtYtFM0eFmraD+BYrlHsD0mMS44XP2MdPiwhwqEOEAom/IPSly2Tk4hxoWuTJ8NJ5lZ8uDlovj/YQ3YGoJHs92jW3KJqq7L0PZpKNrTOy546i2Jvkvvlq54w/PzKq+GU8unDjo55QgjGYJe+KRXL4L5l6oyGPf6kdDjioYmCdocKqp6CuDUfouhqCNJ0mGg368RzaWwRoQ4dkMnfk167T0JdINflvU0esz0x9fpNwhzFJy6TzWhwO+/D+dlxiRzsH32NE/PYr0SgUMbX86jG27XDRpnIttM/q4GE9e+DFWgGx0SrcgalNWq NTawlRUA FOCxxzGUdWztyNZPjNN6XKVp4fqshtEN8lbqNcO93bjrmsoxnEGDvoPCmlHLg4bYTkBdaAtA884fvIvPzzy4ew16s9LZHOsQ6WPSJCpjO1JY+rJi0suliGUWeYa3d6MENuYAGR0gh3op4kDFR8l5Z0fr+6moFCF6g4WkO+FuuSwR1cRTA9Gy40CjcEufWA6Smr2cWFTUDXvvjy78wOtXAH3iVVBA6sqlQ2RA2iNseU/DTmP8= 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: List-Subscribe: List-Unsubscribe: Implement functions for supporting online DAMON context level parameters update. The function receives two DAMON context structs. One is the struct that currently being used by a kdamond and therefore to be updated. The other one contains the parameters to be applied to the first one. The function applies the new parameters to the destination struct while keeping/updating the internal status and operation results. The function should be called from DAMON context-update-safe place, like DAMON callbacks. Signed-off-by: SeongJae Park --- include/linux/damon.h | 1 + mm/damon/core.c | 274 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 275 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index ce12c9f1b4e4..27c546bfc6d4 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -756,6 +756,7 @@ void damon_destroy_ctx(struct damon_ctx *ctx); int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs); void damon_set_schemes(struct damon_ctx *ctx, struct damos **schemes, ssize_t nr_schemes); +int damon_commit_ctx(struct damon_ctx *old_ctx, struct damon_ctx *new_ctx); int damon_nr_running_ctxs(void); bool damon_is_registered_ops(enum damon_ops_id id); int damon_register_ops(struct damon_operations *ops); diff --git a/mm/damon/core.c b/mm/damon/core.c index b538a31fbd83..f69250b68bcc 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -725,6 +725,280 @@ int damos_commit_quota_goals(struct damos_quota *dst, struct damos_quota *src) return 0; } +static int damos_commit_quota(struct damos_quota *dst, struct damos_quota *src) +{ + int err; + + dst->reset_interval = src->reset_interval; + dst->ms = src->ms; + dst->sz = src->sz; + err = damos_commit_quota_goals(dst, src); + if (err) + return err; + dst->weight_sz = src->weight_sz; + dst->weight_nr_accesses = src->weight_nr_accesses; + dst->weight_age = src->weight_age; + return 0; +} + +static struct damos_filter *damos_nth_filter(int n, struct damos *s) +{ + struct damos_filter *filter; + int i = 0; + + damos_for_each_filter(filter, s) { + if (i++ == n) + return filter; + } + return NULL; +} + +static void damos_commit_filter_arg( + struct damos_filter *dst, struct damos_filter *src) +{ + switch (dst->type) { + case DAMOS_FILTER_TYPE_MEMCG: + dst->memcg_id = src->memcg_id; + break; + case DAMOS_FILTER_TYPE_ADDR: + dst->addr_range = src->addr_range; + break; + case DAMOS_FILTER_TYPE_TARGET: + dst->target_idx = src->target_idx; + break; + default: + break; + } +} + +static void damos_commit_filter( + struct damos_filter *dst, struct damos_filter *src) +{ + dst->type = src->type; + dst->matching = src->matching; + damos_commit_filter_arg(dst, src); +} + +static int damos_commit_filters(struct damos *dst, struct damos *src) +{ + struct damos_filter *dst_filter, *next, *src_filter, *new_filter; + int i = 0, j = 0; + + damos_for_each_filter_safe(dst_filter, next, dst) { + src_filter = damos_nth_filter(i++, src); + if (src_filter) + damos_commit_filter(dst_filter, src_filter); + else + damos_destroy_filter(dst_filter); + } + + damos_for_each_filter_safe(src_filter, next, src) { + if (j++ < i) + continue; + + new_filter = damos_new_filter( + src_filter->type, src_filter->matching); + if (!new_filter) + return -ENOMEM; + damos_commit_filter_arg(new_filter, src_filter); + damos_add_filter(dst, new_filter); + } + return 0; +} + +static struct damos *damon_nth_scheme(int n, struct damon_ctx *ctx) +{ + struct damos *s; + int i = 0; + + damon_for_each_scheme(s, ctx) { + if (i++ == n) + return s; + } + return NULL; +} + +static int damos_commit(struct damos *dst, struct damos *src) +{ + int err; + + dst->pattern = src->pattern; + dst->action = src->action; + dst->apply_interval_us = src->apply_interval_us; + + err = damos_commit_quota(&dst->quota, &src->quota); + if (err) + return err; + + dst->wmarks = src->wmarks; + + err = damos_commit_filters(dst, src); + return err; +} + +static int damon_commit_schemes(struct damon_ctx *dst, struct damon_ctx *src) +{ + struct damos *dst_scheme, *next, *src_scheme, *new_scheme; + int i = 0, j = 0, err; + + damon_for_each_scheme_safe(dst_scheme, next, dst) { + src_scheme = damon_nth_scheme(i++, src); + if (src_scheme) { + err = damos_commit(dst_scheme, src_scheme); + if (err) + return err; + } else { + damon_destroy_scheme(dst_scheme); + } + } + + damon_for_each_scheme_safe(src_scheme, next, src) { + if (j++ < i) + continue; + new_scheme = damon_new_scheme(&src_scheme->pattern, + src_scheme->action, + src_scheme->apply_interval_us, + &src_scheme->quota, &src_scheme->wmarks, + NUMA_NO_NODE); + if (!new_scheme) + return -ENOMEM; + damon_add_scheme(dst, new_scheme); + } + return 0; +} + +static struct damon_target *damon_nth_target(int n, struct damon_ctx *ctx) +{ + struct damon_target *t; + int i = 0; + + damon_for_each_target(t, ctx) { + if (i++ == n) + return t; + } + return NULL; +} + +/* + * The caller should ensure the regions of @src are + * 1. valid (end >= src) and + * 2. sorted by starting address. + * + * If @src has no region, @dst keeps current regions. + */ +static int damon_commit_target_regions( + struct damon_target *dst, struct damon_target *src) +{ + struct damon_region *src_region; + struct damon_addr_range *ranges; + int i = 0, err; + + damon_for_each_region(src_region, src) + i++; + if (!i) + return 0; + + ranges = kmalloc_array(i, sizeof(*ranges), GFP_KERNEL | __GFP_NOWARN); + if (!ranges) + return -ENOMEM; + i = 0; + damon_for_each_region(src_region, src) + ranges[i++] = src_region->ar; + err = damon_set_regions(dst, ranges, i); + kfree(ranges); + return err; +} + +static int damon_commit_target( + struct damon_target *dst, bool dst_has_pid, + struct damon_target *src, bool src_has_pid) +{ + int err; + + err = damon_commit_target_regions(dst, src); + if (err) + return err; + if (dst_has_pid) + put_pid(dst->pid); + if (src_has_pid) + get_pid(src->pid); + dst->pid = src->pid; + return 0; +} + +static int damon_commit_targets( + struct damon_ctx *dst, struct damon_ctx *src) +{ + struct damon_target *dst_target, *next, *src_target, *new_target; + int i = 0, j = 0, err; + + damon_for_each_target_safe(dst_target, next, dst) { + src_target = damon_nth_target(i++, src); + if (src_target) { + err = damon_commit_target( + dst_target, damon_target_has_pid(dst), + src_target, damon_target_has_pid(src)); + if (err) + return err; + } else { + if (damon_target_has_pid(dst)) + put_pid(dst_target->pid); + damon_destroy_target(dst_target); + } + } + + damon_for_each_target_safe(src_target, next, src) { + if (j++ < i) + continue; + new_target = damon_new_target(); + if (!new_target) + return -ENOMEM; + err = damon_commit_target(new_target, false, + src_target, damon_target_has_pid(src)); + if (err) + return err; + } + return 0; +} + +/** + * damon_commit_ctx() - Commit parameters of a DAMON context to another. + * @dst: The commit destination DAMON context. + * @src: The commit source DAMON context. + * + * This function copies user-specified parameters from @src to @dst and update + * the internal status and results accordingly. Users should use this function + * for context-level parameters update of running context, instead of manual + * in-place updates. + * + * This function should be called from parameters-update safe context, like + * DAMON callbacks. + */ +int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src) +{ + int err; + + err = damon_commit_schemes(dst, src); + if (err) + return err; + err = damon_commit_targets(dst, src); + if (err) + return err; + /* + * schemes and targets should be updated first, since + * 1. damon_set_attrs() updates monitoring results of targets and + * next_apply_sis of schemes, and + * 2. ops update should be done after pid handling is done (target + * committing require putting pids). + */ + err = damon_set_attrs(dst, &src->attrs); + if (err) + return err; + dst->ops = src->ops; + + return 0; +} + /** * damon_nr_running_ctxs() - Return number of currently running contexts. */ From patchwork Tue Jun 18 18:18:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702815 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 E8393C2BB85 for ; Tue, 18 Jun 2024 18:18:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D1DF8D0049; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 030DF8D0041; Tue, 18 Jun 2024 14:18:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB5D78D0049; Tue, 18 Jun 2024 14:18:25 -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 E375E8D0047 for ; Tue, 18 Jun 2024 14:18:24 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 91B941A0260 for ; Tue, 18 Jun 2024 18:18:24 +0000 (UTC) X-FDA: 82244819328.23.95C5301 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 8177F180010 for ; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aYOkhPAI; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1718734699; 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=D+bS6r7fj10qDfK0KHXb3u39/YlU/kxNt/qAwrg8pPk=; b=G5zYY99+9p1TxQ/u1zcaIGM4I0TFyjAwdpcxNI4CO7vU9cx4lnire5BScvhykkpASl6xTX lQbKq85piPBblhdK8GfhxVKIzO9arQVd281h64qP9HPLzCbKN7TggnoHfW7HWtw1vQ+zaG MiDd0z7Tcx4nNXx95WKDc5DQjp8YIus= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aYOkhPAI; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734699; a=rsa-sha256; cv=none; b=4qOmW1AfkDX+n5EXtBWTnXz/gJKOS5bYov2Xo3dpy0gAmhD0SU0EpCmann+RSs4NrJgvEO DPOIXlCJiSc/e0LE5lzkaSys2Xl/sxAvkXAzzeT9k4wq57xDoW/s7A6DE6E4wSB9JCVO7K buY/hqfAC54I/RD/UWKz4U99zPsZ2wU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 744F2CE1C0A; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31A89C4AF49; Tue, 18 Jun 2024 18:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734698; bh=iHi9F2LJwfRH7bQXO7MbPtxBZ9hQhqVO/mLP8mATsq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aYOkhPAIdBUFDJZuuOt/U3pLKRvSSX6WXYHpo+fIAycQr3OgTttGwtX284KPO+qPd hPVHPYRAtFozTVYqtkOhu2yi1QuxXf0q1fDgbkyNr9zb6YBKJdtc8u3LenvjZxZjhS ikrcX0GVUDeS6WeqszBOgeAe7eDR1c7gJhPc3iHVs8eDGvnMC0s8naVmIA6dH5+QGb ijPhu813BtP4jEPR18XhavPEc9pJ4IgbSuIqyrQRE/2Q5cv/Na8SAX8D4J9Hqo8ams YfHlm52WY2W/hyEXKQLccxzAtQlY4VNpvFvletIxoA/vcD4xKg3jgcWp8zqTeYdfTV BMtuWx94rR9Fg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/12] mm/damon/sysfs: use damon_commit_ctx() Date: Tue, 18 Jun 2024 11:18:00 -0700 Message-Id: <20240618181809.82078-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 8177F180010 X-Stat-Signature: 3edmc4kur48zwizgabaw99hkkhzsoiep X-HE-Tag: 1718734702-160659 X-HE-Meta: U2FsdGVkX18+bc3RjTE/8RW7R+66NrCKjlnotrUN7GvsMj+ikBl3CBnGws+s5wsE+Ry0tB6wwedV24nWAE8EgygTze4A/1oDMPn5ObU5qIkgfq8bsAwJ3yjnfN4GeB77LOlVrVAHsAoHhfWwzK5YuUNeoL03QU/OeD0I7KlGpuj70L+vscj2HaZzPr3tPr/gfqt2LiSit1ZfMmgTJYCeciOcPQ8MnpcR/0C6kf/f5nZj7pdcehpmZTfr+fBR0LAIV9027nyDZCw232li8lQpXLpGifu8HjskR0Y7/BeFaChoPuee6xQ5Rc/5dtbT1xg09p/an3j12NDjMKpJhlBAt+Wt8dR0D6BlpWOpueFPnIcQteSM9kRQfprkpirZPWNwPcdQ294XNgsPANJG6gP3S/wrSPVLxoEzPxB9m9TkfoVEUjzJ/gPtlnd8DHw16cmuLFO8G9s5p1EP9wit6C9fgx5SxPQ2k8Agmmqj1Sztoqf7PgSegHrppjGWdAKycq5C705bu3Hi43Yohuz67mm/oL7eUBQiJfRqQNSnZKHfh8YTLWLzo8KWVzMgblNFzez8qBizE9v6OZ3wfhdvOv6BOm0CxVUqQ2IEkX0KOuoPaP02dgjwPaM1qeRMxsnhT/whK5B6pxLII3hLrO1kmJwgCNMc+H25ZDV2IlHgGMTL0H+hnpVWJp1RK5gA/xEu+3YmrgGWUJyTss2FALBXhqXALuMR0Dg1gLhnvVvRhfD4ojEEt3U6EitadiLV9oSyPzlOYNUB6LVUB4Z2NbXTHiU/+1VKYOB5mZIKyZoPfnWpvYjs109eo66NjrZQnWoUKB+QHydObrzqR2ebA8gUaR2v4C6s3qUwo9MVFbLSB0ouSL8gPYXDjkj5Csd3qJxwgG4PpWcy8Od28VFDsMRmSwMosIdEIuMCKIKwlgJ1bQjI8+4xSPjzThfq1WaaE7WbbaPHciw880PMd/FMN3iG+Wy BZuquJjy QrwxnUYt+kUCtRf/xtil0cbNkUidVXeRHviLwbQD7hMVs22YZVMSduoB3ILdpOm5ESb5LJD+bgq7eucx6ipwhRqpfH8O318CmVWCqhcP4spYmRUC+C1ZcK6no31xDfYFjcbpdacJ59kfHFdlTTIkoSmQWdBWLe5vfzjcsV3xlmUx/kSDcmqUVkW0EriBDOzTf4F2ZgWbugMqM7+gnITcV2TQ0sJ6SVY0b+IXQIvhkmkd899xgNTCmc08UGpRLuA+l+b310lK7G8as7noBwKYyb4k5dQ== 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: List-Subscribe: List-Unsubscribe: DAMON_SYSFS manually manipulates DAMON context structs for online parameters update. Since the struct contains not only input parameters but also internal status and operation results, it is not that simple. Indeed, we found and fixed a few bugs in the code. Now DAMON core layer provides a function for the usage, namely damon_commit_ctx(). Replace the manual manipulation logic with the function. The core layer function could have its own bugs, but this change removes a source of bugs. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 6fee383bc0c5..0f9fe18beb40 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1345,6 +1345,9 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx, return damon_sysfs_set_schemes(ctx, sys_ctx->schemes); } +static struct damon_ctx *damon_sysfs_build_ctx( + struct damon_sysfs_context *sys_ctx); + /* * damon_sysfs_commit_input() - Commit user inputs to a running kdamond. * @kdamond: The kobject wrapper for the associated kdamond. @@ -1353,14 +1356,22 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx, */ static int damon_sysfs_commit_input(struct damon_sysfs_kdamond *kdamond) { + struct damon_ctx *param_ctx; + int err; + if (!damon_sysfs_kdamond_running(kdamond)) return -EINVAL; /* TODO: Support multiple contexts per kdamond */ if (kdamond->contexts->nr != 1) return -EINVAL; - return damon_sysfs_apply_inputs(kdamond->damon_ctx, - kdamond->contexts->contexts_arr[0]); + param_ctx = damon_sysfs_build_ctx(kdamond->contexts->contexts_arr[0]); + if (IS_ERR(param_ctx)) + return PTR_ERR(param_ctx); + err = damon_commit_ctx(kdamond->damon_ctx, param_ctx); + damon_sysfs_destroy_targets(param_ctx); + damon_destroy_ctx(param_ctx); + return err; } static int damon_sysfs_commit_schemes_quota_goals( From patchwork Tue Jun 18 18:18:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702812 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 F2947C27C4F for ; Tue, 18 Jun 2024 18:18:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D3A68D0035; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7834B8D0001; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 623DA8D0035; Tue, 18 Jun 2024 14:18:22 -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 4848F8D0001 for ; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DD1D780971 for ; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) X-FDA: 82244819202.24.CFAEBA4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 4F22C8001C for ; Tue, 18 Jun 2024 18:18:20 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GhpVrpYn; spf=pass (imf02.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734693; 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=iK5ypQ/OwhfWGwDoVk4KJsQmqrvAKkO7trlsPbZNQ6A=; b=NTW6PCJKZpHndn6ASqj/GEJF5EnAWDEVlFExaeyzkB4CRWPzJ28ttmche8MOPjE0QiQew0 CEO2wb0MgNpyQ5nrY9wEYawyTEsJwlFZ4p8xixt8zL6eHhiiLzpBYLwwPjwumDgwLSuLa2 BScryswDrpBXjDY9KGPPqcAXx+aR0E0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734693; a=rsa-sha256; cv=none; b=nqzz98do+Pa7EODQNgbLY+DHo1TpShavttR9ZuGTHKI7oJdocMVoaPFeSikxkZkYRMWljM xwHXVswzlLaXuaSXTvAs2QSNgFVHOZXgpCtbXSUYw4Kzlo5uTAFBZu0Ru4+TWbCoWnF32i PJZ85SqDg3IzrkcVqJ0DcFU4XDxuEPQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GhpVrpYn; spf=pass (imf02.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5D4A761A56; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8129C3277B; Tue, 18 Jun 2024 18:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734699; bh=vyu4uJ3nrBS9zXRgwSeDU7byk5QTt4EqJtkm+FLnKWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhpVrpYn44Wb3cl7ZfbnbyU1jS+5Zjc/B6MgPWl7lT9sv8IsCZd5lgVxQh9JhVPUM ZimB/lpOIiJ1meXbMj8oWQcrGfHLkFYxdRr12LhUnjQadgFAwdX2mZb68RhZSx5JGF 6qgA2za6SHEY5hjYVT2mbYaccCOKIIMRycGSPbfr7Qiw/0zO/RoukbVLXIndDCNve9 9ItQOg4Jk/OKE25fqQMBHMwUcLO/u7gBX9XxdVCe/Lw2HxsiHDQ+tAwlGimU4O2xpp 9wsEmirmXF7I2SOILuIxxo5jJOvRz759lWRp9yuOcSebyBz6qchrzF4SPgFUj4WtR1 MEjxIArfqSJqg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/12] mm/damon/sysfs-schemes: use damos_commit_quota_goals() Date: Tue, 18 Jun 2024 11:18:01 -0700 Message-Id: <20240618181809.82078-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4F22C8001C X-Stat-Signature: krrnkiccjynbyubjzcu34s81pc559ii8 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718734700-609024 X-HE-Meta: U2FsdGVkX184e7Ei8Ka4f4qrQpJvuccP3Vg05XnhWph/MhPIpfgysXzEfbSumiMkc5m6dbWPg7X/EUXgxbrlGTgFK+b3aylvGKrkwmeRHeD8R3xrabBjQ2+xb3eQAlLwAlMej7CUSSUg3BXEcVzGSFrQ1nW0taPmsGVS+kb2HYvv+z+sFeTa/DTiG5I/fvEjH5xksyhqnSFnLex8yQ6GAbAv7JANrUqv9YQ5+j3WmlU2lcNmcXMmXvsaUdrc/x9yxa0j8s1C6uWCBxRNJZ64uGPfrE8jB1bCAl3ANigDTYFjnCfjWvnq+nBxTqx/x6C01hhyD0HApc9ZGqP6T4sQZMQrX8aaLiIzRwdTszNPoZEkSL5Wj5kCTVA/KlGzczJdXAyGyVLDfOLapnZw2jLWsxa7n40X6l+R+Ib0dUpgEvuRNhdiCbMwMhrjLxkgIqf9reetINjw1NAHmZThIByr/G+TJbT5IwhTOWUZeEHnM9c+HXYqwLBqudUhiQuCy97d9wOC645aZIjFXn4Z7VnNqkfYRae+B5kMe2YLXPx91i9DjKYOzZoSUhmutjWJV+crTrgdAFSWSNMNAmgvdB/CuoghqkGuimRackNUcZ9sOUSI3H69/pS5g+dwD7/gr1qNKeWP3Xoke/ResijTzLK1oxLhT8EJm9Rx4JiNCUUiyMQGnnozD2gPtoYnyOjwHU3P4qb6vXpeNT0VRxJaX3Jik8/jdlAvMFnwVON8826nN29UUg5w/xUi0Fjta2b2Jj/3p7KAHrnNccJz9NWnLDmzEE+K1WUzTy7KxpIlXUGJcZQQacvksYysIRvTicNDKsRoJ6re5gYHzMfqD5cAbDhH15HuaHZD/iYpSJpD6/W5sKsBShTC+y12G1wbnT7IDpKwXNIBsVyG3Gayt/M9u+1r+I40YUrCx3qmRB166j9eyIvThGbEvVG+OrYerLPyE9uqwWrsg9gmf0TqcYyqYPD j2P74Swi eWrS9Ig043XOAVD/Bvtc2HsAYyTUxi4/C02iifSnl9uny5BjOGAJkYeGERgl+oNSrss5pBvBg2+gli4SfSJ8kw7zi4bpv2EyS1Yt6IWaHdSgVbYl4QgC/HDnudbOwSljTVtWU/MMkUgTxiaZFBnIbOL053C59Ex6x4jWDm/ZEa4DQYpN0r+iYO18jS2AjZagkueHNKQB7CggkF1/oF8BsFvFzH7tVD42KSfODY47WWhc+bVhsb+oJX84rxqfIMDhknWZCtGVL63hxRgbW/cx3kTQHIA== 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: List-Subscribe: List-Unsubscribe: DAMON_SYSFS manually manipulates the DAMOS quota structs for online quotal goals parameter update. Since the struct contains not only input parameters but also internal status and operation results, it is not that simple. Now DAMON core layer provides a function for the usage, namely damon_commit_quota_goals(). Replace the manual manipulation logic with the function. The core layer function could have its own bugs, but this change removes a source of bugs. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 66fccfa776d7..1bccf2619e11 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1983,10 +1983,13 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx) { struct damos *scheme; + struct damos_quota quota = {}; int i = 0; + INIT_LIST_HEAD("a.goals); damon_for_each_scheme(scheme, ctx) { struct damon_sysfs_scheme *sysfs_scheme; + struct damos_quota_goal *g, *g_next; int err; /* user could have removed the scheme sysfs dir */ @@ -1995,9 +1998,16 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, sysfs_scheme = sysfs_schemes->schemes_arr[i]; err = damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, - &scheme->quota); + "a); + if (err) { + damos_for_each_quota_goal_safe(g, g_next, "a) + damos_destroy_quota_goal(g); + return err; + } + err = damos_commit_quota_goals(&scheme->quota, "a); + damos_for_each_quota_goal_safe(g, g_next, "a) + damos_destroy_quota_goal(g); if (err) - /* kdamond will clean up schemes and terminated */ return err; i++; } From patchwork Tue Jun 18 18:18:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702813 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 55A38C2BB85 for ; Tue, 18 Jun 2024 18:18:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F5318D0037; Tue, 18 Jun 2024 14:18:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A66F8D0036; Tue, 18 Jun 2024 14:18:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA7B98D0037; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B545D8D0001 for ; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 63D9380985 for ; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) X-FDA: 82244819244.05.766F1F5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id C3B54140007 for ; Tue, 18 Jun 2024 18:18:20 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="gQ/CB4r0"; spf=pass (imf09.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734694; 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=lZw5UshCrbLVu/J9nDf0egiPlz/h8iuY3CLlnC8azGw=; b=6bu62bct91fbis/PooaiT3p8uRN4Wm1VDHEsxhZlUvaK/2hV1aNVbivgqhy6LeoCnXb2SG QEN69AGDqMUHG/zRpmT4BdaZjmgWW9PlpaUfPh5mhbXb+DIwp9f9mG5igpvbxnHeAKiUfA bpU/cOymYWHjaCHJPEId3SPTJKVGJN4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734694; a=rsa-sha256; cv=none; b=JN8FZ+SLhpycjwC6kX32MjYrkV8y9lwTqgpLYU493nEC1q2/fbn9gglraGVsBtcq7eVScR c8scV+003YN9rjWi3TGa9bK9Mhz2QlKRLAOYrOLEPt3Pc+4Stu2RpIVPfUsmW2HZAwZ7z8 lFqfSMpdz6uRUwyK/KMk0lwPtubJSS8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="gQ/CB4r0"; spf=pass (imf09.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EF8EF61A5F; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66037C4AF64; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734699; bh=kQhv3CeO5+UCw9SJSn7ZxV5sAw44NEd/krZ6l962Oqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gQ/CB4r01A0ClGT+QwDaT7ylpWMw3N+dob/wzVdm7wJD9HDuPo57XRBVku1+5BZZf k3KE4bLPtcIAsUXjZo670ljF89YMHona8451FMZ4mkRU0iCVHxswVKcO2vt6BEX98O /hnQh6TPCFAvWEHUNflOSLMe0hpR4jPahbJJKcHwmBVcWD3Lqa7WgKWlD/LKud4EYT sth87vbfVIsgkevcpxrNdwA7VVIsqeJWdAvvt+bPPmSN0Ap1KHOC9+DI3gJ/2T2LXL ymXCzvt+u91KmVkLalchFgH5miTU3BoCS9AXS1b0NVnnJCMM5fiTHaxV+BMjWJDZuq XbtAtMPFPO3kA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/12] mm/damon/sysfs: remove unnecessary online tuning handling code Date: Tue, 18 Jun 2024 11:18:02 -0700 Message-Id: <20240618181809.82078-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C3B54140007 X-Stat-Signature: 5kn5sspazpg8p46mzch51u5ssbiuusaa X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718734700-490179 X-HE-Meta: U2FsdGVkX1/LmuzqHdLFQL11HROv+xskPA/in5pLx+UYi+Dnz0mOcLwv81XOiXULpR30KC9Lgd3iuKgc/HcXpqnlaabREixXIukjmULDo1ubWcB34YvD38gDOyecN8BU6GM2V5pf0Mn74//v4cgjWGKf3rMJXumMprs9YADMvIw3kqOR8O8+UH0vzTly2aqdRvKY7yyJhBAl2b8fLP8SLWG3NzqpoHJ6NacljYMFD0UIQB0A21vujqoEe2SIxlWQD4KCD5jL6YGeTsk2aBFosO4wiVgTsQl82c7L2AuAMnRf6RfywvEAxSyMyPhWRq5eJcgUuvYTOJVfRGGPji1H5zNQjcE1stWEKwQVHsVFWv0lBhjQlHyatjH7HBVmYijIB8PSM+OuCCbhyDdd2Lap0FRs9snDJqwQEj9ZUiIz59NC6CI5UoHE7DT/ZCvNxKH6gTg/RLptr8Y8dWVJzk5/5PGu7NAJXcbPHsjjLM9s6iinkQOl4hD3074KOkmq1CXPs6QzePbScRiKoCoYZdxv0sCO/4D0+0vx/nI/OC1q6oAscvVtLX1enKB0YWQb8ufolyAFMdH1jqWt28StltIldW4GVJdYzQGqYwUYhxlpafZ7IPhlr+N6n+JfNQB0G9pT4rbJc207To7nIDg3lHGb7O1laxPZWe3Kfou634lEiVxuf6pzTT4fS26lTrEUaBEibxhW09bGnWNfk9L5lIC1JCBUI2tb7H2ROTVEUpoNc/RZsyn2Fk9i7N9OEROy0VkKZ+/iVgzRf0WvzZ8ZoPepPPJNSEYt1MejWqGGRe53aPx2UERzzJL8LsrlZ2wJTBknZb5s/tPV0EjytAkpYedT91PCTqwxkoc4JL5S6PztwfEhaXKNohGSuANGMLXbNpJMod+ZnScnnVGvk1ws9Xkmxu+mZzKgZc2N0pcYG8rWjm5aocxmwVIf+sNSOpZvfFe6NKiSo1bqQzMTIPNXhMT Xh2LuxH3 J5broURSq8LKr1iHO8DWkVmGToHgFPjyx+Qv4ml5Y0eIay3oo1Mw/Yz5Byz81RngJUkI0Un6UPsdEm4p/0LBdFaLBy1Wr4eXujcmN0DbLne1gNs6+kKtB6c/0Dp3cC+vzaGWsR5VpdVhftzIffWG59ctSoXw5ErFXGMvh+FHEbz5f5uPbnYAomCJO6S0gPkxfpmOPKncVhbylZ9Bx7d3lgMrUUJfP5QECZw7/i5S3tTyzxvo= 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: List-Subscribe: List-Unsubscribe: damon/sysfs.c contains code for handling of online DAMON parameters update edge cases. It is no more necessary since damon_commit_ctx() takes care of the cases. Remove the unnecessary code. Signed-off-by: SeongJae Park --- mm/damon/sysfs-test.h | 2 +- mm/damon/sysfs.c | 60 ++----------------------------------------- 2 files changed, 3 insertions(+), 59 deletions(-) diff --git a/mm/damon/sysfs-test.h b/mm/damon/sysfs-test.h index 73bdce2452c1..43a15156a7c3 100644 --- a/mm/damon/sysfs-test.h +++ b/mm/damon/sysfs-test.h @@ -62,7 +62,7 @@ static void damon_sysfs_test_set_targets(struct kunit *test) sysfs_target->pid = __damon_sysfs_test_get_any_pid( sysfs_target->pid + 1, 200); damon_sysfs_set_targets(ctx, sysfs_targets); - KUNIT_EXPECT_EQ(test, 1u, nr_damon_targets(ctx)); + KUNIT_EXPECT_EQ(test, 2u, nr_damon_targets(ctx)); damon_destroy_ctx(ctx); kfree(sysfs_targets->targets_arr); diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 0f9fe18beb40..c729222797b8 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1162,72 +1162,16 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target, return err; } -static int damon_sysfs_update_target_pid(struct damon_target *target, int pid) -{ - struct pid *pid_new; - - pid_new = find_get_pid(pid); - if (!pid_new) - return -EINVAL; - - if (pid_new == target->pid) { - put_pid(pid_new); - return 0; - } - - put_pid(target->pid); - target->pid = pid_new; - return 0; -} - -static int damon_sysfs_update_target(struct damon_target *target, - struct damon_ctx *ctx, - struct damon_sysfs_target *sys_target) -{ - int err = 0; - - if (damon_target_has_pid(ctx)) { - err = damon_sysfs_update_target_pid(target, sys_target->pid); - if (err) - return err; - } - - /* - * Do monitoring target region boundary update only if one or more - * regions are set by the user. This is for keeping current monitoring - * target results and range easier, especially for dynamic monitoring - * target regions update ops like 'vaddr'. - */ - if (sys_target->regions->nr) - err = damon_sysfs_set_regions(target, sys_target->regions); - return err; -} - static int damon_sysfs_set_targets(struct damon_ctx *ctx, struct damon_sysfs_targets *sysfs_targets) { - struct damon_target *t, *next; - int i = 0, err; + int i, err; /* Multiple physical address space monitoring targets makes no sense */ if (ctx->ops.id == DAMON_OPS_PADDR && sysfs_targets->nr > 1) return -EINVAL; - damon_for_each_target_safe(t, next, ctx) { - if (i < sysfs_targets->nr) { - err = damon_sysfs_update_target(t, ctx, - sysfs_targets->targets_arr[i]); - if (err) - return err; - } else { - if (damon_target_has_pid(ctx)) - put_pid(t->pid); - damon_destroy_target(t); - } - i++; - } - - for (; i < sysfs_targets->nr; i++) { + for (i = 0; i < sysfs_targets->nr; i++) { struct damon_sysfs_target *st = sysfs_targets->targets_arr[i]; err = damon_sysfs_add_target(st, ctx); From patchwork Tue Jun 18 18:18:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702818 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 C132CC2BA18 for ; Tue, 18 Jun 2024 18:18:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C22908D0048; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7B268D004B; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 400BF8D004A; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AE0388D003B for ; Tue, 18 Jun 2024 14:18:23 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5EC78A2C40 for ; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) X-FDA: 82244819286.28.7E26318 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id B50F2A0006 for ; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PjoSmauB; spf=pass (imf25.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734696; 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=zwB8ozK7Br0e5BeIoJR/HX7vYM26VYq+1rAfUEsbWJQ=; b=21qBgwS3mkkUVaH3pKrz37iapLmwJbubOzn9wOjIynuRPfXs+vo9KbkoYx7hfczK6pNQnh XekasVtMvBOoQ15nb6kIcNCqerHp2pRz5MQL3R32Ez8d1qgdU/EsKcsaMZPCCUnqtrceuR Ar+in4nfKa06HdxFK69ktJ+Bi88hDuc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PjoSmauB; spf=pass (imf25.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734696; a=rsa-sha256; cv=none; b=7ry39zQO5+MjkCH3PQdx55cpEgc/hL1S6fJMRfd+wXX5LLXNo3t7B3yS62SgypvTegkuo8 ojbflEWvG4H2M/S6tfv57Vi/s+g3Ke33G1a/DYr6NreHDrD/VnP3f/SB3EwUL9JEm8E84s Vi4Nfdhy0I0sgx6IivZWqmSOeCaPagU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9532F619EC; Tue, 18 Jun 2024 18:18:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07F2AC4AF53; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734700; bh=EJciIpJkn54LApe2WvU8Qvem30aT3O4bHfII25VjoqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjoSmauBnyzwWhhnbMqKVxNzt+ZsloVpP7l+vWj1e6DIaRfGZ3ecZyu3aYIrRHwYq gkYh0jfvuo91oJYjeFefoLFGuNHTWx/VQfwOUDYtq+WQfSeG4aHju3NPphSufmZDyM VWIyveow4XQMugCPdEuTG2g0AH3Tr4mbFNjFRDVLRLCqG4QoINhx0aID0+Fk7iua0e 0AkN3SLPSEwlx0oOoCZfq2l6hTpiZfVxH9zikTxB4s43cawJzfrIIf5NleDNwmsobB jwsAooNpgTPmqUC3y0o4YPvlJZ4SG6JvAfZiFK0AhcaQDvsd4HaeqkFXdWHxr4yTwL ze7fOUTGtpCXA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/12] mm/damon/sysfs: rename damon_sysfs_set_targets() to ...add_targets() Date: Tue, 18 Jun 2024 11:18:03 -0700 Message-Id: <20240618181809.82078-7-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ytg7kujqgqe9omwpqanwx3wmg8mpwhwk X-Rspam-User: X-Rspamd-Queue-Id: B50F2A0006 X-Rspamd-Server: rspam02 X-HE-Tag: 1718734701-845052 X-HE-Meta: U2FsdGVkX18WfLF76t6k1JcEfaYltCWLZDnLe7r1akAUuKDiIhx9IL9nOGir2lSIDrhO6npLlBwTTAOUOxsoPivdIFNoya49uUe/lhapvZ7vKBkUYG8OoK/GuB4dp/rwaiwDcdzvmQ9C4WnzyxEcLc2dmszx+PC8S4O1+hslukrC6an/k+Lvo5MqQpGnqGFRiW81wFY0l2LE61H6QgbySvR6RFSu7dVxPj+Dv1Q2TuxOiaF7bF2FjMxqov4JzlGeWHQb8H2xMLL9SH/FzCfZitCIoa9x4Bvd/R7IHUXhW27IvyMP90WJUKxRReqyrqAOQPThnaUMG+MkYMrATXlFP4nVjbpwgvmx8lWnCpPRSVqPXTezSt03KfexUPHcQuBWMu6gEcW4Gen+WHU72uUj3uICVVewq2gOWLBvys0oPaJvXEymN+C7k6XJaBbnSP/FDMK0bZycFppWqOBckQrtjKV+FaWuT0U4nRHOa/TVk2nqmPlL+QM8YzvMBNXM4heYW5DKWc76O4E8p2gIZ0BQunt9CvIGa1iNTPBRoS2cEdLGF4ykHAZSCYC3CJ1p5dtEYH4K1hA3NnvGbclq/1WvCy2Zbq/bEPUvGBAsOFZzZd0pjKwvZH9I8bNrThKxPqEl+me5K4ZSyMdNI6ZmM+cSy5fduvr/tN7a683FNTTu9D6V2kkkM1XRkzxMs0sDh3/a/8YWb4OCosdV8D0vtmOhBJfN0gJelueFy/Gha5FKHGMd13LtfEtPThABVaxBASeBohm/RujlWVDi9EStKNuP9AJwAJ/HAVgN1P1ePJSR+M7LPTxQEoz6IkckOv94huEwi0zk+h1PQ6CR4f2wAc/omRZUcf5MT0B+5yz+9BPDWwCavaZNkG/zS9elUKFVEnSvVx5f1sJTeeNSjZjKLszGx+RQrLkszLd0flkxcHhbFfnoAvj1ijIvAGjSavB2MrwLwPC65xUj0BzJMigOKK/ l0eFZrZl 17bwDnIIKTebdey/2n1UTx4au9P3Q7xk5bsX41JWAWN7u1sFXxkwRultq6cJUJoR4tlehi01mwLzmaTk+Uxmm+65SYe1jXh54yYfAhF4uW4pIwKLTav6cmq284ie+FCAAlpBwvLJqAFi4CEsXB30bcJ0/Jbpm5rlE8t3tP5F9C265Sshhpi1qRWThqSkzoBiELtUBX44mX3cjaGolmK4MTAc5QVzWtwrmxBQmBnfIscu8mVXlTPrAAnLKRucXVFgW0qBy4ArPZhYCG2fPRG/RY3LHqw== 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: List-Subscribe: List-Unsubscribe: The function was for updating DAMON structs that may or may not be partially populated. Hence it was not for only adding items, but also removing unnecessary items and updating items in-place. A previous commit has changed the function to assume the structs are not partially populated, and do only adding items. Make the function name better explain the behavior. Signed-off-by: SeongJae Park --- mm/damon/sysfs-test.h | 8 ++++---- mm/damon/sysfs.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/damon/sysfs-test.h b/mm/damon/sysfs-test.h index 43a15156a7c3..1c9b596057a7 100644 --- a/mm/damon/sysfs-test.h +++ b/mm/damon/sysfs-test.h @@ -38,7 +38,7 @@ static int __damon_sysfs_test_get_any_pid(int min, int max) return -1; } -static void damon_sysfs_test_set_targets(struct kunit *test) +static void damon_sysfs_test_add_targets(struct kunit *test) { struct damon_sysfs_targets *sysfs_targets; struct damon_sysfs_target *sysfs_target; @@ -56,12 +56,12 @@ static void damon_sysfs_test_set_targets(struct kunit *test) ctx = damon_new_ctx(); - damon_sysfs_set_targets(ctx, sysfs_targets); + damon_sysfs_add_targets(ctx, sysfs_targets); KUNIT_EXPECT_EQ(test, 1u, nr_damon_targets(ctx)); sysfs_target->pid = __damon_sysfs_test_get_any_pid( sysfs_target->pid + 1, 200); - damon_sysfs_set_targets(ctx, sysfs_targets); + damon_sysfs_add_targets(ctx, sysfs_targets); KUNIT_EXPECT_EQ(test, 2u, nr_damon_targets(ctx)); damon_destroy_ctx(ctx); @@ -71,7 +71,7 @@ static void damon_sysfs_test_set_targets(struct kunit *test) } static struct kunit_case damon_sysfs_test_cases[] = { - KUNIT_CASE(damon_sysfs_test_set_targets), + KUNIT_CASE(damon_sysfs_test_add_targets), {}, }; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index c729222797b8..f83ea6a166c6 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1162,7 +1162,7 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target, return err; } -static int damon_sysfs_set_targets(struct damon_ctx *ctx, +static int damon_sysfs_add_targets(struct damon_ctx *ctx, struct damon_sysfs_targets *sysfs_targets) { int i, err; @@ -1283,7 +1283,7 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx, err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs); if (err) return err; - err = damon_sysfs_set_targets(ctx, sys_ctx->targets); + err = damon_sysfs_add_targets(ctx, sys_ctx->targets); if (err) return err; return damon_sysfs_set_schemes(ctx, sys_ctx->schemes); From patchwork Tue Jun 18 18:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702819 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 91353C2BA18 for ; Tue, 18 Jun 2024 18:18:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A4128D0036; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 032D08D004C; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76E7E8D003B; Tue, 18 Jun 2024 14:18:26 -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 5584B8D0040 for ; Tue, 18 Jun 2024 14:18:24 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE1711C18A5 for ; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) X-FDA: 82244819286.09.75A7A57 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 31E252000E for ; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fu9AAeUW; spf=pass (imf13.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734695; 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=KrirIhj6Cn9Ghf6p0hNvN8hK8cro02Zm5Tq1L8aMSBI=; b=j0i+3MP4P2m+oBvywjysvOwQTLmvd6+hIDFC53JUa/VwYhp4UZYhvKo1iV3vFTLPm8+qxK YVl9EKX1WoVMQ4zBP+zgQSEixhTXBy+ZIDmyigKXU+BHe+LXMI5K0KPNe0oclKtOxZhDE5 OyDqUafhPTAE1Qnc9hL1VU86te9oJFI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734695; a=rsa-sha256; cv=none; b=p8n2he8x2MA/+udaeJB2KRX9+fofJniv8RaJWOUn2aTkFOAF2q8eY5LVijHk3AR0CecFDa B0lSlobuymtCFQFHuenDpS3gYK4XgVFRC1KCRg0u2g7B70MUZIJIYdDLQwwCeJ8tXUaIcM 3Y6adk98CZetmV41pkwscBMhdWIMzBg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fu9AAeUW; spf=pass (imf13.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 35D3161A85; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E5D2C4AF49; Tue, 18 Jun 2024 18:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734701; bh=FhX0FlOnMgUOXgLd59wQh9U7osp32SgwH12eXj0ho8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fu9AAeUWwTeRvtt2JM6jMIciTRKYP/+kxem/o9sGjge4tI6cDVL9JuDRmdkXWUjvO FE0m4jQ759sVN2rvKx3+TwR/0pBlT1i0cBvmuOsDRkaBljXk5rK6aORrGPyH/jRBwu w+tD6OmLtv0CxJZcBJEI8q23Hh0DzzfsAWJbYxHNGvdGD4cR/8fqCgVi18TGcmO7lM p7Cj3vOwXsVrCzzwVZ3ClXe840/Iw6Od1CEYAvLM3iO4n4hfaLUu2saw/99s43fa6K bQYGpdBDRJgSRCZZ4eW3VO1v6IlDmMlVhhUQwpkyuD1WEhld44789a3JPdjxezvpjL tiLJAL/I+k2wQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/12] mm/damon/sysfs-schemes: remove unnecessary online tuning handling code Date: Tue, 18 Jun 2024 11:18:04 -0700 Message-Id: <20240618181809.82078-8-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 31E252000E X-Stat-Signature: pnyrfua155kaigdgti8sqs45ofqi9a8k X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718734702-130364 X-HE-Meta: U2FsdGVkX1856xCzJS4rrr8gTjdmkZlwG/eWuXaUPkNn04w1iFs1xOt5F5hLSU+sVpQUrHsNSTl963AJN2JKpd1HCoAIZdGVTnwfWY+aH8J1luvXkEyrdQcK2FLUV9zjZzicHgIw6bCouC3CMR7z1tqmR+dP6vLmq983f7mnu6khQXVqDbG1vrK4Q65Ve/6Djt2bOLhVv/GueQ7RuvbnufUdGUt+vWQ7Tp4rtdxVGwwChLC+t+hHdwO4Or/qoMMSlc4U+zaW2fbLAk6hPw9+UCTvMdPeCNw7Ug7LXP1jF0bK9/l+W9WF7+kJVjQNRHx8w32WN557XkGESqkBPC4Oiw8L3DNPAQRI3neQh3fAZDhHTFY0VkoH8PWidSlvkUkeoYAixHTBMv0zlYtiWp8OqJKWhJPm8kUgZwLGmppzlKEIihR2uBWa55HXqqtesPBRproAvXO0+bESz7Ses+fk9IQRDrwNuiOucG/BkdVLIASv4SkLCC2rvrhBOjahSMTpdVM/H/vaoV3HWmgpIudDODvVnK8JPoGZcd0TympmsNshNSigvVbmQ8oj0f69pqTg+gzRes1095fd1hkgYKIevAaLppIF+LLhvr6tKnIzA8Cb0XvFvSP3vaQIuFdwrLOs7c3TVZghF5BSPTVh9zXbDVuhn+MRnK//9P+QTZph7sUheU9wV09BRFvRahqxwDKrh/3P9mB/a2ycsiFUFSLJPuBlxn4x/TkGDvEeRGuUHeV7CmrqKksrPaqk6oetyrttSTnGWR1rzgx3Q9X35k5UBReDLnJflKpTgwVc4uIXArIojHQfHeQCuKq5aZTxAm5x06u/36zFpApBZF0JKuHIFIg8AcC30Mh0jnJsPnBJmyY0f82DlCSpU868c8dYOITzIKuN3rKe0O8Qa5KW6SfXhDExAxGs5pXg6JXfrD8k+kd7kaLWnHTKB4Q9exOBo2daiKbFI12Hx1EIfeHpDA/ 0LgFqogN 3DdW/qb/Dwa+XDewrCQXZKrPNC2lncyhATzyTBEBZgq2eSxxhZx98BEridNe8cIaj6Aa5Ue1UJicbf3QIbbn9aWe6uKjjRRvZfYoRlR0CDypuTYklnC45y9Q0UTka32+Mbee8M60iyG7lAD59rEOuOLTRfCjY0UskeEhHVwl4ldAv/Eg4dDLTIbqV422gQkjA8/r3xXRqdxKvKu+fBgXs1xO7J0pe0iBzQuKUMJGVTLf6mWxG5xJiG6RbSfz6buqM56ICfwmyUmPRHgU= 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: List-Subscribe: List-Unsubscribe: damon/sysfs-schemes.c contains code for handling of online DAMON parameters update edge cases. The logics are no more necessary since damon_commit_ctx() and damon_commit_quota_goals() takes care of the cases. Remove the unnecessary code. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 68 ++-------------------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 1bccf2619e11..77c0265dff5c 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1912,10 +1912,6 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, struct damon_sysfs_scheme_filters *sysfs_filters) { int i; - struct damos_filter *filter, *next; - - damos_for_each_filter_safe(filter, next, scheme) - damos_destroy_filter(filter); for (i = 0; i < sysfs_filters->nr; i++) { struct damon_sysfs_scheme_filter *sysfs_filter = @@ -1955,12 +1951,9 @@ static int damos_sysfs_set_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) { - struct damos_quota_goal *goal, *next; + struct damos_quota_goal *goal; int i; - damos_for_each_quota_goal_safe(goal, next, quota) - damos_destroy_quota_goal(goal); - for (i = 0; i < sysfs_goals->nr; i++) { struct damos_sysfs_quota_goal *sysfs_goal = sysfs_goals->goals_arr[i]; @@ -2091,67 +2084,12 @@ static struct damos *damon_sysfs_mk_scheme( return scheme; } -static void damon_sysfs_update_scheme(struct damos *scheme, - struct damon_sysfs_scheme *sysfs_scheme) -{ - struct damon_sysfs_access_pattern *access_pattern = - sysfs_scheme->access_pattern; - struct damon_sysfs_quotas *sysfs_quotas = sysfs_scheme->quotas; - struct damon_sysfs_weights *sysfs_weights = sysfs_quotas->weights; - struct damon_sysfs_watermarks *sysfs_wmarks = sysfs_scheme->watermarks; - int err; - - scheme->pattern.min_sz_region = access_pattern->sz->min; - scheme->pattern.max_sz_region = access_pattern->sz->max; - scheme->pattern.min_nr_accesses = access_pattern->nr_accesses->min; - scheme->pattern.max_nr_accesses = access_pattern->nr_accesses->max; - scheme->pattern.min_age_region = access_pattern->age->min; - scheme->pattern.max_age_region = access_pattern->age->max; - - scheme->action = sysfs_scheme->action; - scheme->apply_interval_us = sysfs_scheme->apply_interval_us; - scheme->target_nid = sysfs_scheme->target_nid; - - scheme->quota.ms = sysfs_quotas->ms; - scheme->quota.sz = sysfs_quotas->sz; - scheme->quota.reset_interval = sysfs_quotas->reset_interval_ms; - scheme->quota.weight_sz = sysfs_weights->sz; - scheme->quota.weight_nr_accesses = sysfs_weights->nr_accesses; - scheme->quota.weight_age = sysfs_weights->age; - - err = damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); - if (err) { - damon_destroy_scheme(scheme); - return; - } - - scheme->wmarks.metric = sysfs_wmarks->metric; - scheme->wmarks.interval = sysfs_wmarks->interval_us; - scheme->wmarks.high = sysfs_wmarks->high; - scheme->wmarks.mid = sysfs_wmarks->mid; - scheme->wmarks.low = sysfs_wmarks->low; - - err = damon_sysfs_set_scheme_filters(scheme, sysfs_scheme->filters); - if (err) - damon_destroy_scheme(scheme); -} - int damon_sysfs_set_schemes(struct damon_ctx *ctx, struct damon_sysfs_schemes *sysfs_schemes) { - struct damos *scheme, *next; - int i = 0; - - damon_for_each_scheme_safe(scheme, next, ctx) { - if (i < sysfs_schemes->nr) - damon_sysfs_update_scheme(scheme, - sysfs_schemes->schemes_arr[i]); - else - damon_destroy_scheme(scheme); - i++; - } + int i; - for (; i < sysfs_schemes->nr; i++) { + for (i = 0; i < sysfs_schemes->nr; i++) { struct damos *scheme, *next; scheme = damon_sysfs_mk_scheme(sysfs_schemes->schemes_arr[i]); From patchwork Tue Jun 18 18:18:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702816 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 5717AC2BA18 for ; Tue, 18 Jun 2024 18:18:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 505248D0038; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3994D8D0041; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F091B8D0038; Tue, 18 Jun 2024 14:18:25 -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 C96108D0041 for ; Tue, 18 Jun 2024 14:18:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 71C84A0A25 for ; Tue, 18 Jun 2024 18:18:24 +0000 (UTC) X-FDA: 82244819328.08.AFBE9AB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id C1966140007 for ; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W1QOFYNZ; spf=pass (imf26.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734698; a=rsa-sha256; cv=none; b=CA1mhdi2sH4PQ++KVRMMH2GD8/CqngVKqC4LZa+30hFmywxQhxs88akckurtRI9ERxHctI VvYF7anHel1utsIoNos/o/03SBHNE25L8EbYFApMPNA32dW8/ztfGXKhjxsPlWC98efoQ7 Lz/YAv8NESj6PyY0SItKY4F+v/TkqQw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W1QOFYNZ; spf=pass (imf26.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734698; 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=49qqnHY5at1odpCoizFkFonS4qGLfbMj/uWQv2oCroQ=; b=yDJnNWVr88RHCPpypeUJCdGce2SoBIPSJFnHomAff0kXb0RhvFvsyyuXaxVcwvbsa4WLjP V6mds+iZYFO1qUTf6DyOjP6rrh9fN8MgvL+J4z01z0LJMOwBYmdbUETma0R7m2u9rhU9Q3 8iCk4bMrK86sEhQbhzO3ZBoULQZ0nvA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CE90261A56; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FE3AC4AF50; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734701; bh=IvB9TY1BgcO/wE27+FMWRz+Cg1k/Z3ehFmcdbgTDhfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1QOFYNZF8ejie0JzdmDiZs20qHP66bCShDkYs6kYuVfrgDXUx9RkIj2Vt689X0LL c5KGgHMaapOGrTmPZhmOjpu8mx7gR52gC1q2recUO41eCxmBKIcfIeDZhDC4F8wCDn pN5fhMg6QIdP2qketSZnuOJTmskmL1wvNkfaf8yOPiho89o7HCynwTtt0CyWbCWBVX uQ7NKuHV2FAqbxJsZ2v3dXdP5gNb0olBAmSaoys1f0Xr4P7Q9+dq1Ds0fNGgiav396 kTXFgqE4YzjkhgibHfbI2pv9Ia1icBbKh7YPt3PQBF9BLsTaVIlNJr3GF0FI8U9fCv 3jMgt+CtpQJAA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/12] mm/damon/sysfs-schemes: rename *_set_{schemes,scheme_filters,quota_score,schemes}() Date: Tue, 18 Jun 2024 11:18:05 -0700 Message-Id: <20240618181809.82078-9-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: qfgnoqji4payia6hkghoxsarbcawwkyu X-Rspamd-Queue-Id: C1966140007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718734702-685025 X-HE-Meta: U2FsdGVkX1+Hm3uKamU7VZmVgSRgpWlH1K9ICpDkBhgSXbwO6zGXljiJegnmtTJD8gcIK/xR1oOPH+wv7/uDVL184jIIpoGRQ0Bon9ysRkOkNt216H5E2PLMeEctP9ctABHmgnobT21DL6F6K/cMbqqj4tbW+aAqphC7o00FA4W1Zd2vu+tagwiL+0eJzhAUPcgk0CrFmknAikioU8VKcjS0QZAWMLgQ1xy7p/bBOgZejz0AAzGPc8X6kDF+Pds7mfI0ybXpKH0fq0ipMNBx912ZW9kIfLvdJUWKubkFls8d2/YjQkGmA13a0Kz6S8PLrugo2ZV1xg5cpUBrZmShdi4W0US1tZLUXD+DAnn5IJG6k7QiVvUV0b2TzDjfQ00Zyx5GyQcHaLJEMnAH/EYonc8BKf7J83z7Xfvx9jydp1A3pifBpv3LJ+ST9x6VYHUh8xWUXQK+BTxaXpQrg3CMjplCb6z7NvVeDwJh/VL77J06WS+US8Eu2nKsEIT1PFiXQyxTlXZo6yaz1BwJRe/uWjoNhGyn+qO/TpN+DMzGDo96KxwVvX1TfakWmRaeixWpDhT3g/kqqZoe5e4pvcETnCujU4V3Po4718pHI+BV5JzMLzyqhXq/6kBhFlfxtxOvXeng0qOj04bp5aiMyoG5ivXHobxL1yttut+PZ3Pounayoj0JIFy5jMeBy2wNVEOKqyQoA1Yujxgz5CsJdqsDvB6v9UdPL9eRjWiC1Zy28aMntzwyzmMyNNfsdtTBCaURcgUX8jsZh+Tv0MQ/wX3N6RlUGOKj9w/wWdmG8tRU+HGB9koGerS4Mp4o1mev2n35IXvCf5csQVh4GsDUw9zWGabvbhEshZKu7JChX8hYhGSCOjcnWZ1AqbW0Ze0mKe7wzsrCi0xH22Km2ocSu3e7vR9kEBa0QHEimC36oXE7aRNApLAsgGwT8x9AE+kG5wCuzDYMb0SLtpepwT3juBv E596E55J VmpNkxi0/PzmjxV49ziSKUSYghLWMEdZ6PneeYjfmqnEN1H6cpwi7KuxdsasLfScZGFZsdTF1rnTuBT1gpysGmX6RJEXKFr9Wze+E5ZEMXYyVopgSQDwa2bWymGVkC37Mo5jzbNvUwwWicVDYpwM4ZxM32P8jUCeYFSrDH4YnI/DdYrnrWDWSvv/I9HUF0xpgLvoyuTu/bL51qXtHyUCrWUVeiawM+Nl5oc9hIbiM6b0jkgX9h9g2papniyl9UM/PPNJQgbevuPElt8EwsxEoEte0Iw== 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: List-Subscribe: List-Unsubscribe: The functions were for updating DAMON structs that may or may not be partially populated. Hence it was not for only adding items, but also removing unnecessary items and updating items in-place. A previous commit has changed the functions to assume the structs are not partially populated, and do only adding items. Make the names better explain the behavior. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 2 +- mm/damon/sysfs-schemes.c | 12 ++++++------ mm/damon/sysfs.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index a63f51577cff..9a18f3c535d3 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -38,7 +38,7 @@ void damon_sysfs_schemes_rm_dirs(struct damon_sysfs_schemes *schemes); extern const struct kobj_type damon_sysfs_schemes_ktype; -int damon_sysfs_set_schemes(struct damon_ctx *ctx, +int damon_sysfs_add_schemes(struct damon_ctx *ctx, struct damon_sysfs_schemes *sysfs_schemes); void damon_sysfs_schemes_update_stats( diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 77c0265dff5c..b095457380b5 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1908,7 +1908,7 @@ static int damon_sysfs_memcg_path_to_id(char *memcg_path, unsigned short *id) return found ? 0 : -EINVAL; } -static int damon_sysfs_set_scheme_filters(struct damos *scheme, +static int damon_sysfs_add_scheme_filters(struct damos *scheme, struct damon_sysfs_scheme_filters *sysfs_filters) { int i; @@ -1947,7 +1947,7 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, return 0; } -static int damos_sysfs_set_quota_score( +static int damos_sysfs_add_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) { @@ -1990,7 +1990,7 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, break; sysfs_scheme = sysfs_schemes->schemes_arr[i]; - err = damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, + err = damos_sysfs_add_quota_score(sysfs_scheme->quotas->goals, "a); if (err) { damos_for_each_quota_goal_safe(g, g_next, "a) @@ -2070,13 +2070,13 @@ static struct damos *damon_sysfs_mk_scheme( if (!scheme) return NULL; - err = damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + err = damos_sysfs_add_quota_score(sysfs_quotas->goals, &scheme->quota); if (err) { damon_destroy_scheme(scheme); return NULL; } - err = damon_sysfs_set_scheme_filters(scheme, sysfs_filters); + err = damon_sysfs_add_scheme_filters(scheme, sysfs_filters); if (err) { damon_destroy_scheme(scheme); return NULL; @@ -2084,7 +2084,7 @@ static struct damos *damon_sysfs_mk_scheme( return scheme; } -int damon_sysfs_set_schemes(struct damon_ctx *ctx, +int damon_sysfs_add_schemes(struct damon_ctx *ctx, struct damon_sysfs_schemes *sysfs_schemes) { int i; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index f83ea6a166c6..cffc755e7775 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1286,7 +1286,7 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx, err = damon_sysfs_add_targets(ctx, sys_ctx->targets); if (err) return err; - return damon_sysfs_set_schemes(ctx, sys_ctx->schemes); + return damon_sysfs_add_schemes(ctx, sys_ctx->schemes); } static struct damon_ctx *damon_sysfs_build_ctx( From patchwork Tue Jun 18 18:18:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702820 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 341E4C27C4F for ; Tue, 18 Jun 2024 18:18:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 455328D0041; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 340B18D004B; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB8348D0047; Tue, 18 Jun 2024 14:18:26 -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 28E918D0048 for ; Tue, 18 Jun 2024 14:18:25 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D700D1C18A5 for ; Tue, 18 Jun 2024 18:18:24 +0000 (UTC) X-FDA: 82244819328.14.90D67E1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 39E6340006 for ; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oLvial6x; spf=pass (imf12.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734699; a=rsa-sha256; cv=none; b=JOx+FV5Tuz0mFbwx9Q59dbAdBNzCpMISkvLGxo4HRw67OVzrRnJ2SHTk+X6nvlYpgv5oUg lZ50mM8VqKaDOE7TrvpjvI90xy+8af65I1/K/0JctTq2Axar+39bZZ2OyOfV6kBpssCPjs w4itvOxD0u5EGIj6Sij5lUgtSC1Gddg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oLvial6x; spf=pass (imf12.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734699; 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=d/fy2pb/SFqipGPwahp+UCBk+ms2s5ekqyb5MmQ5bK0=; b=sHdUIebs7H/HK44Jb74tHzZuc/jnXR8BK0lFVg731CfAoO76sy9ZDWqGhMG0MqzZkqkL0Q 5DezkKomBaK9iS/gfPxh+0mVLDePj2JJ3aVOGpPuJYq2jLmn79G4orCxGRXlt8pyMcQRH+ lVXDvbB23Uv7b34QeF2IUXWY86N8lt4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6F08261B27; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D6DC4AF49; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734702; bh=63ugfgzmyX4NmFqGz3i2C7qMQZ/sIyT4hK0C23YIhHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oLvial6xmmuQ0yPDZAWQraZaKb6LAp115Mm79wORwQmYVnNAOzFEko+KxgpbPJLkz MRYok8GqL9vvB+Xng+vOPk6x2Ke23b0oGTXyeQGQo8z1inXgPxk4fopGgnRjedXhZy Eqrd1/iiBBe8JnYfDTnDFaiiUHu98i6oWKGJpphMMCb2CQJbEYesD+bDmm5pfzkviY 1KZ8YT+nbf6AUahFRFTMWuenMt9RgUl8U+0ZAhSKipyrrpCZoOyO8V25BsNViSxrCe XKrsvzOBk9oEyDrM0MCHujO98I7Z0YxrtalloMZJBeENxgdIECdr4zIzpyBHS4z3gP fY0Sy3b+SnQUQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/12] mm/damon/reclaim: use damon_commit_ctx() Date: Tue, 18 Jun 2024 11:18:06 -0700 Message-Id: <20240618181809.82078-10-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: s45zuohgdj7w1c3jafnhh9n46t584emf X-Rspamd-Queue-Id: 39E6340006 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718734703-454222 X-HE-Meta: U2FsdGVkX1+F0n4OxG/TrYsSasVOtMcu7Qr42gEl0BJov59FYPqtfXxCH3S3raXcWK3XTidF+cDAodHX65hwfJidURM+UdhL3Nxy3sS7aX+7PDZvUpjAFHkEPdC2z4Z3TUP6KjTgU3oGy+MZULwRK23O1yi/ujn2UbOsN5RaxBlaTYvZusLla7kYDY0u2GATf8Ww2wc2/5bNKVsbLQ2KqHUIqPLH4+/G91LdBw1NUiR9bw7++MFOOuregYMOkbGssGyW8hr8mNfFBsmiklA/R1RCA4NQsuhQsOC0RYQ8cAbEQe3ZunJyeKeCPH4zhmV4tycQru5y8emYmMPXIku9wiZRT51OAIJEK/3LV4Zy0oayhuczqhqsgBN0i+jiLP/+kxWhICOSP8olVqFcjy05zZJG/O2/vhojvAnLoCn1azBFioIrcMA44MF6Dlvem9M+foh3M1YOcpH8KqX7FPNbwUaNXGiqpim4CIyVtZ8QN3sR5RafBnO1YEN2oCXJK3JR+QGOx5r0ffnA/BDiNQQH27V3OT4tHkqUPB9vqYvy9g5RMS7gSSbROdJqzcaQKo5xLwKwdzYz1+UtV9eO6TFTDNUfDkSFr1Sc5jRxk4w1TbR87dktz68e4DjJDPCzazYzsufOt7U7aSqwdec2tViVB2kq42j3/RybOdlpKd9g9GCzoMy/eP/71ZpHhIPaGUXnZpVQbAyCa7bNj1k5Tp0LjGtcTGEtRs7BxgMJLtcv7Y2fkEjDuSCt8a2afJ+kTDEyxm7B2s8XZQf+LRzxaUOUwdmSpGKm7lTUgT1yCxi3lvEpJBLFqaHk8aVGeNvcxvfZW1ICQkI3USmniz5AIgdVJAp21KJPltl+zSx2crERiLUEIj1kWMFwaCS3F68xjcCaLwQ/VW/8T+V3pH9RnQKLJhEWkVJJfIrxKUXHHlDHABY0AkdvNJ/mF5o5MJ+u7PBHuneRwkjXgTyARxUCvJs pxNvnU/V RZvtk6/XFRmYl3EWPHhQIe1PGmiI3Rys/QE0iIM0ApJMlzs4NP7xgTWxbm4m6QsRlFpWi6Hh7B2s3CqamR5Akx+2sb9TofZKtEvL0k3NSLm/qpSZTT3EgRzdJcRoF+5Xr01mJ85WfQfvVZNqo0MjUpiGOPmk/MROKFdqHahINYmJyFXH84GdhhWkmAm77Mcy+rGfrvsrUsR2WpELxYpEx5J4hchWVWrxN3WcTNtIABuQZDUKMWIVONwavnwqAuXKGxqo/3aXefzWyZiw3fAoclEW0cYRPMQaWaA7u 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: List-Subscribe: List-Unsubscribe: DAMON_RECLAIM manually manipulates the DAMON context struct for online parameters update. Since the struct contains not only input parameters but also internal status and operation results, it is not that simple. Indeed, we found and fixed a few bugs in the code. Now DAMON core layer provides a function for the usage, namely damon_commit_ctx(). Replace the manual manipulation logic with the function. The core layer function could have its own bugs, but this change removes a source of bugs. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index a05ccb41749b..be7f04b00d0c 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -195,59 +195,64 @@ static void damon_reclaim_copy_quota_status(struct damos_quota *dst, static int damon_reclaim_apply_parameters(void) { + struct damon_ctx *param_ctx; + struct damon_target *param_target; struct damos *scheme, *old_scheme; struct damos_quota_goal *goal; struct damos_filter *filter; - int err = 0; + int err; - err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); + err = damon_modules_new_paddr_ctx_target(¶m_ctx, ¶m_target); if (err) return err; - /* Will be freed by next 'damon_set_schemes()' below */ + err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); + if (err) + goto out; + + err = -ENOMEM; scheme = damon_reclaim_new_scheme(); if (!scheme) - return -ENOMEM; + goto out; if (!list_empty(&ctx->schemes)) { damon_for_each_scheme(old_scheme, ctx) damon_reclaim_copy_quota_status(&scheme->quota, &old_scheme->quota); } + damon_set_schemes(ctx, &scheme, 1); if (quota_mem_pressure_us) { goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US, quota_mem_pressure_us); - if (!goal) { - damon_destroy_scheme(scheme); - return -ENOMEM; - } + if (!goal) + goto out; damos_add_quota_goal(&scheme->quota, goal); } if (quota_autotune_feedback) { goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); - if (!goal) { - damon_destroy_scheme(scheme); - return -ENOMEM; - } + if (!goal) + goto out; goal->current_value = quota_autotune_feedback; damos_add_quota_goal(&scheme->quota, goal); } if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); - if (!filter) { - /* Will be freed by next 'damon_set_schemes()' below */ - damon_destroy_scheme(scheme); - return -ENOMEM; - } + if (!filter) + goto out; damos_add_filter(scheme, filter); } - damon_set_schemes(ctx, &scheme, 1); - return damon_set_region_biggest_system_ram_default(target, + err = damon_set_region_biggest_system_ram_default(param_target, &monitor_region_start, &monitor_region_end); + if (err) + goto out; + err = damon_commit_ctx(ctx, param_ctx); +out: + damon_destroy_ctx(param_ctx); + return err; } static int damon_reclaim_turn(bool on) From patchwork Tue Jun 18 18:18:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702823 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 183D7C27C4F for ; Tue, 18 Jun 2024 18:18:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 232458D004B; Tue, 18 Jun 2024 14:18:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F6C18D004A; Tue, 18 Jun 2024 14:18:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6ABF8D004B; Tue, 18 Jun 2024 14:18:29 -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 8F01C8D004A for ; Tue, 18 Jun 2024 14:18:29 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 320FC1C18BD for ; Tue, 18 Jun 2024 18:18:29 +0000 (UTC) X-FDA: 82244819538.02.95F6613 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 1D32440019 for ; Tue, 18 Jun 2024 18:18:26 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Bv3wHdx6; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1718734704; 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=XMEwUC7FSP1SVRLTt1QIAO9000rnCRGabII8POKTyA4=; b=OB3AiiUwICqB2d5yX9B1FVMO+HtdYIv1soZU+O4HH5RV/ViiOY8Snd2c20LYxpvc7iZvYf gFbyFZVWE1tshwBWks53opUHwN4Gd7N9EeLXpBvz9nAA7QQohJgbeO+IqJ/6NrxzmXeCNp hbaEh4A+7x9bf/sHLaxzovsLOlagUKw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Bv3wHdx6; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734704; a=rsa-sha256; cv=none; b=5PYxEgt7vuLuVSd9tdq3qdRDC0/zTRKMaec7CUQeiL4agiC5K6ZwcMNPShJJczRB5PJYLy rjUqYKRTppwgnJ9mJadDxmfVj1FONzwjcX+rRPFJJ17uZORTzKXRtXf1tkkdeE3x3jH0+3 mpfUa3ZU700W/zXLUTVEyJo0HDra5Oo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id D50E7CE1C0E; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C6BC3277B; Tue, 18 Jun 2024 18:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734702; bh=50hBEP6CpX4UJy/Ydz/ykmHUVQkUp5qb7XdctlMxkUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bv3wHdx62BoXicPFD3PtWCmzu1QMbhv2f1y/yA6WIoKpljpHHt1SpeWSMp51QlqTh YRo9i5ZHlHsb8/rM5jZWPOZOJAdHlCUnI1ovNiJZyXBbcQCjvaa2bb40wetatKs/TA aw0ojXny1SKlwjKjhYhpd+0a5Hy6JFL5XOvQSKDN8mQ8Z5AiScjUsee6GCQXhbbpwD 8wT93MtFD7eBrhaeQvmcT7N1wSk+tll4x3u2s2Ku/osq8eZJffSqBJIkRbD9KyVIN2 yyYiJz4eJf2pWOUnSxMJ4EN7n2p7g9D2jtcyniabVB9N7eF3++GExlXmeU3iXTtaCZ 5BQVwFeCDY2Eg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/12] mm/damon/reclaim: remove unnecessary code for online tuning Date: Tue, 18 Jun 2024 11:18:07 -0700 Message-Id: <20240618181809.82078-11-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1D32440019 X-Stat-Signature: 3x3dyjkmrb91ptbd4sr5hbheer1ymhhh X-HE-Tag: 1718734706-358205 X-HE-Meta: U2FsdGVkX1/7hD4hGRTnbh2ckxI+b5gQSVwn0EPSqdDLmO4MaMIyQFVyqair0iMaipJYzOjU90XYIG24xrpX7yI8bbJTflheACTD/A1Gad72YhsBIeH7Rt5PD6TUmDnNmNlaN0sgfoVzQKKO3yJS34IPbgWFZ/BItLwI/QTyTmcH2fKOPJQB1EXcoFASeYYT3caQjoNLUEuUB5BVZNADzOUWaKjbkS2/zhComcC6TknscUbac+BOq3g/sLJ3gehRhDTWT2p8FDoj3f8q58E1PffysQDEykabek6MhfIb3JTZr4CLnPVJLr2eHb48TVnqugTMu96fkg64WSrHA2vQAdzDqxuGnAgKd2VOTgEc8qYmNBscYEzfSkKT8BphdFNHelTCBeSQNZOtZnfyLjfCPv8LFSkHt5QBTl6idLIh1B01b6sG4+W7fqTy0MnySRwK5JHo5uR63jGy/nEneuyYsV4WZYx36m3jrz14rz4pVnN3KO18IOuI2QuuHtVyU1w57lhAjqF7IS1PyRQ6RqKVOlrLxBGE4IQ+BrPbaqwb00kXf2i5N+mo3HvYvOKhuV12/o1DiTCDaIGPb/3nytOChfOUxcqLldLe5W/CeVuCdYD8VqYk9/KJGMVnopXX82QhezaM3zeD9PlBiCROEDcTI+j6lGm4P6DKPDD/azb16lKCFjZXUKKO1D8gF8j0AW2x57E1mgsKXNkHgY6sKkdi35DV5wmtA8U5o5V1AY/kfrxt6PPZTxIdfMuMMFL67hXo2aln1RpWiXGvHh4LG8jSr1o8VP6zHgiIWsUz6QNv+oF/MV4gvC8F+o7SxcglcDrLuj5N3tAziJRZfaW0jeBdEMLf3hdhKrmGvsE7ZaFTtqCSFxPevIhnj09YVW8xwCnV5twOtRfHAL5fySOvLaQL5BT4v5usZ+JpCo4Kzs0oBc8flVnLvcM3PjmAFFThX1oEjR9nbyV2j8sLuwHdL49 GiNKXSbM gCh7vBJwDwS7sCGQ6uxm6Boh855Mu66MzPimaF3/7wiXntxGEbv0IBlzV2B4oSIiaSdOGI61SNvNyKWmNvhNAWScmrrbAgv5v4opWbgNzqkqb3kaNyP/FPAVEacOSa0fjhw3mF0cT0hTtXIh7krlh6i1fvevG6qD112Etu2ed8S6J+DSb6gQcMloW8vAjcDH9ccWDgiVKFtOxtZBZjWaFtvQ2IgICJwyknNpqdiNIlcjPJn4= 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: List-Subscribe: List-Unsubscribe: DAMON_RECLAIM contains code for handling of online DAMON parameters update edge cases. It is no more necessary since damon_commit_ctx() takes care of the cases. Remove the unnecessary code. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index be7f04b00d0c..9e0077a9404e 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -181,23 +181,11 @@ static struct damos *damon_reclaim_new_scheme(void) NUMA_NO_NODE); } -static void damon_reclaim_copy_quota_status(struct damos_quota *dst, - struct damos_quota *src) -{ - dst->total_charged_sz = src->total_charged_sz; - dst->total_charged_ns = src->total_charged_ns; - dst->charged_sz = src->charged_sz; - dst->charged_from = src->charged_from; - dst->charge_target_from = src->charge_target_from; - dst->charge_addr_from = src->charge_addr_from; - dst->esz_bp = src->esz_bp; -} - static int damon_reclaim_apply_parameters(void) { struct damon_ctx *param_ctx; struct damon_target *param_target; - struct damos *scheme, *old_scheme; + struct damos *scheme; struct damos_quota_goal *goal; struct damos_filter *filter; int err; @@ -214,11 +202,6 @@ static int damon_reclaim_apply_parameters(void) scheme = damon_reclaim_new_scheme(); if (!scheme) goto out; - if (!list_empty(&ctx->schemes)) { - damon_for_each_scheme(old_scheme, ctx) - damon_reclaim_copy_quota_status(&scheme->quota, - &old_scheme->quota); - } damon_set_schemes(ctx, &scheme, 1); if (quota_mem_pressure_us) { From patchwork Tue Jun 18 18:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702821 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 26E57C27C4F for ; Tue, 18 Jun 2024 18:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 828168D003B; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64C288D0047; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E684F8D004A; Tue, 18 Jun 2024 14:18:26 -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 1288E8D0036 for ; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A4EC4160238 for ; Tue, 18 Jun 2024 18:18:25 +0000 (UTC) X-FDA: 82244819370.09.2D96A50 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 13A342000E for ; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VwfqITNf; spf=pass (imf13.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734697; 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=GSiZxeQ2+v2e+94jFet88RHrZY62PUpoMVDsQ3B3tu8=; b=g3Lyong8TCKR19AkIJYeGeJys68m+qFP1RUM7oN9pqLkNZ5G2ZwP6rR8ZgpAY6KjUFJNxd 4KjKPNhJJLl5U3wFb5Z6AROJf+XfEX6f4SR1PFqM0/7vJphKJTYLs9tjr4dZ+fUHqc9KPo ps1WBwGowutFl2tJCdUkDiCacmQ3lfI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734697; a=rsa-sha256; cv=none; b=j8yzvC99rvpDK+TARSDZ4HmdG/fcsG3m9+8MDuanlSlag/yei0iZ9sqvr6GOb0q+8CTqwD njviQw0uQrwCLgx3sKbiZt/+LqB1+gZIpytEJtRwX3fz/cG5AUSHdsVWeoPOoUr9dEf5vo p+NKOqqq/u4jqHP197S6etFAGMKgmTI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VwfqITNf; spf=pass (imf13.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AC04E60EE1; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BF79C4AF62; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734703; bh=Y0WL72ENjXuzcYBbbK9ft+KRSGtN7fHgxSV1OXgDM6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwfqITNfa3Gj1ma2qV/KzR8qnMeqp295ZGO60CRb4JZdppxB2/90KPDXFex+I8IS9 qE2LEd69le3pgiaIGSfyZY7/VMgIQMiVEqUnU99WRufDW3uEvBp/IrWj/wiHmY/wUm ridb+Gzi6oKnW4Rj2zaqD8u95VTwStfTtH1nakd76T3lZofQqJbQ89Gs5Rf0n9mxJB ZCKyZutBvmraNTr/twF/Qe0CHL7uda40NlCilWCFepZ9a4+P0/MaWYcfj9wIqDFWFB Ap88kFf1HArbbAbyQhpoFj+bDyRC22LC5jT3qnFdywRo5kaVmNKCZ4+z0+3Xizuwtt nxOJIHeqamhbg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/12] mm/damon/lru_sort: use damon_commit_ctx() Date: Tue, 18 Jun 2024 11:18:08 -0700 Message-Id: <20240618181809.82078-12-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 13A342000E X-Stat-Signature: uq9o3dbuz9rz3xyqnhe66bxdw3cyzca6 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718734703-25840 X-HE-Meta: U2FsdGVkX19Qo+9PkCYJpcpVGKgPvslZmyUORZ+xsWbb5zVYvrAHj2mYfUKhgEgrflvAVK1ovvLdQKsamxrp8MxedE40DLG3F1ONhCgs6DFkIzWzlFbngQelUyv0AASK3GMuuF3qVGZpMOdoIWP4+lrPRro6nSlCD9jRgzsr7o+buy7NfuSXHDMT/rYxOqfXBBLWEYKr6dN12HLxIfUAvYUTK25ZISP4P9hIX/jqqJmhqAhcbOItO1CA+n3xcnE4udKTbTcBTeSmGrB0DM3NDLkcET3E47RRcnOilA6aTXdyqGWMBDLl+wI3Wq3zxEID97/2SUBdWYZjA8PTW/A/mgIc2u+xL7xhQ6jDAlHQFnYiYz8KJVyUb/nFXgYXXIyFoX/zAtdUMR6eK4wnnvgTs95WhrvKq4FZWVBaeyrg99PxFDP2qyEOXyQlxXf5Y1kp4jY1GmbZhFgfnoDSsgvPb11SO5bYG9XWiYpkDXO3F+kpw1f9sd8NmSRMNkLtcy7n07VvuKQqpGX/hODofRY91F1ejziKiojr1d4eSuaOVO2EQWGQ7FhFnuf/iPHmk6TztrWMnOks6Rsg05Q3idaMsaCc+dMUkFAvaZsIYvqaxALrHpgkGdhMZ7AsENM0VehKzhbIpi6QxdfemeXYIs1qyHb0N+CwZgcbd8u3sosRF+7gvYiemvJzb5voDp/jC3xLqYs+OtcEOAzHttZ6rhK5duDaDEtlwZgY1FVnnhIc1+dhcVWr/Rr5IaQ+TAeWccytg6MBU4cywViRBIXrSNM9UINT7E23v1yiNQDX5mEyuJwkp7rJlH2LXt5BVPaHJxLrz2KIUSeR7BsaTrEoHnl3a+Ag6j9N2Ty8jyAIkkxHgaj599fYapasjcjCA60GBsQl5qyUkfF4Et1vZwSDFR2/EvMlb8uSg0SALBK3wp/icXtEolE9V2BePlP7UC4katZ8WX/ZUKrHBDxiBN6Gf5x zrnNns1j BQvpizJdR/ZVqbB2fUjfYB8ZMwn9+WUbS3e/h9X47B6VcwEFjZe2gxRZ7wqpQ77clnT4PWm/j6aUctaemYe5cWCCmSDe3jO2oZQulmJ8vseqdWqXanVpRCxY2LdRW1P1yDBJAkYF7nUFWOOVgDk5K9Gko/3uXE9LBfEbwtfz6Fb9os/Y/FPufavzHBbRfo4J4a0r7seIrvpGQFlDIrCH17RZ3b24iUkMoKo/2ySaeoLuu509qLTP2C0AE3WqwMak8ID5/l0ElcetKk2BzDLngdx9v/XJd5HbGZ8Yk 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: List-Subscribe: List-Unsubscribe: DAMON_LRU_SORT manually manipulates the DAMON context struct for online parameters update. Since the struct contains not only input parameters but also internal status and operation results, it is not that simple. Indeed, we found and fixed a few bugs in the code. Now DAMON core layer provides a function for the usage, namely damon_commit_ctx(). Replace the manual manipulation logic with the function. The core layer function could have its own bugs, but this change removes a source of bugs. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 3775f0f2743d..f83542973946 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -199,15 +199,22 @@ static void damon_lru_sort_copy_quota_status(struct damos_quota *dst, static int damon_lru_sort_apply_parameters(void) { + struct damon_ctx *param_ctx; + struct damon_target *param_target; struct damos *scheme, *hot_scheme, *cold_scheme; struct damos *old_hot_scheme = NULL, *old_cold_scheme = NULL; unsigned int hot_thres, cold_thres; - int err = 0; + int err; - err = damon_set_attrs(ctx, &damon_lru_sort_mon_attrs); + err = damon_modules_new_paddr_ctx_target(¶m_ctx, ¶m_target); if (err) return err; + err = damon_set_attrs(ctx, &damon_lru_sort_mon_attrs); + if (err) + goto out; + + err = -ENOMEM; damon_for_each_scheme(scheme, ctx) { if (!old_hot_scheme) { old_hot_scheme = scheme; @@ -220,7 +227,7 @@ static int damon_lru_sort_apply_parameters(void) hot_thres_access_freq / 1000; hot_scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!hot_scheme) - return -ENOMEM; + goto out; if (old_hot_scheme) damon_lru_sort_copy_quota_status(&hot_scheme->quota, &old_hot_scheme->quota); @@ -229,18 +236,24 @@ static int damon_lru_sort_apply_parameters(void) cold_scheme = damon_lru_sort_new_cold_scheme(cold_thres); if (!cold_scheme) { damon_destroy_scheme(hot_scheme); - return -ENOMEM; + goto out; } if (old_cold_scheme) damon_lru_sort_copy_quota_status(&cold_scheme->quota, &old_cold_scheme->quota); - damon_set_schemes(ctx, &hot_scheme, 1); - damon_add_scheme(ctx, cold_scheme); + damon_set_schemes(param_ctx, &hot_scheme, 1); + damon_add_scheme(param_ctx, cold_scheme); - return damon_set_region_biggest_system_ram_default(target, + err = damon_set_region_biggest_system_ram_default(param_target, &monitor_region_start, &monitor_region_end); + if (err) + goto out; + err = damon_commit_ctx(ctx, param_ctx); +out: + damon_destroy_ctx(param_ctx); + return err; } static int damon_lru_sort_turn(bool on) From patchwork Tue Jun 18 18:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702822 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 200F0C27C4F for ; Tue, 18 Jun 2024 18:18:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B802C8D0047; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B11E8D004A; Tue, 18 Jun 2024 14:18:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A7C88D003B; Tue, 18 Jun 2024 14:18:27 -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 8B42C8D0041 for ; Tue, 18 Jun 2024 14:18:26 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4359F120A62 for ; Tue, 18 Jun 2024 18:18:26 +0000 (UTC) X-FDA: 82244819412.29.DF819B4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id A0BB614001D for ; Tue, 18 Jun 2024 18:18:24 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=b83Rt0oM; spf=pass (imf26.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734700; a=rsa-sha256; cv=none; b=bhOxOiCy8bjpelTi/7cQo9SgeCcfXNuTDaviBW29ekGmPJ/k4u2AaEAaratMSMZNhZIGT5 YGTWLR5nxkLHreqTwVDx5RRsGQPzeWDGW5eOHsC0niGwlnqYRpJxVBGfM3U90cOplAvXTa QegwOf40GS+RFr1Nii9nN000/ntExV4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=b83Rt0oM; spf=pass (imf26.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734700; 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=EKp4rTjFjoPyyrAOBTdsALhJHsEWne+AGSwLWZmchD4=; b=HBAN8bfRw/r+T7h2Iwq1Hwi2/Ht6BI7WB93fMiRgrP1gh+ah05WNxKPWGW/Z5cNEl/3hJu cq1CVF9n8STdirSi6mlwXdeeIxJeYzbv5TV5kwQnan4yUMlq7rtyAaaKeppJErWMkvMrdP M3uTuYY1C9Tzsi1tlmeDmy4d2o8rM1M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4DE4B619EC; Tue, 18 Jun 2024 18:18:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B564AC4AF1C; Tue, 18 Jun 2024 18:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734704; bh=EHvHHvs3IdQ5P9rJaPK4ESC9R2II3qWxcAR6kWa1t4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b83Rt0oMqPtrzFHwkktThAbwt6RLmjgTiYcJl5Yy8yP9GJeb/W67nnfp5KZK0arUv AILftpGiE3WMsdcmNVeO06uiWCOP57jzQFLd1M8NPK1GdpHyeeBWFks1meqa/uR74z DWfr3k0KW/cwRj2FJZ4zBkjFtSID93TaQ4C7+cS9bb0DBl9MUr+I84JLe5+2BrtIRJ BUqf6UfT/EeGXEDHkhVbNrnNcvbOZNlJIgR/RwJHs/r28rZ1dBIEY6OkC+j0xFOk89 gykTKPRNkIWYUZK8UdpT7GsbE6qwRUCV9YHJ614stO3SWX0cnJ/oDWEJL45ZS2dn1m 2zQtXOPOaSZGg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/12] mm/damon/lru_sort: remove unnecessary online tuning handling code Date: Tue, 18 Jun 2024 11:18:09 -0700 Message-Id: <20240618181809.82078-13-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: iimhg47zqck55ak5hdbxfmbo3gwn5unw X-Rspamd-Queue-Id: A0BB614001D X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718734704-251057 X-HE-Meta: U2FsdGVkX18DhhLd6MVLX2Eqnj1LhedvGAxarueqdThTGCKG2f5IdnNuC5HoX/JQTWn5VGX5DR0IUh99XFU/dACIBBlQ1NvyMDLN5ztp1m+YUOYirwpq41P9M4sbmtSsZHkB3+GaWQ0Z/yzulj5GeeN9KxHzn53MOWNgS5M9HUz3BcV1Ed7FjWSvonvrVhH7QcKn2zFJCpPMiQW4BDh+N2MHZnYW4+QLeeQd9ttyulxU7VT6D+O3mBUYusNXaKOdsUkk9k+RrVCq8PibLu9F5lFnLT3ikd4AyRzHAth0Jik2E8bEBeNngISR6pOxWyIXdkZaa/MUkEKCVB6BRs7IArxJgnSwBhXchDRNZSSD4HyH6dQbzlMo1Npo+QBm1/GDogNVYU/XsxrU2vS1gI6bmpVTrPR09o+fsb4cTNAB36Vxl4Tdl/dJlcJDJZihQhcKc6tg5PEcw+ciPGNtEwmHIYSVhbQzd7qSNaw4n+BHpGRS6dRDkrC6OPSRjCUnwkhE8i77P8AyEQMJ3kJrafDxCjm4Li0Qbmm9CPFJhKpR8oBO7ydwD7UuD34u2rMMKd0N9j6rbc4gG55dgx1KzLrxINA8AmUvAerXR4SkDqjBTFnswIolPDQMD2MSivvWzFlWl/GMPFr94zRSwv+/pmFklJNUgX8uexuYwr+y+ExHnSjv6Rph0/X9M2MdMo0dKeHLGbgERvRNfMsXObaLyTTFmGUJOxcUNnXH77Ql2oHJyiOv26Ftyl3zf5TqVLwglZnxqHg36Q3C129ECwfgLEJVcKVyCMJBZt3pPcBxOOEJbtOq2qH1ui+Du8ePqOtLTEq9eLn513bKbFJQNi+o3VhyFnVO3Oq3auWnMKuXogOMSX9+hUEdYpa41LXR/vaIyL7j+3Q89DtOzH+Ma1Oy9ZFa6tG12Y506trLTyfOOc/wbpZJaohvKhQjHcEOyXFiJ0v6OrBNHJMd1BQzPEc2FFw SKBxNjx8 mDLUrLlbdS2T2fexXEaL/MdAvCX86kriO/G1ZgggaVmXy9VWWnKa0z3U/cYBv1csh68iIGk3ftUzhBQzLOYLf0XXjr2dnyYc42gxBAmZhumW7ss4jc2JB7cjaSNrrALyRdlybUdbCKDgvLon15vLJZWZheNMVwbnfjoXJ507jRlNDVf97D46qMirLgST6mH+fx+jik71rKUeni2YK+KlKfMQQdOzeTxIfxa8Eo7xSYXoN8w86Sr7lr1U7lx4TKQghsPvuHoMfeTx6k5zxtg4L2zTn5LsEDu5c8ySn 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: List-Subscribe: List-Unsubscribe: DAMON_LRU_SORT contains code for handling of online DAMON parameters update edge cases. It is no more necessary since damon_commit_ctx() takes care of the cases. Remove the unnecessary code. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index f83542973946..4af8fd4a390b 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -186,23 +186,11 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); } -static void damon_lru_sort_copy_quota_status(struct damos_quota *dst, - struct damos_quota *src) -{ - dst->total_charged_sz = src->total_charged_sz; - dst->total_charged_ns = src->total_charged_ns; - dst->charged_sz = src->charged_sz; - dst->charged_from = src->charged_from; - dst->charge_target_from = src->charge_target_from; - dst->charge_addr_from = src->charge_addr_from; -} - static int damon_lru_sort_apply_parameters(void) { struct damon_ctx *param_ctx; struct damon_target *param_target; - struct damos *scheme, *hot_scheme, *cold_scheme; - struct damos *old_hot_scheme = NULL, *old_cold_scheme = NULL; + struct damos *hot_scheme, *cold_scheme; unsigned int hot_thres, cold_thres; int err; @@ -215,22 +203,11 @@ static int damon_lru_sort_apply_parameters(void) goto out; err = -ENOMEM; - damon_for_each_scheme(scheme, ctx) { - if (!old_hot_scheme) { - old_hot_scheme = scheme; - continue; - } - old_cold_scheme = scheme; - } - hot_thres = damon_max_nr_accesses(&damon_lru_sort_mon_attrs) * hot_thres_access_freq / 1000; hot_scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!hot_scheme) goto out; - if (old_hot_scheme) - damon_lru_sort_copy_quota_status(&hot_scheme->quota, - &old_hot_scheme->quota); cold_thres = cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; cold_scheme = damon_lru_sort_new_cold_scheme(cold_thres); @@ -238,9 +215,6 @@ static int damon_lru_sort_apply_parameters(void) damon_destroy_scheme(hot_scheme); goto out; } - if (old_cold_scheme) - damon_lru_sort_copy_quota_status(&cold_scheme->quota, - &old_cold_scheme->quota); damon_set_schemes(param_ctx, &hot_scheme, 1); damon_add_scheme(param_ctx, cold_scheme);