From patchwork Thu Jan 19 01:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13107284 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 B256AC38159 for ; Thu, 19 Jan 2023 01:38:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EC3C6B0075; Wed, 18 Jan 2023 20:38:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 69D7E6B0078; Wed, 18 Jan 2023 20:38:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 454966B007B; Wed, 18 Jan 2023 20:38:43 -0500 (EST) 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 2427A6B0075 for ; Wed, 18 Jan 2023 20:38:43 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 00FA5A4923 for ; Thu, 19 Jan 2023 01:38:42 +0000 (UTC) X-FDA: 80369839326.09.5074809 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf16.hostedemail.com (Postfix) with ESMTP id 6755A180010 for ; Thu, 19 Jan 2023 01:38:41 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CnXTVAit; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674092321; 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=Oy1cp+7yGyUimK41XJ4B2m90vIX7M8nbu9KoSvGzCqQ=; b=oCwQCWUfxF0iEDFpKhTR5s+CB60Sjr5eJDqTzLTGgd+vuex3c6Q5QB9yxmEhL6DHqBiis9 XJKn0V5FM0XtNGbJ1jesa82AoWvlDfjOn/f77MsA+Zhiv0luljosfBoirz1NsmDVrtTgsM XmGILCZGkFkGKef9l05RxXD0iQOeWKs= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CnXTVAit; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674092321; a=rsa-sha256; cv=none; b=ZJCZwpc1sCPvfcMT1gU14K/YHnIe5enJYbp7nM8q/997MyGCzTCerV9F+r9ssvQFJByism Pxkq7RZIXpfr9ZU7eJu+HNUlnXEqkuz5L8cKsnNzo0trkeC0kG1JJuyjANg45WzuroHZmO eyKsPY1SxhWlj7uwI0H9OIA4iq7ZLqQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D3061B81FB7; Thu, 19 Jan 2023 01:38:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26FDAC433EF; Thu, 19 Jan 2023 01:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674092318; bh=fkjQwp0vLjtzRNvd4VhBq2nF7CfFg6frjzTnDoBz50k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CnXTVAitPDgUvsOiX6vW9aROGzCslmoqZfT8CZ2eLQCt4U75qjK1GOtsmFX5Hh1mL GHkICAtA9fIez2uteqBjb+qkYlDqDgZoVFOyaA4k/GTtblnEyhvBhAtb4e4LVws6Qp DA9xynr2yHeQuGfMie535L77J68Rf4loZ8vsr36yvq7yvQL4QJvvOEOs1qtxUHHtBx eUoZBktQdw6BQ+9ajw8kIqoYs6Jgg2rVBMLS5qY0Iq/Jrrd97ra5R6/NBQbhXbH+Sh OBWxwozsw+MPupdH+wpqF7B5X13pWPDxxv1U/jyd8aViHxPxoVK+3G1FYOFKLnTa3g k+lZHNQuKqP+A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mm/damon: update comments in damon.h for damon_attrs Date: Thu, 19 Jan 2023 01:38:29 +0000 Message-Id: <20230119013831.1911-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119013831.1911-1-sj@kernel.org> References: <20230119013831.1911-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6755A180010 X-Stat-Signature: arnynkw7jwremqsa64ftttcamg65fmiz X-HE-Tag: 1674092321-790296 X-HE-Meta: U2FsdGVkX1/vqTh+bUk5hfg6ArvCfkXuR0lwr9HVO6iEiHYP5BxYKpeWDbXOS8vcXfl+7XpmyvtGznwZlv29iSp7Vz2mAiYUggN43fgmPojxdMYy0Y39P8+X5FAYAbDJKtLEAKjES+7N+4p67tt53mvGK6nnWyXx98BSC1hCIvZlhNUrDhu7WSfcMrtMWT7S4Hgz+946gaDiYEa+cTBwt2sixq7ywyNTHzjyTQEkAY9mMOKwy700jPlgMz3ZgZ+EvswkWm8rDcTLoNUUC7y6ZvbFW5UbfjY3OpR5M9zlfjybnYAXC2ob//scSxLH+YbENuoPgbTTYmK37eXWMySLssPZK+4fXGTTW1vlUejn97vrE329aXwAkKSWsNq0ZnqgXd63933OQnHPBRPbWt1GeaA4DRhg96N/or19Fs1altX0b8igg6gb+uA5vWUr0d4vvSpXD9m8deMiSTPmLBTY5ZBp8UHBmsmeS+9wDsJIQX8EQ00WxJ0xzO5Ydx8mXgU6vKcF962MDdXwhFxnxzp/8T87J6lXZ05Md+OnqoFLvgS2m7p0sHqYlA5vpKhiSH9brxbGCirztvgANbznbPUzbokLiZbPUYkHcYfXIaQPDo+X9zc6C29JIBPlTYfZOvIoMgNuqSOofw8leBB45gyDE69V/7J0bXGOwCMTWYU+OQ7tSurdmRO+U6BtFkSb3eODUroAwJBS05+QCz57UiVO/Z3RP+dZ/ip/HBLZOGMPFrsLdKFmRlHuIFxiSf4MSa8mZlA3m+132Dd1eEmgMFp8R/NuGbc9Nyqe6xq4y01YCvR0TMSvkKkC5EU1DssRm4YC2BPu/KNC8dBuaZwNddopCCtzZD41sV9XFYozKe2eSMLDKaqioqMAf2f4yRMft+CidEh8py+5Tet55XTyHRLt8A3pKWeCLmKuaCFUlqUpSLU5oSJHMTVWa4HeukHuzVPMaiX4S6h6FddBFQWQOsZ VdU9LH4l vV6Zsw7THGkaIT9pWE/3o21u1Lknc9PJSSgTCdlaY+YqVLqr4C9zX5fYCHHslAfMVFEWF3hWjhG+b+y47kvefrFf5H2cTMyHi/kXk7BOW55m0bCbgqEHGp5QS3Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Commit cbeaa77b0449 ("mm/damon/core: use a dedicated struct for monitoring attributes") moved monitoring intervals from damon_ctx to a new struct, damon_attrs, but a comment in the header file has not updated for the change. Update it. Fixes: cbeaa77b0449 ("mm/damon/core: use a dedicated struct for monitoring attributes") Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index dfb245bb3053..d5d4d19928e0 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -354,10 +354,10 @@ struct damon_ctx; * users should register the low level operations for their target address * space and usecase via the &damon_ctx.ops. Then, the monitoring thread * (&damon_ctx.kdamond) calls @init and @prepare_access_checks before starting - * the monitoring, @update after each &damon_ctx.ops_update_interval, and + * the monitoring, @update after each &damon_attrs.ops_update_interval, and * @check_accesses, @target_valid and @prepare_access_checks after each - * &damon_ctx.sample_interval. Finally, @reset_aggregated is called after each - * &damon_ctx.aggr_interval. + * &damon_attrs.sample_interval. Finally, @reset_aggregated is called after + * each &damon_attrs.aggr_interval. * * Each &struct damon_operations instance having valid @id can be registered * via damon_register_ops() and selected by damon_select_ops() later. From patchwork Thu Jan 19 01:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13107282 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 228FDC38159 for ; Thu, 19 Jan 2023 01:38:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8722B6B0073; Wed, 18 Jan 2023 20:38:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8234D6B0074; Wed, 18 Jan 2023 20:38:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5681A6B0075; Wed, 18 Jan 2023 20:38:42 -0500 (EST) 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 402716B0073 for ; Wed, 18 Jan 2023 20:38:42 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 068F2AAD7B for ; Thu, 19 Jan 2023 01:38:42 +0000 (UTC) X-FDA: 80369839284.11.7D0E232 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 7F51E1A0009 for ; Thu, 19 Jan 2023 01:38:40 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="s/Sn7kF6"; spf=pass (imf19.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=1674092320; 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=MnbWAeGIgkbFdIP5SaC2nqAaGdYVI4g3zgJAzihcluk=; b=YG7CQl9ePtGkGnOL5pEK/xyzQ14n9MlinBY92EEfgKuSg5vdwRQnSutvo7lThGu2Qysnuc 9P2ixKOPWj+XoMbg3q7TZw9P78b2ruy4BfbunPFSqFqr8c/FlydxCjawl73UUqLH4kg8BI ghh/lXd5B/Pe2YdVe0IrCb89nRR8qak= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="s/Sn7kF6"; spf=pass (imf19.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=1674092320; a=rsa-sha256; cv=none; b=8egz0PhCRFQZDv0STuci8Qwtkbm4hVew07/GKk9Gh1UBw3XkwreC0EMy0GxNNNxaS0rplV nBz/vb4WHBiLoowaVpQDhTJ7ztyQmtHxoCkZbAaga3mHlp6qaST9OW3WqinG8wZtou65BU zWpb3Gedy8GnHaR8vV8mHajtJVFF2HY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BAEBB61745; Thu, 19 Jan 2023 01:38:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF8F7C433F1; Thu, 19 Jan 2023 01:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674092319; bh=yP6UCgAzws1bfIuCPl7GC+6z1XlLpntmwCkcasuOLyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s/Sn7kF6Omqwq6ivaQphfNyZL1j/yVGYRmDcofn0KoeDu27nTBXyEXj08jraNePN+ Xn4BAUjzN+DK4KTjJBGSJcB8oka3uisg8HYE5hMkn9XrF/IRHDk/KKChGrB3enxxv6 4mqfuu2PfswrNY11OQriGo6l+SmFWK12o3UpoVnDU2Fp2ZxmpdceUme7do10dGrDnU +TqGgvf+I8K8kk21Zmqht6LtGFiwLRyKbVqV5J/B7v663j9EYoJk9DuuGUZnFwsZTq bQmbCIu49vdLv1YmI9j8umVn8Ym1RnWBYzFW9gzIpapvEb3oZMUwJ1HueZvAcuErDK gjORYVfVgvtqA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm/damon/core: update monitoring results for new monitoring attributes Date: Thu, 19 Jan 2023 01:38:30 +0000 Message-Id: <20230119013831.1911-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119013831.1911-1-sj@kernel.org> References: <20230119013831.1911-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7F51E1A0009 X-Rspam-User: X-Stat-Signature: 63tkatxit8gqb9t4i3wxcybpkrzpbc7j X-HE-Tag: 1674092320-115300 X-HE-Meta: U2FsdGVkX1/VZpsy8nrhA9T/eXPK3iqXijABhNIRmD3vmYPzvxG5gCNYxsBehlduCreaZLmbTbaJoR8le0qHB+OuNvnUor7DSNheH0XZp0zDm/L9CVEuXPFrBaBc1CaMTJg9OZY4zww/hT4/y+63R75RGe3y+jayjwhJaCsdl4OdqRiSLtKchdJJRG/Zv0PhnZLl7KMpjyI7/R13iW2CTZM2o11gkaOfyGJfwDiiY4sn4Q1NH9BsEtangbfzhKjU9AZ/9VplU7Vm/FrpdB1FaCUkKvjvVZb7BrMZK8Ihm2css8pxnI9yA6NQF4tCxkuJuZrQDY/FbBdCd6z1l/3BKzr73X+UJwsWpFQvqjJj3BpkgA1/suG5Bluo+e/rhSV0cw7Zj6m/6cIsnYCRCGTaZ/GT2extQIVaPyhQY+4VqIM+0eESivCAc8CoQRxjuc0JeJR2dtq5VRC4m4XuCTmlZVWcm10GiJx23cjUMkNJrrDPV+yKdU4qi0oAYFsXx2nleDIwJ0fJh/nF6te7fLsNIxgOKY8ddwrIx8zLrsTYvrcr6cgZkfCr0JkO9fxzuZW5WyJUVRKfspTLsfPbSnuyeN006V+YC5mtMsEboHjLYx1XjGhoZTw7FvZpkfyMX8jC9ZgzOF0crgtPbV9cHcrX37hZNZ+jtOleHfBuWhhM2Uz3/mPItXpKWg1PYKVtjo3Q1SvsjwaT5jsAKbUDdBqLXgac52vqG5bdpf6ZXt7hx+WMZr0lwROCU8AWFAtiO+Zuhvhbh6C+ONoXd9dk3Of1FKHlNR2V8dKwrQzxeUh3UeFOT9ffcNy1q6c1yZORiSW5AIfg7FS8GnC2BPyryY2H+Yg51UXNVwL78zGbmsDweFF0fAdiKp0zPcbuq3Io3QUFf31F5LuAoHuoEDzONk1TbQWDQE5xO2/3g/esI0LrHsDwunFYpaIGVXdoMdcJ4bcz5N9GFg+D5mEE/TQqj6Z hk2JN1Ck f9AyqFeg43kkPMqaUrE0qcvG/DXnACUOr+AML+asuzHhzyKHAPAC4FYJYICM+qxT3Tp6n 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: region->nr_accesses is the number of sampling intervals in the last aggregation interval that access to the region has found, and region->age is the number of aggregation intervals that its access pattern has maintained. Hence, the real meaning of the two fields' values is depending on current sampling and aggregation intervals. This means the values need to be updated for every sampling and/or aggregation intervals updates. As DAMON core doesn't, it is a duty of in-kernel DAMON framework applications like DAMON sysfs interface, or the userspace users. Handling it in userspace or in-kernel DAMON application is complicated, inefficient, and repetitive compared to doing the update in DAMON core. Do the update in DAMON core. Signed-off-by: SeongJae Park --- mm/damon/core.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 2db8c53491ca..d9ef62047bf5 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -465,6 +465,76 @@ void damon_destroy_ctx(struct damon_ctx *ctx) kfree(ctx); } +static unsigned int damon_age_for_new_attrs(unsigned int age, + struct damon_attrs *old_attrs, struct damon_attrs *new_attrs) +{ + return age * old_attrs->aggr_interval / new_attrs->aggr_interval; +} + +/* convert access ratio in bp (per 10,000) to nr_accesses */ +static unsigned int damon_accesses_bp_to_nr_accesses( + unsigned int accesses_bp, struct damon_attrs *attrs) +{ + unsigned int max_nr_accesses = + attrs->aggr_interval / attrs->sample_interval; + + return accesses_bp * max_nr_accesses / 10000; +} + +/* convert nr_accesses to access ratio in bp (per 10,000) */ +static unsigned int damon_nr_accesses_to_accesses_bp( + unsigned int nr_accesses, struct damon_attrs *attrs) +{ + unsigned int max_nr_accesses = + attrs->aggr_interval / attrs->sample_interval; + + return nr_accesses * 10000 / max_nr_accesses; +} + +static unsigned int damon_nr_accesses_for_new_attrs(unsigned int nr_accesses, + struct damon_attrs *old_attrs, struct damon_attrs *new_attrs) +{ + return damon_accesses_bp_to_nr_accesses( + damon_nr_accesses_to_accesses_bp( + nr_accesses, old_attrs), + new_attrs); +} + +static void damon_update_monitoring_result(struct damon_region *r, + struct damon_attrs *old_attrs, struct damon_attrs *new_attrs) +{ + r->nr_accesses = damon_nr_accesses_for_new_attrs(r->nr_accesses, + old_attrs, new_attrs); + r->age = damon_age_for_new_attrs(r->age, old_attrs, new_attrs); +} + +/* + * region->nr_accesses is the number of sampling intervals in the last + * aggregation interval that access to the region has found, and region->age is + * the number of aggregation intervals that its access pattern has maintained. + * For the reason, the real meaning of the two fields depend on current + * sampling interval and aggregation interval. This function updates + * ->nr_accesses and ->age of given damon_ctx's regions for new damon_attrs. + */ +static void damon_update_monitoring_results(struct damon_ctx *ctx, + struct damon_attrs *new_attrs) +{ + struct damon_attrs *old_attrs = &ctx->attrs; + struct damon_target *t; + struct damon_region *r; + + /* if any interval is zero, simply forgive conversion */ + if (!old_attrs->sample_interval || !old_attrs->aggr_interval || + !new_attrs->sample_interval || + !new_attrs->aggr_interval) + return; + + damon_for_each_target(t, ctx) + damon_for_each_region(r, t) + damon_update_monitoring_result( + r, old_attrs, new_attrs); +} + /** * damon_set_attrs() - Set attributes for the monitoring. * @ctx: monitoring context @@ -482,6 +552,7 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs) if (attrs->min_nr_regions > attrs->max_nr_regions) return -EINVAL; + damon_update_monitoring_results(ctx, attrs); ctx->attrs = *attrs; return 0; } From patchwork Thu Jan 19 01:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13107283 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 70EAEC678D4 for ; Thu, 19 Jan 2023 01:38:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D08706B0074; Wed, 18 Jan 2023 20:38:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C8F6C6B0075; Wed, 18 Jan 2023 20:38:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B07D36B0078; Wed, 18 Jan 2023 20:38:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9FEE06B0075 for ; Wed, 18 Jan 2023 20:38:42 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 74056C02D0 for ; Thu, 19 Jan 2023 01:38:42 +0000 (UTC) X-FDA: 80369839284.10.FD716B7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 0289A120002 for ; Thu, 19 Jan 2023 01:38:40 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kg1+ilbz; spf=pass (imf29.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=1674092321; 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=3fNupXQhsN5vsVTB6XW0C50NRNjjMAsS/7fTR58sXqA=; b=E62lphBd9YzzEP7euHP90PUhX26WYKkKt6Rx6J1fHl2lhxThCxyxsH9bXINoWgucfQcaq0 KBqsvZHtwpGlkjArRIl3P+sqV4DHepM8LvvMZLugJvB1T7T7aqxRUU13/GGz/Ga2TX2K3U pVN5/tW5SrSsDOsWIpCpbmQYM7I7vNM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kg1+ilbz; spf=pass (imf29.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=1674092321; a=rsa-sha256; cv=none; b=j9Ma1VX6AbVoW5BgVAzGtgmEF7cCXpQc7UgYMIqgunQEorc6198HMX3GvjNPM1W6EWd3J1 97ufDI1GJhCJ39c4Slo3ysTF6WNbvF9Isjh0LDfQqE0KCJhJ3B/tBP0MCARpYzk5lx1rDh FJmjBt3sS2DiG6PI5iGTtqVXcFMZfe0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 137046171D; Thu, 19 Jan 2023 01:38:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 640F5C43396; Thu, 19 Jan 2023 01:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674092319; bh=4x0hnDy4BX61lB/pbgUpUZC1nSP8lE0d4hLy0MishdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kg1+ilbzWZybIQkILRS0j625AZhP7sNVWI2JBN+aHXZ2odIdbzI0kIXodhRrbj8ig ZMlQ4qeSzaSsYFpuRnzk1VeYWQRxyj3bxvcHY4BsmNvGwxGvezui3C/8oY8XHTfMr1 riwUIv17ty8xmzBgdHfrQcUrlhG/vmLian0Hf13hjJTOKFHuNoMjtcPWMyym5tVu2W Z2l+vaKdgROZU4t5MbhLxAXrs0ziF63YtDE1YtWY33j47VgUn7nJ579EToCzI5pPi+ ETtxqdK8+Gl28xqf7e28CIgB8kJEL99OCQ7yiOS28Z5gqgwE3vjfd2dFLeexDvyU9g HDsnVYKUsQkew== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , brendanhiggins@google.com, kunit-dev@googlegroups.com, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mm/damon/core-test: add a test for damon_update_monitoring_results() Date: Thu, 19 Jan 2023 01:38:31 +0000 Message-Id: <20230119013831.1911-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119013831.1911-1-sj@kernel.org> References: <20230119013831.1911-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: y1argy464g8dpbsb8xfxieungh3z83bf X-Rspam-User: X-Rspamd-Queue-Id: 0289A120002 X-Rspamd-Server: rspam06 X-HE-Tag: 1674092320-821718 X-HE-Meta: U2FsdGVkX19auubuyx9brVTzQYOw/Ir0bubQ5A+9zszM536VAdt69Acnm4umufhDc3MUM8p9qe5YWJ0BhRSZStrWf6eQ7QbbSMFhVRRADeibS9hDADz4hSdlAhkxRJD/dsjdxAaS4FOaONUWn+9G2+BsdjF8lnGLP23j4WBzEzib8rnk1zFhQ5X1G4/Pl5+FvyfihgBAVtzqKce5Mg3DNsbJWGOXiB1fYjk2g+1wvH2IJ1+jn5jdOd3t+1gyi2NbwDFK0HnGqp0pQHILUf/YEfGWnrHH0RksGOBfK3wiPQiP05p1M7DPt49OK+4XH0W0ZVhciO8cTElSsvnLxRNe9R4HQ3hSFuRYREiiFYTR2ORLKsI42K4HDds4GnM1y0kxP2NpuaKZFVEztbE7+tPA1RPW4QP3ZHlq1yVm6PtgDarx1TyH7nzvKBp2rjB3JsS3o5VYNOBJvSWS8+QxQMw2F7xzqnJdnv8Yv1vxYg3yI7x79c8rVY7sQR209VdyXyr6d9Jgb0kYVh5YiLN+oxsJLMVUKBdcM6ckmwOqopvXk+ZtNN6l7VMVxi+KYvSLKG8wESUKOILwND0vRec8FZ2UBxdy3rgSfDaMCDKJYdTKr6Tf8j7neH4e2VCUwkiHBZd542lDUNCMdg/LMs9iTMgWb1PA9TvhJ4wkYdwcR+UqlqotvosZ/wTA+LZ81JKWcwJV7uitbvlJJz/TDrUpDw08PGvOGHUsMC29ZQzFyVtuSiEvjsaQGj3wyfpiVkHWpYJR2DroT6U9qUVObuf+l4NnUDOM6WS2SWuXd669LjktK/0BiBLg8vxz4rAG5CrR6Y0Y9qRSwygi7LU2E3sUuV1gjPtQRnWKB3inkpSO/Dj4H1BnneKZ9cV7QxFA5WavJ2E7etlPcRiOGbv2h3pgZJ1uMTWaCvJZldV01DPgDtrqjbpVY1UYIDBngUYjCF1TY7RH86XgxuFpz8K4gLsAh9q WS1O9QwT lIDNgTq96I2/qGmCnXpsaItiJO0SjZgyUn+vNnws4AwTe0q202uPysNrdzHzHMCB5JCIdX2hGZVFkgusDB3kVX0Ohx0g7sked4HInBwFpcg3kZmUd13XSgzhsog== 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: Add a simple unit test for damon_update_monitoring_results() function. Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index 3db9b7368756..fae64d32b925 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -289,6 +289,35 @@ static void damon_test_set_regions(struct kunit *test) damon_destroy_target(t); } +static void damon_test_update_monitoring_result(struct kunit *test) +{ + struct damon_attrs old_attrs = { + .sample_interval = 10, .aggr_interval = 1000,}; + struct damon_attrs new_attrs; + struct damon_region *r = damon_new_region(3, 7); + + r->nr_accesses = 15; + r->age = 20; + + new_attrs = (struct damon_attrs){ + .sample_interval = 100, .aggr_interval = 10000,}; + damon_update_monitoring_result(r, &old_attrs, &new_attrs); + KUNIT_EXPECT_EQ(test, r->nr_accesses, 15); + KUNIT_EXPECT_EQ(test, r->age, 2); + + new_attrs = (struct damon_attrs){ + .sample_interval = 1, .aggr_interval = 1000}; + damon_update_monitoring_result(r, &old_attrs, &new_attrs); + KUNIT_EXPECT_EQ(test, r->nr_accesses, 150); + KUNIT_EXPECT_EQ(test, r->age, 2); + + new_attrs = (struct damon_attrs){ + .sample_interval = 1, .aggr_interval = 100}; + damon_update_monitoring_result(r, &old_attrs, &new_attrs); + KUNIT_EXPECT_EQ(test, r->nr_accesses, 150); + KUNIT_EXPECT_EQ(test, r->age, 20); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -299,6 +328,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_split_regions_of), KUNIT_CASE(damon_test_ops_registration), KUNIT_CASE(damon_test_set_regions), + KUNIT_CASE(damon_test_update_monitoring_result), {}, };