mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Ingo Molnar <mingo@redhat.com>,
	yrl.pp-manager.tt@hitachi.com
Subject: Re: [PATCH ftrace/core V5] ftrace: Introduce saved_cmdlines_size file
Date: Mon, 09 Jun 2014 17:21:12 +0900	[thread overview]
Message-ID: <871tuycx3b.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <20140605012427.22115.16173.stgit@yunodevel> (Yoshihiro YUNOMAE's message of "Thu, 05 Jun 2014 10:24:27 +0900")

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)/

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;
> +}

  reply	other threads:[~2014-06-09  8:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05  1:24 Yoshihiro YUNOMAE
2014-06-09  8:21 ` Namhyung Kim [this message]
2014-06-09 13:48   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871tuycx3b.fsf@sejong.aot.lge.com \
    --to=namhyung@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=yoshihiro.yunomae.ez@hitachi.com \
    --cc=yrl.pp-manager.tt@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®