@@ -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)
{
@@ -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
@@ -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);
@@ -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