Re: [PATCH ftrace/core V5] ftrace: Introduce saved_cmdlines_size file

From: Steven Rostedt
Date: Mon Jun 09 2014 - 09:48:37 EST


On Mon, 09 Jun 2014 17:21:12 +0900
Namhyung Kim <namhyung@xxxxxxxxx> wrote:

> Hi Yoshihiro,
>
> Sorry for being late, but just wanna give you some (minor) feedbacks..
>
>
> On Thu, 05 Jun 2014 10:24:27 +0900, Yoshihiro YUNOMAE wrote:
> > +static int trace_create_savedcmd(void)
> > +{
> > + int ret;
> > +
> > + savedcmd = kmalloc(sizeof(struct saved_cmdlines_buffer), GFP_KERNEL);
>
> s/sizeof(struct saved_cmdlines_buffer)/sizeof(*savedcmd)/
>
>
> > + if (!savedcmd)
> > + return -ENOMEM;
> > +
> > + ret = allocate_cmdlines_buffer(SAVED_CMDLINES_DEFAULT, savedcmd);
> > + if (ret < 0) {
> > + kfree(savedcmd);
> > + savedcmd = NULL;
> > + return -ENOMEM;
> > + }
> > +
> > + return 0;
> > }
>
> [SNIP]
> > static ssize_t
> > +tracing_saved_cmdlines_size_read(struct file *filp, char __user *ubuf,
> > + size_t cnt, loff_t *ppos)
> > +{
> > + char buf[64];
> > + int r;
> > +
> > + arch_spin_lock(&trace_cmdline_lock);
> > + r = sprintf(buf, "%u\n", savedcmd->cmdline_num);
>
> In general, it's better to use scnprintf() instead.
>
>
> > + arch_spin_unlock(&trace_cmdline_lock);
> > +
> > + return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
> > +}
> > +
> > +static void free_saved_cmdlines_buffer(struct saved_cmdlines_buffer *s)
> > +{
> > + kfree(s->saved_cmdlines);
> > + kfree(s->map_cmdline_to_pid);
> > + kfree(s);
> > +}
> > +
> > +static int tracing_resize_saved_cmdlines(unsigned int val)
> > +{
> > + struct saved_cmdlines_buffer *s, *savedcmd_temp;
> > +
> > + s = kmalloc(sizeof(struct saved_cmdlines_buffer), GFP_KERNEL);
>
> s/sizeof(struct saved_cmdlines_buffer)/sizeof(*s)/
>

I already pushed this to Linus. He hasn't pulled yet, but if you want
to send a patch against my ftrace/core, I'll add that. These are minor
enough to get into the merge window still.

-- Steve


> Thanks,
> Namhyung
>
>
> > + if (!s)
> > + return -ENOMEM;
> > +
> > + if (allocate_cmdlines_buffer(val, s) < 0) {
> > + kfree(s);
> > + return -ENOMEM;
> > + }
> > +
> > + arch_spin_lock(&trace_cmdline_lock);
> > + savedcmd_temp = savedcmd;
> > + savedcmd = s;
> > + arch_spin_unlock(&trace_cmdline_lock);
> > + free_saved_cmdlines_buffer(savedcmd_temp);
> > +
> > + return 0;
> > +}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/