linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] mm/damon/core: intorduce per-context region priorities histogram buffer
Date: Sun, 25 Aug 2024 21:23:20 -0700	[thread overview]
Message-ID: <20240826042323.87025-2-sj@kernel.org> (raw)
In-Reply-To: <20240826042323.87025-1-sj@kernel.org>

Introduce per-context buffer for region priority scores-total size
histogram.  Same to the per-quota one (->histogram of
struct damos_quota), the new buffer is hidden from DAMON API users by
being defined as a private field of DAMON context structure.  It is
dynamically allocated and de-allocated at the beginning and ending of
the execution of the kdamond by kdamond_fn() itself.

[1] commit 0742cadf5e4c ("mm/damon/lru_sort: adjust local variable to dynamic allocation")
[2] https://lore.kernel.org/20240531122320.909060-1-yorha.op@gmail.com

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 2 ++
 mm/damon/core.c       | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index fcccaa9b9d54..6342d8f9b0fd 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -661,6 +661,8 @@ struct damon_ctx {
 	unsigned long next_ops_update_sis;
 	/* for waiting until the execution of the kdamond_fn is started */
 	struct completion kdamond_started;
+	/* for scheme quotas prioritization */
+	unsigned long *regions_score_histogram;
 
 /* public: */
 	struct task_struct *kdamond;
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 84d9b0fd8ace..be3d05357667 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2019,6 +2019,10 @@ static int kdamond_fn(void *data)
 		ctx->ops.init(ctx);
 	if (ctx->callback.before_start && ctx->callback.before_start(ctx))
 		goto done;
+	ctx->regions_score_histogram = kmalloc_array(DAMOS_MAX_SCORE + 1,
+			sizeof(*ctx->regions_score_histogram), GFP_KERNEL);
+	if (!ctx->regions_score_histogram)
+		goto done;
 
 	sz_limit = damon_region_sz_limit(ctx);
 
@@ -2096,6 +2100,7 @@ static int kdamond_fn(void *data)
 		ctx->callback.before_terminate(ctx);
 	if (ctx->ops.cleanup)
 		ctx->ops.cleanup(ctx);
+	kfree(ctx->regions_score_histogram);
 
 	pr_debug("kdamond (%d) finishes\n", current->pid);
 	mutex_lock(&ctx->kdamond_lock);
-- 
2.39.2



  reply	other threads:[~2024-08-26  4:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26  4:23 [PATCH 0/4] replace per-quota region priorities histogram buffer with per-context one SeongJae Park
2024-08-26  4:23 ` SeongJae Park [this message]
2024-08-26  4:23 ` [PATCH 2/4] mm/damon/core: replace per-quota regions priority histogram buffer usage " SeongJae Park
2024-08-26  4:23 ` [PATCH 3/4] mm/damon/core: remove per-scheme region priority histogram buffer SeongJae Park
2024-08-26  4:23 ` [PATCH 4/4] Revert "mm/damon/lru_sort: adjust local variable to dynamic allocation" SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240826042323.87025-2-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).