From patchwork Sun Nov 12 19:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453380 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 AAE88C4167B for ; Sun, 12 Nov 2023 19:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C827B8D001C; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4C2E8D001B; Sun, 12 Nov 2023 14:46:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9FCE8D001C; Sun, 12 Nov 2023 14:46:18 -0500 (EST) 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 8F8E48D0002 for ; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8E9CF802F8 for ; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) X-FDA: 81450333594.24.0B7AE74 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id E519AC0006 for ; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ElglL7CM; spf=pass (imf10.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=1699818376; 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=c8RBfebLYj/irJ50NtFuHKb77zJqGsqkj803DZDYu+M=; b=ESt8j+zCJklqYNKPPdx5h49TjJ5HIO2JsDGHmliuiqbOg3kND/qeaF+54glljO9vWzMIeG 04ZiGOOTQMyQuMxn4BVY0Wzc7LXeAqfB0WOnF3nG0OsPu8lvOY75L72dvf78LHDsLxPu9y q+l11Kl5yl7cYu5kqLARht4Mzc3e14A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818376; a=rsa-sha256; cv=none; b=C3Oxp6ZMzVOpetwFVjIhG5xF0MUkOIP5dbVWnApQEQ8KNINh6ZjM9Tfz3EKz9lX4WKhiaN bfkbSC0JtxpmS0F6irP/Ibt6uh4QJsUZrh5xB2U/I3jK4ggtY932DdKAlAwBZazx87AJzf JjUNf8rKVC+yM4ZsKKY9JDdIUt/AfOo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ElglL7CM; spf=pass (imf10.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 246BA60C6C; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91F23C43391; Sun, 12 Nov 2023 19:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818374; bh=MxtUx51tOzqutV8xiuFATacKMvsWPmbxLxD9xhq6D0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ElglL7CM8DTNUMvs6zpbU98dLV/xAZSfMCOCe74EzCDQx13WqQ2sun5Eop+Vu1JlN 5aqCvIxzUfxRmaWDjsoSi05967P4ozWuGPaX8Yt6ko7ElRPUiyRe5gRfJekha2/nU+ FQIp8l43A/Mbx0w9H9Mc31haTzjOTEEl9q7T7+lryokZBn92fl6IFKRpaGZC38znwQ cW/R7dvdzCCnxPfKmKDMIQvdnOEshOxgT9y29zMJqwpAu4PVZfc01AkZ9a11sAmllC p7YuBzxb9uPB6URkcXhop5z84lhTVq7K7IepbaqAEBSB/Usb0KHEsYkG41nfXAXCKa dlPydUs9fyzOg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/8] mm/damon/sysfs-schemes: commit damos quota goals user input to DAMOS quota auto-tuning Date: Sun, 12 Nov 2023 19:46:02 +0000 Message-Id: <20231112194607.61399-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E519AC0006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: phehzoasi3ku7ihmx666fanmd8q4a14s X-HE-Tag: 1699818375-518780 X-HE-Meta: U2FsdGVkX1/KqgVTPEN7vB1mGs4KkOHETYNMJ5E1nze0LauNNKMxZ4WoTOxa83wnJ4dYAeJ2qwo9VDPxfs9vpaoh86NBM/sgZgby8J1rUUPVoUeHLwkr8Ml/urJpUUa8TyBzsDyDWamADNbj+tWe0HYMvchMxIwBG0zmYq42Vu97nmEIZ9fZIy3r7CxrN+XpsSTF6A9rOevWO8TcASIxid1Z2dKE0jybyEA9N1Eeu85APEqpAePEYTynnGYQNqoMITCCwrI2IQjrVGp4MijNc2fpzRzpBLW6oGfpNnrSrChfAKWc/UqkYYDNDEW/5KIrllsKtF6bBrOE+eqxj2HMN1eUSE16FU0lpW9Y+j8/s4YjASqZH6qUhxyIrvtyu+6ti4SqpMwbHktzRrK1lQ51oPTWwdzxYd+TQayR5JoajjmlLmuFGJ0nwHpnM3ibWSDnh82lxPwqDgzZ9xd+4eGsN52ocKHwRNf03RV7uKQUVJODh2BCs59K6odPoZim27h3Q3znjh/tj5K2KGuuUNHz6Y9cRrXuH3vsnVXPdjQfU4vXwLYYGi2h91NAZ8OkNYg1LLpUWz5HYmNbJcWd4eMqae5FtztXL4fF4yl9/mSBo1Ip5q3Cvdj7G9Ug9Wr3sRlVAHfP8XXAYf7B0wMHOz3ScX64+rriYFOwEJ1V8eLKvuVbBV4aokRGpwepFPXzKtqHsq76SvUlqo2RNsb+OSYUwyenCI4uOoNNItazBExHtbYysZqednwypWR81lGLhMni4GSt5T7gaUoEAFScXZEGuicLd7GNX60R5TbZU6HF1nhzAPbQC3pxWs6R8RJCiS4t2uOC98LauwOYaDMIMPiopQ10uX0iPhh1lSAgrnP7JtCLHxciqYlgJH8pJkUiVf8LUfTskTr5W2rLPqB18x+QK6BHGrcASs0GMUIVua09naSuf1Kz/0MBS6nMQXLUcHtFZ6RiaMwTzd/eqqokGvL oXFlaJzT 9zsCwh5HKqELUna/6KWXZdLXQ46RFWBoWO1FoGHxLqyYzcuNkkSlyh2fwY6fWvPZ8LjtB5cYSQRRorxija7ZiBUl91g8+zujY7mR/ViQAUs20SvLeQEvWuQCESzW0FdUJHcnCQW1haIcJzSNYAGqcZzMVfk85gXkgNmx127p4I3+7hDaAWvXmPf1Lya0NfCDPIHHopge2ivspxJWiSt3+ciCGI9vt6IR+AXGC3RIEV+tIAZE= 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: Make DAMON sysfs interface to read the DAMOS quota goals user input and pass it to DAMOS so that the input can be used for the quota auto-tuning. The committing is made for initial starting of DAMON, and online input updates that can be done via 'commit' input to the kdamond's 'state' file. That is, the user should periodically write 'current_value' files under goal directories and write 'commit' command to the 'state' file. Note that the interface is supporting multiple goals while the core logic supports only one goal. DAMON sysfs interface passes only best feedback among the given inputs, to avoid making DAMOS too aggressive. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index d3b57348f07b..10d8678e48ea 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1860,6 +1860,34 @@ 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 void damos_sysfs_set_quota_score( + struct damos_sysfs_quota_goals *sysfs_goals, + struct damos_quota *quota) +{ + struct damos_sysfs_quota_goal *sysfs_goal; + int i; + + quota->get_score = NULL; + quota->get_score_arg = (void *)0; + for (i = 0; i < sysfs_goals->nr; i++) { + sysfs_goal = sysfs_goals->goals_arr[i]; + if (!sysfs_goal->target_value) + continue; + + /* Higher score makes scheme less aggressive */ + quota->get_score_arg = (void *)max( + (unsigned long)quota->get_score_arg, + sysfs_goal->current_value * 10000 / + sysfs_goal->target_value); + quota->get_score = damos_sysfs_get_quota_score; + } +} + static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme *sysfs_scheme) { @@ -1897,6 +1925,8 @@ static struct damos *damon_sysfs_mk_scheme( .low = sysfs_wmarks->low, }; + damos_sysfs_set_quota_score(sysfs_quotas->goals, "a); + scheme = damon_new_scheme(&pattern, sysfs_scheme->action, sysfs_scheme->apply_interval_us, "a, &wmarks); if (!scheme) @@ -1937,6 +1967,8 @@ static void damon_sysfs_update_scheme(struct damos *scheme, scheme->quota.weight_nr_accesses = sysfs_weights->nr_accesses; scheme->quota.weight_age = sysfs_weights->age; + damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + scheme->wmarks.metric = sysfs_wmarks->metric; scheme->wmarks.interval = sysfs_wmarks->interval_us; scheme->wmarks.high = sysfs_wmarks->high;