linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/cma_debug: Avoid to use global cma_debugfs_root
@ 2019-02-21  4:01 Yue Hu
  2019-02-21  4:01 ` [PATCH] mm/cma_debug: Check for null tmp in cma_debugfs_add_one() Yue Hu
  0 siblings, 1 reply; 8+ messages in thread
From: Yue Hu @ 2019-02-21  4:01 UTC (permalink / raw)
  To: akpm, mhocko, rientjes, joe; +Cc: linux-mm, linux-kernel, huyue2

From: Yue Hu <huyue2@yulong.com>

Currently cma_debugfs_root is at global space. That is unnecessary
since it will be only used by next cma_debugfs_add_one(). We can
just pass it to following calling, it will save global space. Also
remove useless idx parameter.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 mm/cma_debug.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/mm/cma_debug.c b/mm/cma_debug.c
index f234672..2c2c869 100644
--- a/mm/cma_debug.c
+++ b/mm/cma_debug.c
@@ -21,8 +21,6 @@ struct cma_mem {
 	unsigned long n;
 };
 
-static struct dentry *cma_debugfs_root;
-
 static int cma_debugfs_get(void *data, u64 *val)
 {
 	unsigned long *p = data;
@@ -162,7 +160,7 @@ static int cma_alloc_write(void *data, u64 val)
 }
 DEFINE_SIMPLE_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n");
 
-static void cma_debugfs_add_one(struct cma *cma, int idx)
+static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry)
 {
 	struct dentry *tmp;
 	char name[16];
@@ -170,7 +168,7 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
 	scnprintf(name, sizeof(name), "cma-%s", cma->name);
 
-	tmp = debugfs_create_dir(name, cma_debugfs_root);
+	tmp = debugfs_create_dir(name, root_dentry);
 
 	debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops);
 	debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops);
@@ -188,6 +186,7 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
 static int __init cma_debugfs_init(void)
 {
+	struct dentry *cma_debugfs_root;
 	int i;
 
 	cma_debugfs_root = debugfs_create_dir("cma", NULL);
@@ -195,7 +194,7 @@ static int __init cma_debugfs_init(void)
 		return -ENOMEM;
 
 	for (i = 0; i < cma_area_count; i++)
-		cma_debugfs_add_one(&cma_areas[i], i);
+		cma_debugfs_add_one(&cma_areas[i], cma_debugfs_root);
 
 	return 0;
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-21  9:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-21  4:01 [PATCH] mm/cma_debug: Avoid to use global cma_debugfs_root Yue Hu
2019-02-21  4:01 ` [PATCH] mm/cma_debug: Check for null tmp in cma_debugfs_add_one() Yue Hu
2019-02-21  8:23   ` Michal Hocko
2019-02-21  8:36     ` Greg KH
2019-02-21  8:45       ` Michal Hocko
2019-02-21  9:10         ` Greg KH
2019-02-21  8:56     ` Yue Hu
2019-02-21  9:10       ` Greg KH

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).