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: 203231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp5304dyc; Mon, 19 Feb 2024 11:45:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOh3dXS8RxBH89UbuHdhlqw1lf1KZ5JM3Jfy11TZCgrNqBeyfO0ixmdkYV6fm4E98aItAWNyk+if3yWG09PA0eDXGAiQ== X-Google-Smtp-Source: AGHT+IGDjz6vr9QyT/Awa9UEJ88xtdhQA2h3vIQGnF3dyGDejTXL3X3BUyctlnO2GmOoiFCdT7eE X-Received: by 2002:a17:90b:3b88:b0:299:58a4:4a90 with SMTP id pc8-20020a17090b3b8800b0029958a44a90mr8954031pjb.22.1708371931774; Mon, 19 Feb 2024 11:45:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371931; cv=pass; d=google.com; s=arc-20160816; b=KRg1uxCbs5FGlabbEZLgRcxjPEKauDBnV65nqBqT2vPBWhr6EF70xmmza3ZNiKZuK1 2b3Kw3eDoRfst2N7ABhbM85wBcv0fObnIfhYvo6iloiiGbaTlKdfwJgzkVtkfb2QCeAH c4RTkBuUY4VowHx5nVEWILJ8SZwKv1NQpfdpEIw5MGRCu9/LvTnUV6TVT90CE+BTtApQ v9S25QwG0+B96VszNP/2iUPCERmpPPrX7QseSnckv6jH2a2CJ/+PDKyA0fQJcD7w89Yx 5ek/fjCn3MNufhpbMDcVKxuGeRNSg3Ap0m5owZHAiMi7GdTgFDi02wmQDJmjpShCT8B4 fT0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/ZWqB51uiSLVGsyFb3R7KQTuo8SuEk6lmuqlWRgYzFg=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=tXlZ1uhReI+XES6/jd+SPkQXYy7PW2e0zWlee5NwfkyItfaKgjVEU6o+COMXL3jwHV D52S0IqpxLuPJRLvDOTOg5dC+3I7F+oqfeCuTD0sW2UNYJa6g/sELa+IQaJ8RoX63ch7 FVi56nHDfvr34BljONxW1JTAj0sHcPF2qwsyEzXz1/jRfEjbtEpkyggy7t+7rXFkpOoa MPkq9MoVpCVULglC+9q0ppEBONtdz6pTboc9+dI1zzZ1hBRS4JD2Jaj7QWlFMi5FcvAU YwknGxmoBlckKKHxY+q1QQ9+mw38hs9LpXJ+9mhDVBqbH4kAUCcm2fJJLOhkCsoooD+p 4AgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lX9paEie; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o6-20020a17090a744600b002971bc099d8si4927705pjk.44.2024.02.19.11.45.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:45:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lX9paEie; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9952F282913 for ; Mon, 19 Feb 2024 19:45:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 821E453E03; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lX9paEie" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1B6251C49; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371879; cv=none; b=bHea+bJz5xcBsCydAqPL70HIcw5j13iglNBGFPwyJ68R2UREvodZWdToBdByMjj1nNmlTvIG3ewUysdqql0AP9g8PrJcAfd8JIpFH4W4lI7UCMIvZxv1hlHpUdeTqQxuDOjK0pK9Baap4BuVwvsqOswtInCC+bIX1ylRJcbTqSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371879; c=relaxed/simple; bh=d9LlALHiCfhiFh3lfhrepX1jc1b9cJAF+/9AGNt4qgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iajp50yAmGzk4cRtajP881ytLXFXrrGXcnNBi4qRb4nLEKNTtQ7iSCMc5vJsXBWWIrKEsFTLTsN8GNeTlyFlQVq05UyQNgRoTmNykgDCwTidQgAaD/c6uNK5MwNksteBfsLGtPRmJz7+Dwtrg2rLsZqLOxCmZ7V0B80fr9ZIRUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lX9paEie; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357806818566367 X-GMAIL-MSGID: 1791357806818566367 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;