Re: [PATCH v23 07/15] mm/damon: Implement a debugfs-based user space interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Mon, 1 Feb 2021 09:37:39 -0800 Shakeel Butt <shakeelb@xxxxxxxxxx> wrote:
> 
> > On Tue, Dec 15, 2020 at 3:59 AM SeongJae Park <sjpark@xxxxxxxxxx> 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.
> > 
> > Which kernel space APIs are being referred here?
> 
> The symbols in 'include/linux/damon.h'
> 
> > 
> > > 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.
> > >
> [...]
> > > +static ssize_t dbgfs_target_ids_write(struct file *file,
> > > +               const char __user *buf, size_t count, loff_t *ppos)
> > > +{
> > > +       struct damon_ctx *ctx = file->private_data;
> > > +       char *kbuf, *nrs;
> > > +       unsigned long *targets;
> > > +       ssize_t nr_targets;
> > > +       ssize_t ret = count;
> > > +       int i;
> > > +       int err;
> > > +
> > > +       kbuf = user_input_str(buf, count, ppos);
> > > +       if (IS_ERR(kbuf))
> > > +               return PTR_ERR(kbuf);
> > > +
> > > +       nrs = kbuf;
> > > +
> > > +       targets = str_to_target_ids(nrs, ret, &nr_targets);
> > > +       if (!targets) {
> > > +               ret = -ENOMEM;
> > > +               goto out;
> > > +       }
> > > +
> > > +       if (targetid_is_pid(ctx)) {
> > > +               for (i = 0; i < nr_targets; i++)
> > > +                       targets[i] = (unsigned long)find_get_pid(
> > > +                                       (int)targets[i]);
> > > +       }
> > > +
> > > +       mutex_lock(&ctx->kdamond_lock);
> > > +       if (ctx->kdamond) {
> > > +               ret = -EINVAL;
> > > +               goto unlock_out;
> > 
> > You need to put_pid on the targets array.
> 
> Good catch!
> 
> > 
> > > +       }
> > > +
> > > +       err = damon_set_targets(ctx, targets, nr_targets);
> > > +       if (err)
> > > +               ret = err;
> > 
> > You need to handle the partial failure from damon_set_targets().
> 
> My intention is to keep partial success as is.

But, we should put_pid() partial failures...  I will simply make this to
completely fail with no registered target.


Thanks,
SeongJae Park
[...]




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux