Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp27252rdb; Wed, 29 Nov 2023 18:38:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmRccIEhzvDgPVsA9i55GTwY8zFmpQFQr9iZDf3Z3AJtM0JAtwnzvL4kr1qvxsS7z24mWq X-Received: by 2002:a25:ae96:0:b0:d9a:49bb:3d1d with SMTP id b22-20020a25ae96000000b00d9a49bb3d1dmr19777467ybj.3.1701311893742; Wed, 29 Nov 2023 18:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701311893; cv=none; d=google.com; s=arc-20160816; b=BhYH70VwtTi0XdIF31FeVY/dAzF4sKZtDTDy4wLYHZVDntShVSDmZ9I37lf3QrwgOD hxMoJk640o9XzlcvfzKDz9iThLjtv2kXCpU7g+Q9D7Wh91rjfqO2l+AnJp445XwsmTMS 7T4krOwLEWCjjuRRFY0jEtU04h8n2YRLDDWXcMFvoVIjbAV9Qw2EZzER22rpd6D1JMSx 5JRkdE75gdfnRmAl08mXvjwF6ZCJzpn2SVw1wp/7celg/ekF4XQIEDj8IqXKW2m7SPko UESQIEV+D6nXS0cFQdO/K/M1JUL9m4oyOcnxtx37BScxoemG4OFyhRWykHD4Nl9mJaPi +gQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+y0XdEoH84SRvPQ31esO2pBGQn0+moIZB0kK+H5kX9A=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=c+lu9wyC/HfvKeL6yyaXEtxCa7iEiF+zhKeYL/OvhOBkNVGB9rYL+xL29iAb+dLj/1 4pBXz9B7vyPPWuogp0Yo05S47eFI309+fY8sXHxvjQE//6Pctq70rsPQsXxhHn3IW70Z K/RzKfAVH2yvuuM2mUjx+GnjlzPiHglolnJEg1iRIaF4jWXPkpPR1K0TKSBOTkCfYgD4 DAnvS+RMkowZXM7PjLYDRVgIPpp218vl4lr9K9QEssuyoqEk4GukC4DT1POlm0zUUwcF o7EPrgZ11PVwSdOAAd/pKVUFZ2hB2sea8ZrW4Cwma2j5PnS/ufvOGAEE/8r5m1cLpXaa WMlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TcLL9P8+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h16-20020a056a00219000b006be2d9914eesi200144pfi.118.2023.11.29.18.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 18:38:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TcLL9P8+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 38D1681F393C; Wed, 29 Nov 2023 18:38:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344193AbjK3Chg (ORCPT + 99 others); Wed, 29 Nov 2023 21:37:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbjK3Ch3 (ORCPT ); Wed, 29 Nov 2023 21:37:29 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE381BC1 for ; Wed, 29 Nov 2023 18:37:01 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1D64C433D9; Thu, 30 Nov 2023 02:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311821; bh=FMojcAP5QPRX+4T1uzEuLlR/gen6p9qPd+B5RLedtWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TcLL9P8+Oy7ltVM5DiR3gFU7QyJ4fcHcQUswFA5l9LkcNpPDLaI9QY14RyNitoWB1 AteHwdn9YvdZ3w6aJFgIy5DjiYi/B2H31eUsy/Gx1qdvsRKrF9qTYj/yLx5IUHKFjz ajMFnvqGe1TlsBdByvYwU2OHu8YSc0XRyCV0IoDpkGiY8KEdMRVVMzf+65jIALOfcJ XeHnYD6l5pqPhPA1It6KvoYEilCMZ9ixhpVE2VS+POXVvhPTdYGBTWkDQgdVkXk4w8 ZkJuTZNLXXSx7dJyny7Jrr0324rZWw/DA1/74PZpGrXp85Et4yYCRJLm3rIBo/pSOs G3u542rHiHFWg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] mm/damon/sysfs-schemes: commit damos quota goals user input to DAMOS Date: Thu, 30 Nov 2023 02:36:46 +0000 Message-Id: <20231130023652.50284-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 18:38:02 -0800 (PST) Make DAMON sysfs interface to read the user inputs for DAMOS quota goals and pass those to DAMOS, so that the users can use the quota auto-tuning feature. It uses the DAMON sysfs interface's user input commit mechanism, which applies all user inputs for initial starting of DAMON and online input updates, which can be done by writing 'on' and 'commit' to the kdamond's 'state' file, respectively. In other words, the user should periodically write appropriate value to 'current_value' files and 'commit' command to the 'state' file. 'target_value' files could also be similarly updated at any time. 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 e5531dbd4cf1..a7917534ca19 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1868,6 +1868,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) { @@ -1905,6 +1933,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) @@ -1945,6 +1975,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; -- 2.34.1