[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201005105522.23841-9-sjpark@amazon.com>
Date: Mon, 5 Oct 2020 12:55:12 +0200
From: SeongJae Park <sjpark@...zon.com>
To: <akpm@...ux-foundation.org>
CC: SeongJae Park <sjpark@...zon.de>, <Jonathan.Cameron@...wei.com>,
<aarcange@...hat.com>, <acme@...nel.org>,
<alexander.shishkin@...ux.intel.com>, <amit@...nel.org>,
<benh@...nel.crashing.org>, <brendan.d.gregg@...il.com>,
<brendanhiggins@...gle.com>, <cai@....pw>,
<colin.king@...onical.com>, <corbet@....net>, <david@...hat.com>,
<dwmw@...zon.com>, <elver@...gle.com>, <fan.du@...el.com>,
<foersleo@...zon.de>, <gthelen@...gle.com>, <irogers@...gle.com>,
<jolsa@...hat.com>, <kirill@...temov.name>, <mark.rutland@....com>,
<mgorman@...e.de>, <minchan@...nel.org>, <mingo@...hat.com>,
<namhyung@...nel.org>, <peterz@...radead.org>,
<rdunlap@...radead.org>, <riel@...riel.com>, <rientjes@...gle.com>,
<rostedt@...dmis.org>, <rppt@...nel.org>, <sblbir@...zon.com>,
<shakeelb@...gle.com>, <shuah@...nel.org>, <sj38.park@...il.com>,
<snu@...zon.de>, <vbabka@...e.cz>, <vdavydov.dev@...il.com>,
<yang.shi@...ux.alibaba.com>, <ying.huang@...el.com>,
<zgf574564920@...il.com>, <linux-damon@...zon.com>,
<linux-mm@...ck.org>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH v21 08/18] mm/damon/primitives: Make coexistable with Idle Page Tracking
From: SeongJae Park <sjpark@...zon.de>
DAMON's reference 'primitives' internally use 'PG_Idle' flag. Because
the flag is also used by Idle Page Tracking but there was no way to
synchronize with it, the 'primitives' were configured to be exclusive
with Idle Page Tracking before. However, as we can now synchronize with
Idle Page Tracking using 'idle_page_lock', this commit makes the
primitives to do the synchronization and coexistable with Idle Page
Tracking.
Note that the 'primitives' only require the users to do the
synchronization by themselves.
Signed-off-by: SeongJae Park <sjpark@...zon.de>
---
include/linux/page_idle.h | 2 ++
mm/damon/Kconfig | 2 +-
mm/damon/primitives.c | 7 +++++++
mm/page_idle.c | 2 +-
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h
index d8a6aecf99cb..bcbb965b566c 100644
--- a/include/linux/page_idle.h
+++ b/include/linux/page_idle.h
@@ -8,6 +8,8 @@
#ifdef CONFIG_PAGE_IDLE_FLAG
+extern struct mutex page_idle_lock;
+
#ifdef CONFIG_64BIT
static inline bool page_is_young(struct page *page)
{
diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig
index 0d2a18ddb9d8..63b9c905b548 100644
--- a/mm/damon/Kconfig
+++ b/mm/damon/Kconfig
@@ -14,7 +14,7 @@ config DAMON
config DAMON_PRIMITIVES
bool "Monitoring primitives for virtual address spaces monitoring"
- depends on DAMON && MMU && !IDLE_PAGE_TRACKING
+ depends on DAMON && MMU
select PAGE_EXTENSION if !64BIT
select PAGE_IDLE_FLAG
help
diff --git a/mm/damon/primitives.c b/mm/damon/primitives.c
index 6c8cb66866ac..9f33677e4807 100644
--- a/mm/damon/primitives.c
+++ b/mm/damon/primitives.c
@@ -15,6 +15,10 @@
#include <linux/sched/mm.h>
#include <linux/slab.h>
+#ifndef CONFIG_IDLE_PAGE_TRACKING
+DEFINE_MUTEX(page_idle_lock);
+#endif
+
/* Minimal region size. Every damon_region is aligned by this. */
#define MIN_REGION PAGE_SIZE
@@ -552,6 +556,9 @@ bool damon_va_target_valid(struct damon_target *t)
{
struct task_struct *task;
+ if (!mutex_is_locked(&page_idle_lock))
+ return false;
+
task = damon_get_task_struct(t);
if (task) {
put_task_struct(task);
diff --git a/mm/page_idle.c b/mm/page_idle.c
index 0aa45f848570..958dcc18f6cd 100644
--- a/mm/page_idle.c
+++ b/mm/page_idle.c
@@ -16,7 +16,7 @@
#define BITMAP_CHUNK_SIZE sizeof(u64)
#define BITMAP_CHUNK_BITS (BITMAP_CHUNK_SIZE * BITS_PER_BYTE)
-static DEFINE_MUTEX(page_idle_lock);
+DEFINE_MUTEX(page_idle_lock);
/*
* Idle page tracking only considers user memory pages, for other types of
--
2.17.1
Powered by blists - more mailing lists