From patchwork Mon Feb 19 19:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563012 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 9B1E0C48BC3 for ; Mon, 19 Feb 2024 19:45:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A67F6B008A; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 95A136B0095; Mon, 19 Feb 2024 14:44:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 647FA6B0092; Mon, 19 Feb 2024 14:44:47 -0500 (EST) 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 49E0D6B008A for ; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 16718A03FA for ; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) X-FDA: 81809581014.23.BB7DC51 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf06.hostedemail.com (Postfix) with ESMTP id C7756180012 for ; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lX9paEie; spf=pass (imf06.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=1708371885; 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=/ZWqB51uiSLVGsyFb3R7KQTuo8SuEk6lmuqlWRgYzFg=; b=lMCz9IrxAUMalMsM9NnAi5l4jGtrrM5zY+rKXFASwptInj+CgA4HB8pOZoGZgjLFQT+3yq ZTy8WoY67EZMmUXD+qKHc2CK3RpYF701iuYq2oVgK9XrH0zTC2JLc9mcDcFjj9dhccYf5C x9RNo4Vq0rtA3QBwHqzXr2+xASZpMTA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lX9paEie; spf=pass (imf06.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=1708371885; a=rsa-sha256; cv=none; b=3m+ZZJC9rCAtuq62NlcNanUwGWRcmwLDFmjFGZ8PAGcfmrj1CEz6p/iSCMuZ2TFL5jnAep n2uCjpx72IqP+zLow1pgJ31MX65qPv/hDnr0vSQq6lc5GQqYqDG5lTQaLQvgA8XKVIKC5h kshHBlNYFR7ftRzQ+JxprjBIHatLmvA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 342D0CE13D9; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13681C433B1; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371879; bh=d9LlALHiCfhiFh3lfhrepX1jc1b9cJAF+/9AGNt4qgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lX9paEieqsiLEM6ItX40DG83FoS+BVepX8gzH32254OLWTtBWI+pg31scSWLMWDJO GGNt/pSlFCUeH11AZGf9BctaR37ARnCtn1SfAL6koonIlexRk8n/9D1FEWg1OBmnx5 V7Q0BaN7U19dLpeuk5L6/UvDx081fJVf8OqUjh9pXyVbMmtNhAs1Y5TG4esBp/TLF2 gNWo+SwxA8YPMogR5Z6XEx7SBxZryYYfep794y3jfF2rm4/1enu3XGHv3IiXiN4v4M 476v8cI23J4qe7PzLEf+xrPgVXo1lMqliX1rPD09v612FyMdnJBq75Xj9faG5232RG Jnre6Sp+zmveQ== 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/20] mm/damon/core: Set damos_quota->esz as public field and document Date: Mon, 19 Feb 2024 11:44:12 -0800 Message-Id: <20240219194431.159606-2-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-Rspamd-Queue-Id: C7756180012 X-Rspam-User: X-Stat-Signature: o4natx8a9jdin35nxa8u17ojsacg7536 X-Rspamd-Server: rspam01 X-HE-Tag: 1708371884-339687 X-HE-Meta: U2FsdGVkX18g1Og/o0co8Jx09EBD8/sndPqsBcOtcZXiwXfmHZ8OcRZ4ZhhKWUfFt+6YYXGndkzqWlDifjb+KqBtWnOV+58CPBZ4qAVP8BzTVAX9/h/JgwZ3IP3eSxEw6l10M3ST6uB0FP4oAvU35Vr8G/tuGcO71Jx3XrgdWwiGrVaMJTazmRWlBaAsRiWRafIv1MmiXs6bleKrBhSdNloNtA4BK7Xi80tuhRyW1346PWXvWAt4nURnHbzKSqgTbDZrPXx110VRoz7pJWCGrylCjzryrkxcEQbuWYZaQXQVDvjJfdFN0LdiodyyvL47yBMFYJDgyOifa9Nq2DByGVrLSRwlReiP/U4LF1WO6ENuLalyLWg/SzzQemUGqTE+T5R0eKrAxSgFV2lX5nOZm7Wzpk4UMEKL8YTxOteL8MtkR3TrLepQZpTNNjp50uGDaPX/BsLoE6wtkwY/wV6WKLEjJbWY1QhrPeNrx3kX/UjqDwaNmUOxxpJGQI78sgo0S3iZd1zalRQmxTqDMabeqZBllBIKIEJJUEm0fL/5RXET5qNpda8L2KW7xftmhGlJ+MfpihahURpG6CXSHjDQmELYMM8KlYHhabI+T4c5OYu8aj4QBankW/B06zZ7jtz3aLmYjfreIs9AzjiIbXkUuv/0QIT71Reoqj9uJXPLYkkEWWS7x3FuLb09XQSda/vp1JkgxoCr1iK8C1yT+ciVH9p5wR9rY/xn0WxED6kTloBCw+cbmoqDbgbBcayiXA4GgT3Vot3AHCKm7O1J8KW44OpHUCyvNnAYoIjRFt2YZ/DadT/ulfJ44feXhd1ejlITh4uV/paZcqtFOcp7eDwzcieLpoljHBEegxdOcFNP+md3HprPLX8k/GcX2R8hbMqgSOPYF7pylIiRpHXr2inKDsOTB+F+yPJJtpFs4st5ZwfcJj7jJyIjFxhTsG6/6S4jegi8YP2UL8+oWUH0oJt K61QWg1V y6s+kTOqh4s6bMFhfX6zDJ0Ai33xDiky0ikn1uqOb8J5apYLJLJb+oxi2P/TP+k1vegjGpEA+4vviQz/j7f2v7oPkP2n/P+VI4BOF4LCR6nRf+jf2oeI4yTNQmr17uhMvmUpbdM+WBlZh/LeDvqGDQLilAYa2JIl+MLLeiUjQrESSItbLQLPRNWToX6vsTc9XXEphNqtH1kJN5tnrztYi/bMn/l1+SRbdSsDWhDtEcjCPcphGXSvkirpuQXglgqkMVLLuHpqiv7KhmTj8bYKkLy864ZW5mCxsHbEb 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 allow users to specify the quota as they want in multiple ways including time quota, size quota, and feedback-based auto-tuning. DAMOS makes one effective quota out of the inputs and use it at the end. Knowing the current effective quota helps understanding DAMOS' internal mechanism and fine-tuning quotas. DAMON kernel API users can get the information from ->esz field of damos_quota struct, but the field is marked as private purpose, and not kernel-doc documented. Make it public and document. Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++-- mm/damon/core.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 5881e4ac30be..93ef45b87b9c 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -138,6 +138,7 @@ enum damos_action { * * @get_score: Feedback function for self-tuning quota. * @get_score_arg: Parameter for @get_score + * @esz: Effective size quota in bytes. * * To avoid consuming too much CPU time or IO resources for applying the * &struct damos->action to large memory, DAMON allows users to set time and/or @@ -167,6 +168,8 @@ enum damos_action { * tuning is getting the feedback screo value of 10,000. If @ms and/or @sz are * set together, those work as a hard limit quota. If neither @ms nor @sz are * set, the mechanism starts from the quota of one byte. + * + * The resulting effective size quota in bytes is set to @esz. */ struct damos_quota { unsigned long ms; @@ -179,14 +182,13 @@ struct damos_quota { unsigned long (*get_score)(void *arg); void *get_score_arg; + unsigned long esz; /* private: */ /* For throughput estimation */ unsigned long total_charged_sz; unsigned long total_charged_ns; - unsigned long esz; /* Effective size quota in bytes */ - /* For charging the quota */ unsigned long charged_sz; unsigned long charged_from; diff --git a/mm/damon/core.c b/mm/damon/core.c index 5b325749fc12..0656966a6fc4 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -299,12 +299,12 @@ void damos_destroy_filter(struct damos_filter *f) damos_free_filter(f); } -/* initialize private fields of damos_quota and return the pointer */ -static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) +/* initialize fields of @quota that normally API users wouldn't set */ +static struct damos_quota *damos_quota_init(struct damos_quota *quota) { + quota->esz = 0; quota->total_charged_sz = 0; quota->total_charged_ns = 0; - quota->esz = 0; quota->charged_sz = 0; quota->charged_from = 0; quota->charge_target_from = NULL; @@ -336,7 +336,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); - scheme->quota = *(damos_quota_init_priv(quota)); + scheme->quota = *(damos_quota_init(quota)); scheme->wmarks = *wmarks; scheme->wmarks.activated = true;