This change defines and initializes the caches for the structs req_alloc and page_alloc. Signed-off-by: Juan Yescas --- mm/page_alloc_hogger.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc_hogger.c b/mm/page_alloc_hogger.c index 47b08d056978..52ccc6e99eb5 100644 --- a/mm/page_alloc_hogger.c +++ b/mm/page_alloc_hogger.c @@ -85,9 +85,12 @@ #include #include +#include +#include #include #include #include +#include struct dentry *mmdir; @@ -119,20 +122,55 @@ struct page_alloc { struct dentry *alloc_dentry; }; +struct kmem_cache *req_alloc_cache; +struct kmem_cache *page_alloc_cache; + static int __init page_alloc_hogger_debugfs_init(void) { + int ret; + + req_alloc_cache = kmem_cache_create( + "req_alloc_cache", sizeof(struct req_alloc), 0, + SLAB_HWCACHE_ALIGN, NULL); + if (!req_alloc_cache) { + pr_err("The req_alloc_cache couldn't be created"); + ret = -ENOMEM; + goto error_exit; + } + + page_alloc_cache = kmem_cache_create( + "page_alloc_cache", sizeof(struct page_alloc), 0, + SLAB_HWCACHE_ALIGN, NULL); + if (!page_alloc_cache) { + pr_err("The page_alloc_cache couldn't be created"); + ret = -ENOMEM; + goto clean_req_alloc_cache; + } + mmdir = debugfs_create_dir("mm", NULL); if (IS_ERR(mmdir)) { pr_err("Unable to create mm directory"); - return PTR_ERR(mmdir); + ret = PTR_ERR(mmdir); + goto clean_page_alloc_cache; } return 0; -} + +clean_page_alloc_cache: + kmem_cache_destroy(page_alloc_cache); + +clean_req_alloc_cache: + kmem_cache_destroy(req_alloc_cache); + +error_exit: + return ret; +} static void __exit page_alloc_hogger_debugfs_exit(void) { debugfs_remove_recursive(mmdir); + kmem_cache_destroy(req_alloc_cache); + kmem_cache_destroy(page_alloc_cache); } module_init(page_alloc_hogger_debugfs_init); -- 2.55.0.229.g6434b31f56-goog