mm/damon/sysfs: move sysfs_lock to common module
authorSeongJae Park <sj@kernel.org>
Wed, 26 Oct 2022 22:59:38 +0000 (22:59 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 30 Nov 2022 23:01:25 +0000 (15:01 -0800)
DAMON sysfs interface is implemented in a single file, sysfs.c, which has
about 2,800 lines of code.  As the interface is hierarchical and some of
the code can be reused by different hierarchies, it would make more sense
to split out the implementation into common parts and different parts in
multiple files.  As the beginning of the work, create files for common
code and move the global mutex for directories modifications protection
into the new file.

Link: https://lkml.kernel.org/r/20221026225943.100429-8-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/Makefile
mm/damon/sysfs-common.c [new file with mode: 0644]
mm/damon/sysfs-common.h [new file with mode: 0644]
mm/damon/sysfs.c

index 3e6b8ad..f8d535a 100644 (file)
@@ -3,7 +3,7 @@
 obj-y                          := core.o
 obj-$(CONFIG_DAMON_VADDR)      += ops-common.o vaddr.o
 obj-$(CONFIG_DAMON_PADDR)      += ops-common.o paddr.o
-obj-$(CONFIG_DAMON_SYSFS)      += sysfs.o
+obj-$(CONFIG_DAMON_SYSFS)      += sysfs-common.o sysfs.o
 obj-$(CONFIG_DAMON_DBGFS)      += dbgfs.o
 obj-$(CONFIG_DAMON_RECLAIM)    += reclaim.o
 obj-$(CONFIG_DAMON_LRU_SORT)   += lru_sort.o
diff --git a/mm/damon/sysfs-common.c b/mm/damon/sysfs-common.c
new file mode 100644 (file)
index 0000000..9dc7438
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Common Primitives for DAMON Sysfs Interface
+ *
+ * Author: SeongJae Park <sj@kernel.org>
+ */
+
+#include "sysfs-common.h"
+
+DEFINE_MUTEX(damon_sysfs_lock);
+
diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h
new file mode 100644 (file)
index 0000000..745a918
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Common Primitives for DAMON Sysfs Interface
+ *
+ * Author: SeongJae Park <sj@kernel.org>
+ */
+
+#include <linux/damon.h>
+#include <linux/kobject.h>
+
+extern struct mutex damon_sysfs_lock;
index f3d7b34..a847b91 100644 (file)
@@ -5,13 +5,11 @@
  * Copyright (c) 2022 SeongJae Park <sj@kernel.org>
  */
 
-#include <linux/damon.h>
-#include <linux/kobject.h>
 #include <linux/pid.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 
-static DEFINE_MUTEX(damon_sysfs_lock);
+#include "sysfs-common.h"
 
 /*
  * unsigned long range directory