1 // SPDX-License-Identifier: GPL-2.0
3 * DAMON Debugfs Interface
8 #define pr_fmt(fmt) "damon-dbgfs: " fmt
10 #include <linux/damon.h>
11 #include <linux/debugfs.h>
12 #include <linux/file.h>
14 #include <linux/module.h>
15 #include <linux/page_idle.h>
16 #include <linux/slab.h>
18 static struct damon_ctx **dbgfs_ctxs;
19 static int dbgfs_nr_ctxs;
20 static struct dentry **dbgfs_dirs;
21 static DEFINE_MUTEX(damon_dbgfs_lock);
23 static void damon_dbgfs_warn_deprecation(void)
25 pr_warn_once("DAMON debugfs interface is deprecated, "
26 "so users should move to DAMON_SYSFS. If you cannot, "
32 * Returns non-empty string on success, negative error code otherwise.
34 static char *user_input_str(const char __user *buf, size_t count, loff_t *ppos)
39 /* We do not accept continuous write */
41 return ERR_PTR(-EINVAL);
43 kbuf = kmalloc(count + 1, GFP_KERNEL | __GFP_NOWARN);
45 return ERR_PTR(-ENOMEM);
47 ret = simple_write_to_buffer(kbuf, count + 1, ppos, buf, count);
57 static ssize_t dbgfs_attrs_read(struct file *file,
58 char __user *buf, size_t count, loff_t *ppos)
60 struct damon_ctx *ctx = file->private_data;
64 mutex_lock(&ctx->kdamond_lock);
65 ret = scnprintf(kbuf, ARRAY_SIZE(kbuf), "%lu %lu %lu %lu %lu\n",
66 ctx->attrs.sample_interval, ctx->attrs.aggr_interval,
67 ctx->attrs.ops_update_interval,
68 ctx->attrs.min_nr_regions, ctx->attrs.max_nr_regions);
69 mutex_unlock(&ctx->kdamond_lock);
71 return simple_read_from_buffer(buf, count, ppos, kbuf, ret);
74 static ssize_t dbgfs_attrs_write(struct file *file,
75 const char __user *buf, size_t count, loff_t *ppos)
77 struct damon_ctx *ctx = file->private_data;
78 struct damon_attrs attrs;
82 kbuf = user_input_str(buf, count, ppos);
86 if (sscanf(kbuf, "%lu %lu %lu %lu %lu",
87 &attrs.sample_interval, &attrs.aggr_interval,
88 &attrs.ops_update_interval,
89 &attrs.min_nr_regions,
90 &attrs.max_nr_regions) != 5) {
95 mutex_lock(&ctx->kdamond_lock);
101 ret = damon_set_attrs(ctx, &attrs);
105 mutex_unlock(&ctx->kdamond_lock);
112 * Return corresponding dbgfs' scheme action value (int) for the given
113 * damos_action if the given damos_action value is valid and supported by
114 * dbgfs, negative error code otherwise.
116 static int damos_action_to_dbgfs_scheme_action(enum damos_action action)
127 case DAMOS_NOHUGEPAGE:
136 static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len)
142 damon_for_each_scheme(s, c) {
143 rc = scnprintf(&buf[written], len - written,
144 "%lu %lu %u %u %u %u %d %lu %lu %lu %u %u %u %d %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
145 s->pattern.min_sz_region,
146 s->pattern.max_sz_region,
147 s->pattern.min_nr_accesses,
148 s->pattern.max_nr_accesses,
149 s->pattern.min_age_region,
150 s->pattern.max_age_region,
151 damos_action_to_dbgfs_scheme_action(s->action),
152 s->quota.ms, s->quota.sz,
153 s->quota.reset_interval,
155 s->quota.weight_nr_accesses,
157 s->wmarks.metric, s->wmarks.interval,
158 s->wmarks.high, s->wmarks.mid, s->wmarks.low,
159 s->stat.nr_tried, s->stat.sz_tried,
160 s->stat.nr_applied, s->stat.sz_applied,
170 static ssize_t dbgfs_schemes_read(struct file *file, char __user *buf,
171 size_t count, loff_t *ppos)
173 struct damon_ctx *ctx = file->private_data;
177 kbuf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
181 mutex_lock(&ctx->kdamond_lock);
182 len = sprint_schemes(ctx, kbuf, count);
183 mutex_unlock(&ctx->kdamond_lock);
186 len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
193 static void free_schemes_arr(struct damos **schemes, ssize_t nr_schemes)
197 for (i = 0; i < nr_schemes; i++)
203 * Return corresponding damos_action for the given dbgfs input for a scheme
204 * action if the input is valid, negative error code otherwise.
206 static enum damos_action dbgfs_scheme_action_to_damos_action(int dbgfs_action)
208 switch (dbgfs_action) {
210 return DAMOS_WILLNEED;
214 return DAMOS_PAGEOUT;
216 return DAMOS_HUGEPAGE;
218 return DAMOS_NOHUGEPAGE;
227 * Converts a string into an array of struct damos pointers
229 * Returns an array of struct damos pointers that converted if the conversion
230 * success, or NULL otherwise.
232 static struct damos **str_to_schemes(const char *str, ssize_t len,
235 struct damos *scheme, **schemes;
236 const int max_nr_schemes = 256;
237 int pos = 0, parsed, ret;
238 unsigned int action_input;
239 enum damos_action action;
241 schemes = kmalloc_array(max_nr_schemes, sizeof(scheme),
247 while (pos < len && *nr_schemes < max_nr_schemes) {
248 struct damos_access_pattern pattern = {};
249 struct damos_quota quota = {};
250 struct damos_watermarks wmarks;
252 ret = sscanf(&str[pos],
253 "%lu %lu %u %u %u %u %u %lu %lu %lu %u %u %u %u %lu %lu %lu %lu%n",
254 &pattern.min_sz_region, &pattern.max_sz_region,
255 &pattern.min_nr_accesses,
256 &pattern.max_nr_accesses,
257 &pattern.min_age_region,
258 &pattern.max_age_region,
259 &action_input, "a.ms,
260 "a.sz, "a.reset_interval,
261 "a.weight_sz, "a.weight_nr_accesses,
262 "a.weight_age, &wmarks.metric,
263 &wmarks.interval, &wmarks.high, &wmarks.mid,
264 &wmarks.low, &parsed);
267 action = dbgfs_scheme_action_to_damos_action(action_input);
271 if (pattern.min_sz_region > pattern.max_sz_region ||
272 pattern.min_nr_accesses > pattern.max_nr_accesses ||
273 pattern.min_age_region > pattern.max_age_region)
276 if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
277 wmarks.mid < wmarks.low)
281 scheme = damon_new_scheme(&pattern, action, 0, "a,
286 schemes[*nr_schemes] = scheme;
291 free_schemes_arr(schemes, *nr_schemes);
295 static ssize_t dbgfs_schemes_write(struct file *file, const char __user *buf,
296 size_t count, loff_t *ppos)
298 struct damon_ctx *ctx = file->private_data;
300 struct damos **schemes;
301 ssize_t nr_schemes = 0, ret;
303 kbuf = user_input_str(buf, count, ppos);
305 return PTR_ERR(kbuf);
307 schemes = str_to_schemes(kbuf, count, &nr_schemes);
313 mutex_lock(&ctx->kdamond_lock);
319 damon_set_schemes(ctx, schemes, nr_schemes);
324 mutex_unlock(&ctx->kdamond_lock);
325 free_schemes_arr(schemes, nr_schemes);
331 static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len)
333 struct damon_target *t;
338 damon_for_each_target(t, ctx) {
339 if (damon_target_has_pid(ctx))
340 /* Show pid numbers to debugfs users */
341 id = pid_vnr(t->pid);
343 /* Show 42 for physical address space, just for fun */
346 rc = scnprintf(&buf[written], len - written, "%d ", id);
353 written += scnprintf(&buf[written], len - written, "\n");
357 static ssize_t dbgfs_target_ids_read(struct file *file,
358 char __user *buf, size_t count, loff_t *ppos)
360 struct damon_ctx *ctx = file->private_data;
364 mutex_lock(&ctx->kdamond_lock);
365 len = sprint_target_ids(ctx, ids_buf, 320);
366 mutex_unlock(&ctx->kdamond_lock);
370 return simple_read_from_buffer(buf, count, ppos, ids_buf, len);
374 * Converts a string into an integers array
376 * Returns an array of integers array if the conversion success, or NULL
379 static int *str_to_ints(const char *str, ssize_t len, ssize_t *nr_ints)
382 const int max_nr_ints = 32;
384 int pos = 0, parsed, ret;
387 array = kmalloc_array(max_nr_ints, sizeof(*array), GFP_KERNEL);
390 while (*nr_ints < max_nr_ints && pos < len) {
391 ret = sscanf(&str[pos], "%d%n", &nr, &parsed);
395 array[*nr_ints] = nr;
402 static void dbgfs_put_pids(struct pid **pids, int nr_pids)
406 for (i = 0; i < nr_pids; i++)
411 * Converts a string into an struct pid pointers array
413 * Returns an array of struct pid pointers if the conversion success, or NULL
416 static struct pid **str_to_pids(const char *str, ssize_t len, ssize_t *nr_pids)
424 ints = str_to_ints(str, len, &nr_ints);
428 pids = kmalloc_array(nr_ints, sizeof(*pids), GFP_KERNEL);
432 for (; *nr_pids < nr_ints; (*nr_pids)++) {
433 pids[*nr_pids] = find_get_pid(ints[*nr_pids]);
434 if (!pids[*nr_pids]) {
435 dbgfs_put_pids(pids, *nr_pids);
448 * dbgfs_set_targets() - Set monitoring targets.
449 * @ctx: monitoring context
450 * @nr_targets: number of targets
451 * @pids: array of target pids (size is same to @nr_targets)
453 * This function should not be called while the kdamond is running. @pids is
454 * ignored if the context is not configured to have pid in each target. On
455 * failure, reference counts of all pids in @pids are decremented.
457 * Return: 0 on success, negative error code otherwise.
459 static int dbgfs_set_targets(struct damon_ctx *ctx, ssize_t nr_targets,
463 struct damon_target *t, *next;
465 damon_for_each_target_safe(t, next, ctx) {
466 if (damon_target_has_pid(ctx))
468 damon_destroy_target(t);
471 for (i = 0; i < nr_targets; i++) {
472 t = damon_new_target();
474 damon_for_each_target_safe(t, next, ctx)
475 damon_destroy_target(t);
476 if (damon_target_has_pid(ctx))
477 dbgfs_put_pids(pids, nr_targets);
480 if (damon_target_has_pid(ctx))
482 damon_add_target(ctx, t);
488 static ssize_t dbgfs_target_ids_write(struct file *file,
489 const char __user *buf, size_t count, loff_t *ppos)
491 struct damon_ctx *ctx = file->private_data;
492 bool id_is_pid = true;
494 struct pid **target_pids = NULL;
498 kbuf = user_input_str(buf, count, ppos);
500 return PTR_ERR(kbuf);
502 if (!strncmp(kbuf, "paddr\n", count)) {
508 target_pids = str_to_pids(kbuf, count, &nr_targets);
515 mutex_lock(&ctx->kdamond_lock);
518 dbgfs_put_pids(target_pids, nr_targets);
523 /* remove previously set targets */
524 dbgfs_set_targets(ctx, 0, NULL);
530 /* Configure the context for the address space type */
532 ret = damon_select_ops(ctx, DAMON_OPS_VADDR);
534 ret = damon_select_ops(ctx, DAMON_OPS_PADDR);
538 ret = dbgfs_set_targets(ctx, nr_targets, target_pids);
543 mutex_unlock(&ctx->kdamond_lock);
550 static ssize_t sprint_init_regions(struct damon_ctx *c, char *buf, ssize_t len)
552 struct damon_target *t;
553 struct damon_region *r;
558 damon_for_each_target(t, c) {
559 damon_for_each_region(r, t) {
560 rc = scnprintf(&buf[written], len - written,
562 target_idx, r->ar.start, r->ar.end);
572 static ssize_t dbgfs_init_regions_read(struct file *file, char __user *buf,
573 size_t count, loff_t *ppos)
575 struct damon_ctx *ctx = file->private_data;
579 kbuf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
583 mutex_lock(&ctx->kdamond_lock);
585 mutex_unlock(&ctx->kdamond_lock);
590 len = sprint_init_regions(ctx, kbuf, count);
591 mutex_unlock(&ctx->kdamond_lock);
594 len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
601 static int add_init_region(struct damon_ctx *c, int target_idx,
602 struct damon_addr_range *ar)
604 struct damon_target *t;
605 struct damon_region *r, *prev;
606 unsigned long idx = 0;
609 if (ar->start >= ar->end)
612 damon_for_each_target(t, c) {
613 if (idx++ == target_idx) {
614 r = damon_new_region(ar->start, ar->end);
617 damon_add_region(r, t);
618 if (damon_nr_regions(t) > 1) {
619 prev = damon_prev_region(r);
620 if (prev->ar.end > r->ar.start) {
621 damon_destroy_region(r, t);
631 static int set_init_regions(struct damon_ctx *c, const char *str, ssize_t len)
633 struct damon_target *t;
634 struct damon_region *r, *next;
635 int pos = 0, parsed, ret;
637 struct damon_addr_range ar;
640 damon_for_each_target(t, c) {
641 damon_for_each_region_safe(r, next, t)
642 damon_destroy_region(r, t);
646 ret = sscanf(&str[pos], "%d %lu %lu%n",
647 &target_idx, &ar.start, &ar.end, &parsed);
650 err = add_init_region(c, target_idx, &ar);
659 damon_for_each_target(t, c) {
660 damon_for_each_region_safe(r, next, t)
661 damon_destroy_region(r, t);
666 static ssize_t dbgfs_init_regions_write(struct file *file,
667 const char __user *buf, size_t count,
670 struct damon_ctx *ctx = file->private_data;
675 kbuf = user_input_str(buf, count, ppos);
677 return PTR_ERR(kbuf);
679 mutex_lock(&ctx->kdamond_lock);
685 err = set_init_regions(ctx, kbuf, ret);
690 mutex_unlock(&ctx->kdamond_lock);
695 static ssize_t dbgfs_kdamond_pid_read(struct file *file,
696 char __user *buf, size_t count, loff_t *ppos)
698 struct damon_ctx *ctx = file->private_data;
702 kbuf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
706 mutex_lock(&ctx->kdamond_lock);
708 len = scnprintf(kbuf, count, "%d\n", ctx->kdamond->pid);
710 len = scnprintf(kbuf, count, "none\n");
711 mutex_unlock(&ctx->kdamond_lock);
714 len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
721 static int damon_dbgfs_open(struct inode *inode, struct file *file)
723 damon_dbgfs_warn_deprecation();
725 file->private_data = inode->i_private;
727 return nonseekable_open(inode, file);
730 static const struct file_operations attrs_fops = {
731 .open = damon_dbgfs_open,
732 .read = dbgfs_attrs_read,
733 .write = dbgfs_attrs_write,
736 static const struct file_operations schemes_fops = {
737 .open = damon_dbgfs_open,
738 .read = dbgfs_schemes_read,
739 .write = dbgfs_schemes_write,
742 static const struct file_operations target_ids_fops = {
743 .open = damon_dbgfs_open,
744 .read = dbgfs_target_ids_read,
745 .write = dbgfs_target_ids_write,
748 static const struct file_operations init_regions_fops = {
749 .open = damon_dbgfs_open,
750 .read = dbgfs_init_regions_read,
751 .write = dbgfs_init_regions_write,
754 static const struct file_operations kdamond_pid_fops = {
755 .open = damon_dbgfs_open,
756 .read = dbgfs_kdamond_pid_read,
759 static void dbgfs_fill_ctx_dir(struct dentry *dir, struct damon_ctx *ctx)
761 const char * const file_names[] = {"attrs", "schemes", "target_ids",
762 "init_regions", "kdamond_pid"};
763 const struct file_operations *fops[] = {&attrs_fops, &schemes_fops,
764 &target_ids_fops, &init_regions_fops, &kdamond_pid_fops};
767 for (i = 0; i < ARRAY_SIZE(file_names); i++)
768 debugfs_create_file(file_names[i], 0600, dir, ctx, fops[i]);
771 static void dbgfs_before_terminate(struct damon_ctx *ctx)
773 struct damon_target *t, *next;
775 if (!damon_target_has_pid(ctx))
778 mutex_lock(&ctx->kdamond_lock);
779 damon_for_each_target_safe(t, next, ctx) {
781 damon_destroy_target(t);
783 mutex_unlock(&ctx->kdamond_lock);
786 static struct damon_ctx *dbgfs_new_ctx(void)
788 struct damon_ctx *ctx;
790 ctx = damon_new_ctx();
794 if (damon_select_ops(ctx, DAMON_OPS_VADDR) &&
795 damon_select_ops(ctx, DAMON_OPS_PADDR)) {
796 damon_destroy_ctx(ctx);
799 ctx->callback.before_terminate = dbgfs_before_terminate;
803 static void dbgfs_destroy_ctx(struct damon_ctx *ctx)
805 damon_destroy_ctx(ctx);
809 * Make a context of @name and create a debugfs directory for it.
811 * This function should be called while holding damon_dbgfs_lock.
813 * Returns 0 on success, negative error code otherwise.
815 static int dbgfs_mk_context(char *name)
817 struct dentry *root, **new_dirs, *new_dir;
818 struct damon_ctx **new_ctxs, *new_ctx;
820 if (damon_nr_running_ctxs())
823 new_ctxs = krealloc(dbgfs_ctxs, sizeof(*dbgfs_ctxs) *
824 (dbgfs_nr_ctxs + 1), GFP_KERNEL);
827 dbgfs_ctxs = new_ctxs;
829 new_dirs = krealloc(dbgfs_dirs, sizeof(*dbgfs_dirs) *
830 (dbgfs_nr_ctxs + 1), GFP_KERNEL);
833 dbgfs_dirs = new_dirs;
835 root = dbgfs_dirs[0];
839 new_dir = debugfs_create_dir(name, root);
840 /* Below check is required for a potential duplicated name case */
842 return PTR_ERR(new_dir);
843 dbgfs_dirs[dbgfs_nr_ctxs] = new_dir;
845 new_ctx = dbgfs_new_ctx();
847 debugfs_remove(new_dir);
848 dbgfs_dirs[dbgfs_nr_ctxs] = NULL;
852 dbgfs_ctxs[dbgfs_nr_ctxs] = new_ctx;
853 dbgfs_fill_ctx_dir(dbgfs_dirs[dbgfs_nr_ctxs],
854 dbgfs_ctxs[dbgfs_nr_ctxs]);
860 static ssize_t dbgfs_mk_context_write(struct file *file,
861 const char __user *buf, size_t count, loff_t *ppos)
867 kbuf = user_input_str(buf, count, ppos);
869 return PTR_ERR(kbuf);
870 ctx_name = kmalloc(count + 1, GFP_KERNEL);
876 /* Trim white space */
877 if (sscanf(kbuf, "%s", ctx_name) != 1) {
882 mutex_lock(&damon_dbgfs_lock);
883 ret = dbgfs_mk_context(ctx_name);
886 mutex_unlock(&damon_dbgfs_lock);
895 * Remove a context of @name and its debugfs directory.
897 * This function should be called while holding damon_dbgfs_lock.
899 * Return 0 on success, negative error code otherwise.
901 static int dbgfs_rm_context(char *name)
903 struct dentry *root, *dir, **new_dirs;
905 struct damon_ctx **new_ctxs;
909 if (damon_nr_running_ctxs())
912 root = dbgfs_dirs[0];
916 dir = debugfs_lookup(name, root);
920 inode = d_inode(dir);
921 if (!S_ISDIR(inode->i_mode)) {
926 new_dirs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_dirs),
933 new_ctxs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_ctxs),
940 for (i = 0, j = 0; i < dbgfs_nr_ctxs; i++) {
941 if (dbgfs_dirs[i] == dir) {
942 debugfs_remove(dbgfs_dirs[i]);
943 dbgfs_destroy_ctx(dbgfs_ctxs[i]);
946 new_dirs[j] = dbgfs_dirs[i];
947 new_ctxs[j++] = dbgfs_ctxs[i];
953 dbgfs_dirs = new_dirs;
954 dbgfs_ctxs = new_ctxs;
966 static ssize_t dbgfs_rm_context_write(struct file *file,
967 const char __user *buf, size_t count, loff_t *ppos)
973 kbuf = user_input_str(buf, count, ppos);
975 return PTR_ERR(kbuf);
976 ctx_name = kmalloc(count + 1, GFP_KERNEL);
982 /* Trim white space */
983 if (sscanf(kbuf, "%s", ctx_name) != 1) {
988 mutex_lock(&damon_dbgfs_lock);
989 ret = dbgfs_rm_context(ctx_name);
992 mutex_unlock(&damon_dbgfs_lock);
1000 static ssize_t dbgfs_monitor_on_read(struct file *file,
1001 char __user *buf, size_t count, loff_t *ppos)
1003 char monitor_on_buf[5];
1004 bool monitor_on = damon_nr_running_ctxs() != 0;
1007 len = scnprintf(monitor_on_buf, 5, monitor_on ? "on\n" : "off\n");
1009 return simple_read_from_buffer(buf, count, ppos, monitor_on_buf, len);
1012 static ssize_t dbgfs_monitor_on_write(struct file *file,
1013 const char __user *buf, size_t count, loff_t *ppos)
1018 kbuf = user_input_str(buf, count, ppos);
1020 return PTR_ERR(kbuf);
1022 /* Remove white space */
1023 if (sscanf(kbuf, "%s", kbuf) != 1) {
1028 mutex_lock(&damon_dbgfs_lock);
1029 if (!strncmp(kbuf, "on", count)) {
1032 for (i = 0; i < dbgfs_nr_ctxs; i++) {
1033 if (damon_targets_empty(dbgfs_ctxs[i])) {
1035 mutex_unlock(&damon_dbgfs_lock);
1039 ret = damon_start(dbgfs_ctxs, dbgfs_nr_ctxs, true);
1040 } else if (!strncmp(kbuf, "off", count)) {
1041 ret = damon_stop(dbgfs_ctxs, dbgfs_nr_ctxs);
1045 mutex_unlock(&damon_dbgfs_lock);
1053 static int damon_dbgfs_static_file_open(struct inode *inode, struct file *file)
1055 damon_dbgfs_warn_deprecation();
1056 return nonseekable_open(inode, file);
1059 static const struct file_operations mk_contexts_fops = {
1060 .open = damon_dbgfs_static_file_open,
1061 .write = dbgfs_mk_context_write,
1064 static const struct file_operations rm_contexts_fops = {
1065 .open = damon_dbgfs_static_file_open,
1066 .write = dbgfs_rm_context_write,
1069 static const struct file_operations monitor_on_fops = {
1070 .open = damon_dbgfs_static_file_open,
1071 .read = dbgfs_monitor_on_read,
1072 .write = dbgfs_monitor_on_write,
1075 static int __init __damon_dbgfs_init(void)
1077 struct dentry *dbgfs_root;
1078 const char * const file_names[] = {"mk_contexts", "rm_contexts",
1080 const struct file_operations *fops[] = {&mk_contexts_fops,
1081 &rm_contexts_fops, &monitor_on_fops};
1084 dbgfs_root = debugfs_create_dir("damon", NULL);
1086 for (i = 0; i < ARRAY_SIZE(file_names); i++)
1087 debugfs_create_file(file_names[i], 0600, dbgfs_root, NULL,
1089 dbgfs_fill_ctx_dir(dbgfs_root, dbgfs_ctxs[0]);
1091 dbgfs_dirs = kmalloc(sizeof(dbgfs_root), GFP_KERNEL);
1093 debugfs_remove(dbgfs_root);
1096 dbgfs_dirs[0] = dbgfs_root;
1102 * Functions for the initialization
1105 static int __init damon_dbgfs_init(void)
1109 mutex_lock(&damon_dbgfs_lock);
1110 dbgfs_ctxs = kmalloc(sizeof(*dbgfs_ctxs), GFP_KERNEL);
1113 dbgfs_ctxs[0] = dbgfs_new_ctx();
1114 if (!dbgfs_ctxs[0]) {
1120 rc = __damon_dbgfs_init();
1122 kfree(dbgfs_ctxs[0]);
1124 pr_err("%s: dbgfs init failed\n", __func__);
1128 mutex_unlock(&damon_dbgfs_lock);
1132 module_init(damon_dbgfs_init);
1134 #include "dbgfs-test.h"