From: SeongJae Park <sjpark@xxxxxxxxx> On Thu, 8 Apr 2021 13:48:48 +0000 SeongJae Park <sj38.park@xxxxxxxxx> wrote: > From: SeongJae Park <sjpark@xxxxxxxxx> > > DAMON is designed to be used by kernel space code such as the memory > management subsystems, and therefore it provides only kernel space API. > That said, letting the user space control DAMON could provide some > benefits to them. For example, it will allow user space to analyze > their specific workloads and make their own special optimizations. > > For such cases, this commit implements a simple DAMON application kernel > module, namely 'damon-dbgfs', which merely wraps the DAMON api and > exports those to the user space via the debugfs. > [...] > +/* > + * Functions for the initialization > + */ > + > +static int __init damon_dbgfs_init(void) > +{ > + int rc; > + > + dbgfs_ctxs = kmalloc(sizeof(*dbgfs_ctxs), GFP_KERNEL); > + if (!dbgfs_ctxs) { > + pr_err("%s: dbgfs ctxs alloc failed\n", __func__); > + return -ENOMEM; > + } > + dbgfs_ctxs[0] = dbgfs_new_ctx(); > + if (!dbgfs_ctxs[0]) { > + pr_err("%s: dbgfs ctx alloc failed\n", __func__); > + return -ENOMEM; My colleague, Stefan found 'dbgfs_ctxs' is not freed here. Similar in below '__damon_dbgfs_init()' failure handling. I will fix these in the next version. Reported-by: Stefan Nuernberger <snu@xxxxxxxxx> Thanks, SeongJae Park > + } > + dbgfs_nr_ctxs = 1; > + > + rc = __damon_dbgfs_init(); > + if (rc) > + pr_err("%s: dbgfs init failed\n", __func__); > + > + return rc; > +} > + > +module_init(damon_dbgfs_init); > -- > 2.17.1 >