This change creates a directory for each online node in the system. Signed-off-by: Juan Yescas --- Changes in v2: - Fix comments. - Use for_each_node_state(nid, N_MEMORY) instead. mm/page_alloc_hogger.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 175f479c487b..5765ecc43567 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -89,6 +89,7 @@ #include #include #include +#include #include #include @@ -125,6 +126,26 @@ struct page_alloc { static struct kmem_cache *req_alloc_cache; static struct kmem_cache *page_alloc_cache; +/** + * create_nodes_subdirs() - Creates a directory for each node that contains + * memory. + */ +static inline int create_nodes_subdirs(struct dentry *mmdir) +{ + struct dentry *nodedir; + int nid; + char dirname[12]; + + for_each_node_state(nid, N_MEMORY) { + snprintf(dirname, sizeof(dirname), "node-%d", nid); + nodedir = debugfs_create_dir(dirname, mmdir); + if (IS_ERR(nodedir)) + return PTR_ERR(nodedir); + } + + return 0; +} + static int __init page_alloc_hogger_debugfs_init(void) { int ret; @@ -154,8 +175,15 @@ static int __init page_alloc_hogger_debugfs_init(void) goto clean_page_alloc_cache; } + ret = create_nodes_subdirs(mmdir); + if (ret) + goto clean_dir; + return 0; +clean_dir: + debugfs_remove_recursive(mmdir); + clean_page_alloc_cache: kmem_cache_destroy(page_alloc_cache); -- 2.55.0.629.g250fe7f194-goog