From patchwork Mon Feb 19 19:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563006 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 84124C48BF8 for ; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C0E96B0087; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 670C16B0089; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49AE46B0088; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 369E56B0082 for ; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 07650A0391 for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) X-FDA: 81809580930.04.8E9C6C1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 762BBA001D for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NgOgZmiU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371883; 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=1PRKGkczrSCC9U0WyWDOfOusUernchL4EBxBtw24NII=; b=4uBphnZHkn10wsrZH/bongNwHz8XhVLX2j7NHjg2LC5yy3QY4ezUXr1IZyZu5jTPZBpFO4 r6WvhTYnv/yk2NTp9VMkuFzpBWNnXb8b3u9cCL/s+9vlCnxmT77r3UkUXLgvm6CqyKfMLc ZaNGA8vbMtNudtrHrGZSAZRWGHwFp28= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NgOgZmiU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371883; a=rsa-sha256; cv=none; b=VIDgv44/jUguUrAfChQ4bwxjJeHvk5cehU/ZyLbCOad6o7/jyhdO+dqzOjAKpMh9VbGoZd wgDB9lD0zIrwAGFPfvAw+taGjTNEe+GkE6PXnvRXdqo19n3ma59tck3xKbSv3vye/Q7Y0m cNmZ/FPsHPjUsFllFOmk7/dk0tlETK0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AC87960F63; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 257E6C433A6; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371882; bh=Qrt8JsNV5WkN+0gJ5TqfdjaJcuo1NKzpe3AmVI9CrWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NgOgZmiUq1dFACJWkzSo40xUY0CWmo3HkcrEs3Qntc04KmTD4ie048M4w7bSaDvGe X3uAWqEpQJnp5rIcb9NO63LE6exscXEK2a7FrdEhAnUsYNjMOXHS9hx7vrtqgAa8Ww N9eKU4ocm7Y6VVhmKolxeOUC69Ksq6HGnop1dAPJ6Sr4ZYdu/KVTVcVAzkQ9fUJfu4 Dtl+wq7VEg/lbpHNeevT31JTyjyQb9n9Iajdj6MHNetRMx95jh+nQSuTKvJDznV4hn JqBZMBaAYQyzGoXXA/SPyGlrDPXu66aXtoxujWaavGaBVXHfobr5Er2PGN5moe/tt5 B8X6f3vRLzZag== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/20] mm/damon: move comments and fields for damos-quota-prioritization to the end Date: Mon, 19 Feb 2024 11:44:17 -0800 Message-Id: <20240219194431.159606-7-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: 762BBA001D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pdmm9m336yx3hg4ah9s5u5kh586cz6b3 X-HE-Tag: 1708371883-381427 X-HE-Meta: U2FsdGVkX1+0NmYnaxUe4Uin/yqDRCYgjEQFQCdNlTGd9fCmm3XdzX5mZUDAU1T74wu/3tQ0JZampI6/zkVMad5UB1VNUKt6f6+2f8Ws4K+Y47zTnivNHwXGDhsUAL76cz+Sd3apkFXzvyue5M63APiQ/5qvgFJuBDJ8OyyFBEyhQym2n/m1+IrYEHNYuubZ3MJspGPKgvoSENHDKt59t/zaKvUiS2SKygSCyifJp6C+NCoOog5y/037O5WwP1tlCWmpGvK4hnH8xc5tup2HLi4SW//M9LLn6C3Le4gf4jNXHSpjwQ3E0NFhgBXwmAcHP0fuyiKwnzq5gPpCBXt0LwnftVImQmYdintEi58GCQT3RsootG9xHUG6Sodf5Q1kCZhuzjd5k6MlB22rrJpOUr6iluLMQK1WUmnJuEb4vf8Q6A6VJqhBUia43GzIdhFdRY38Ktdp6tKxnLnK6DJ1NyjO+QDpTDEvvjlQR7cfq6ohJojyXqOPThaPRvJDwykFnAtPf1tMEF7naZ2XsRa/nWQzdUYL0wHd+p5bqkq83WHgb6mym1+msQ+S/KR3C3yVySOtZPerrSHzcYeQIMohIxgytzv0P5CblIn3iQsQKp96T9Jvx3pOoE4OMzCy1r39ZDz40Y6wrYTi19sbEOxQ0vFDLZhOhiOkDxLVhge1xW1m8TH91J0kQVKGE8FwI59nGZ64csHjR+qHyDoSh47haWVEFMfaISAj+5xBKXuJNSeb3KewaUIIggwIpOmMyd2doE/7ZSFnEeM/NMTvs0891trLesShl2Y3ikVgqwTcvz9EGa0pBfXylKDyzDPu3Qyw9sqdqsR3tiNSEtUwOjXypx9zKXki0RbsvG7jVY9WkSue9C0VJZzxxuNLA3wvEEl9gMlA8Iyp20QS4+DzmfXm12jjdk3zLR7r9VdGxlgl8IOjTs1KTfudlA== 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: The comments and definition of 'struct damos_quota' lists a few fields for effective quota generation first, fields for regions prioritization under the quota, and then remaining fields for effective quota generation. Readers' should unnecesssarily switch their context in the middle. List all the fields for the effective quota first, and then fields for the prioritization for making it easier to read. Signed-off-by: SeongJae Park --- include/linux/damon.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 93ef45b87b9c..bd17b14828bc 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -128,18 +128,17 @@ enum damos_action { /** * struct damos_quota - Controls the aggressiveness of the given scheme. + * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @reset_interval: Charge reset interval in milliseconds. + * @get_score: Feedback function for self-tuning quota. + * @get_score_arg: Parameter for @get_score + * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. * @weight_nr_accesses: Weight of the region's nr_accesses for prioritization. * @weight_age: Weight of the region's age for prioritization. * - * @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 * size quotas. The quotas can be set by writing non-zero values to &ms and @@ -152,12 +151,6 @@ enum damos_action { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * For selecting regions within the quota, DAMON prioritizes current scheme's - * target memory regions using the &struct damon_operations->get_scheme_score. - * You could customize the prioritization logic by setting &weight_sz, - * &weight_nr_accesses, and &weight_age, because monitoring operations are - * encouraged to respect those. - * * If @get_score function pointer is set, DAMON calls it back with * @get_score_arg and get the return value of it for every @reset_interval. * Then, DAMON adjusts the effective quota using the return value as a feedback @@ -170,20 +163,25 @@ enum damos_action { * set, the mechanism starts from the quota of one byte. * * The resulting effective size quota in bytes is set to @esz. + * + * For selecting regions within the quota, DAMON prioritizes current scheme's + * target memory regions using the &struct damon_operations->get_scheme_score. + * You could customize the prioritization logic by setting &weight_sz, + * &weight_nr_accesses, and &weight_age, because monitoring operations are + * encouraged to respect those. */ struct damos_quota { + unsigned long reset_interval; unsigned long ms; unsigned long sz; - unsigned long reset_interval; + unsigned long (*get_score)(void *arg); + void *get_score_arg; + unsigned long esz; unsigned int weight_sz; unsigned int weight_nr_accesses; unsigned int weight_age; - unsigned long (*get_score)(void *arg); - void *get_score_arg; - unsigned long esz; - /* private: */ /* For throughput estimation */ unsigned long total_charged_sz;