Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1335035rdb; Mon, 19 Feb 2024 11:45:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFhPru7Q9H4cDMfYNUqhWVrKKf11SFNZSWdlEb3JJ4VlRmzujBnLj6AknptETXx4LrzyvppT0SZR3mA8jfOw4sav+y9kC/gZDF4+iSlw== X-Google-Smtp-Source: AGHT+IHl1l5TTTTmW8fY/61NNxjVBitRd4T1T4Y6u2bNyQ8VVdW8NjRQl2XGQUpjkFo4K5VgG77R X-Received: by 2002:a17:90a:1f44:b0:296:e8e3:13c7 with SMTP id y4-20020a17090a1f4400b00296e8e313c7mr17318565pjy.10.1708371900364; Mon, 19 Feb 2024 11:45:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371900; cv=pass; d=google.com; s=arc-20160816; b=dC1g/9WJiFUlRH9cgog8M3MMZpEz6yZ9Z/QiYiZANozkOJ6GIRx06ZwlUrWRxQxCFj Oafsc+MyHmUepymPpUn8qEXmAnejUuAYWqQRF6PvyDBCScuNKtzTvewJv6PPM1HOHctk nXPsgQrxQuOMl1U0tro6ssV4uIyUNz0Nb54KYC/rem/8Za6jqvxqqYnCshCeMj5+gB6V ESbo3teVgfWg9xD6g6NYk1XqcwF5+fK/JUIdtXI9NeNjVjsNNmQ3UUtJ0iVVE9AOtrsj 0GxPf7Ha4EhgsS2+eJWqHyNBnIk3qGtSc4Tev3HJ2wXde/9XfgiM2RAmtHtM7GNeVCcX S3Iw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71882-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p11-20020a17090a2d8b00b002993b6846d5si5017431pjd.85.2024.02.19.11.45.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:45:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71882-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71882-linux.lists.archive=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 188B7280EF1 for ; Mon, 19 Feb 2024 19:45:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AABA152F74; Mon, 19 Feb 2024 19:44:40 +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 Content-Transfer-Encoding: 8bit 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; -- 2.39.2