From patchwork Mon Feb 19 19:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563013 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 1E5EEC48BC3 for ; Mon, 19 Feb 2024 19:45:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EF986B006E; Mon, 19 Feb 2024 14:44:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DCAF6B0078; Mon, 19 Feb 2024 14:44:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01A366B0096; Mon, 19 Feb 2024 14:44:47 -0500 (EST) 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 E0F406B0092 for ; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B1A51A05B5 for ; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) X-FDA: 81809581014.15.19A6F8C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 08CA04000D for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OlEYB5tC; 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=1708371886; 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=BPtcDrW6smk42ob/SAFc/GI98wGX/lFjOHolWe6AUqg=; b=OAzeK3t1jPSZkZ6IfOK3KHtFFKhTN/cTMHFFQz+IaZgv76CGPeGtSYqxCu1oTBSPOrv901 RCqd+X4HXKKuShVE26nNkd0oYVhg4X/4/Bli0RIU+zfLM2Fuv6W6dTFsD9Tn1Pzp456BLr /bLenEHeyTv721InHgCFp9MNbLeYevY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371886; a=rsa-sha256; cv=none; b=gRXo4INqRJwie7TiuF3efBed1paVFQxwQCWZSkvoRQdOlqY3AZKB/YAjZvmifp/nYPIG8b PAqxVdRFBMipl5oUavPS0krbglMIsLEPU5DQcIAlcorqBWUHH3x5PSZG1lgO7cEO0Mdm1l 1zZI6v1MUmDwJ1HwKuye7865NpbLXTo= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OlEYB5tC; 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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AD72360F6A; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03D0CC43394; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371885; bh=R3dxTppsO4aJJFug6nWMDIsYsBasUQvKpFzDWX0osTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OlEYB5tC4/VXhLLWfLhPwyH9Tzvh/9R0vhtcqhC+OvyZXwKASESgHHIjXyOQTm9fD tM1wtoxgijVyLP2EumAzUce+yvGmcGMEolxhZkNjwobgwRfeBEMN+ZYH2F1EwcBTTw Zklz3HDqD4mx/QWmPq6+0qpQWu/tPAaTa9OOdfUCxr/0VQ6iQa/gNvsPsFqsCgoYyW +NKW/JwAn8XxwOUbHwBxZ8qQQ8jIWBn6qk2ZwU06pG1Q3HDZ6qC27mv4F1XC+FfQGT 2aq8jhUFVJfdXLig4ZB9Q+4aQzEv09sXFcKMyciaKHTbOz28r9voYDgQn55ZTjpgx7 1rAXIxYu/wSzA== 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/20] mm/damon/core: let goal specified with only target and current values Date: Mon, 19 Feb 2024 11:44:22 -0800 Message-Id: <20240219194431.159606-12-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: rdd9e49ywfsmkokzy1yy7w1ebpp9udei X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 08CA04000D X-Rspam-User: X-HE-Tag: 1708371885-448235 X-HE-Meta: U2FsdGVkX19tyk4IsGp2L+9jYxGRfu0JyE7KnTRX80tBEiWFYeQ+i/W8JR7GJe4IuDMGGQaHoOJSN4A/39ZPV/mlUYfYLox7p0ccFI9NgTMr7LTziivSkLX4HCiogQNVts1Y3u8B7porivJ6QgxQUzyLawbAancwyn3nsOQu/TwSNDoEGZtBDHdZKG4cJuWkWMITvgHdvuiNm8+gMN4irNzWrQA96G131xpucpmxhA3COj34d1D1nyCV9Zu+bb/9rzJfKXTe6na2kd7EbqDsGi2Vh70TJKg2mu22hVdohDT2sClBDQqVNxJEe6yuMCBB1BbeY1vl/HRRf+7Q/vZDIboe/+C0t1Pl7jJYW4KePXslLEyNrUCIeyx3ACRr8mOsmuNtCKh2S/TtREDgTffZC5qQZ79Fsa/Yiq39SKeQ8G9gNU6/5rSCDqunV/0QQMbLSCszBTvDITUEUz3UbRHMnpIItPOCVefj3usroNnztwb2rKr/OeoV2nVyY8obcl3JAHYCEYjcsgEtwdhx1OPDR9mklXDnrBkpfXn2+Tyezz2FTQFT7D7DNIQ7gkVDIN5qVkr5C0lSBYqnrtXYCcDheDpM9XbLczBMUxA5KQT1iWYhMIRhDJk/pehgrGTB6GrXeVRUYhmn0YJBoVBUCPUXAEqfcP6YOkIRTC8RrRFPOfWXrkClnd+ZNqrVHLlnnCvz7UDCrvpgruioDYC8tDUlPCO6DGIgPWsxFLGzike9JFWHqVGGyh5TGriigKOhCQuBPsGDgdHmmRZx86susJzhR63+nxrQ+WXgBEAslSsMsYMAYWK+utRUbUq2byXLVENVTRCddiLWBWzd08EK9oqoB41IOOW5qil/7lCTaQGOO6PLlWO4qgA5Sq6VL9QMhOh9LfdZDwN0XRzwn9QLrmn56oNRxodYNPCEM/3xXdbyRlCalPrtIilR7y2oBCyoaIdse2tliZvVQDzJUqPqow0 gkbwDNYc arw1jASNfFGWkUZCHUWIJi/7b3VON9ljfWws52pHNxHS/L4bYQsnmL5FtLsNI6/LE4gHbWQSRy27w8rsDXXUuwWgQJVRv0H41e+E6c6FFpAhgbsZjqJh//0FQ5VswruPfnOxgTiV+vFlePxR1whFsH+ZXruff7bMMFP3frrc0y6+k/4JaaxNKl17YmIIbxyEVjQQA8IqHxR3UP/XMgAIt0p39pbJA1BF3/aFZ1+fttlISe+nkLn/C0nQJEA== 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: DAMOS quota auto-tuning feature let users to set the goal by providing a function for getting the current score of the tuned quota. It allows flexible goal setup, but only simple user-set quota is currently being used. As a result, the only user of the DAMOS quota auto-tuning is using a silly void pointer casting based score value passing function. Simplify the interface and the user code by letting user directly set the target and the current value. Signed-off-by: SeongJae Park --- include/linux/damon.h | 19 +++++++++---------- mm/damon/core.c | 9 +++++---- mm/damon/sysfs-schemes.c | 10 ++-------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 76c965c1eea3..de0cdc7f96d2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -128,19 +128,18 @@ enum damos_action { /** * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. - * @get_score: Function for getting current score of the goal. - * @get_score_arg: Parameter for @get_score + * @target_value: Target value to achieve with the tuning. + * @current_value: Current value that achieving with the tuning. * @list: List head for siblings. * - * Data structure for getting the current score of the quota tuning goal. - * Calling @get_score with @get_score_arg as the parameter should return the - * current score. Then the score is entered to DAMON's internal feedback loop - * mechanism to get the auto-tuned quota. The goal of the tuning is getting - * the feedback score value of 10,000. + * Data structure for getting the current score of the quota tuning goal. The + * score is calculated by how close @current_value and @target_value are. Then + * the score is entered to DAMON's internal feedback loop mechanism to get the + * auto-tuned quota. */ struct damos_quota_goal { - unsigned long (*get_score)(void *arg); - void *get_score_arg; + unsigned long target_value; + unsigned long current_value; struct list_head list; }; @@ -690,7 +689,7 @@ void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); struct damos_quota_goal *damos_new_quota_goal( - unsigned long (*get_score)(void *), void *get_score_arg); + unsigned long target_value, unsigned long current_value); void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); void damos_destroy_quota_goal(struct damos_quota_goal *goal); diff --git a/mm/damon/core.c b/mm/damon/core.c index 7b06d926c552..907f467fc8c0 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -300,15 +300,15 @@ void damos_destroy_filter(struct damos_filter *f) } struct damos_quota_goal *damos_new_quota_goal( - unsigned long (*get_score)(void *), void *get_score_arg) + unsigned long target_value, unsigned long current_value) { struct damos_quota_goal *goal; goal = kmalloc(sizeof(*goal), GFP_KERNEL); if (!goal) return NULL; - goal->get_score = get_score; - goal->get_score_arg = get_score_arg; + goal->target_value = target_value; + goal->current_value = current_value; INIT_LIST_HEAD(&goal->list); return goal; } @@ -1132,7 +1132,8 @@ static unsigned long damos_quota_score(struct damos_quota *quota) damos_for_each_quota_goal(goal, quota) highest_score = max(highest_score, - goal->get_score(goal->get_score_arg)); + goal->current_value * 10000 / + goal->target_value); return highest_score; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7bf94b1ed6f7..50218a7bfa0a 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1882,11 +1882,6 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, return 0; } -static unsigned long damos_sysfs_get_quota_score(void *arg) -{ - return (unsigned long)arg; -} - static int damos_sysfs_set_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) @@ -1904,9 +1899,8 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(damos_sysfs_get_quota_score, - (void *)(sysfs_goal->current_value * 10000 / - sysfs_goal->target_value)); + goal = damos_new_quota_goal(sysfs_goal->target_value, + sysfs_goal->current_value); if (!goal) return -ENOMEM; damos_add_quota_goal(quota, goal);