All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 2/2] tracing: Do not copy hash if O_TRUNC is set
Date: Wed, 11 Jun 2014 10:05:24 -0400	[thread overview]
Message-ID: <20140611100524.295efcce@gandalf.local.home> (raw)
In-Reply-To: <1402474014-28655-2-git-send-email-namhyung@kernel.org>

On Wed, 11 Jun 2014 17:06:54 +0900
Namhyung Kim <namhyung@kernel.org> wrote:

> When a filter file is open for writing and O_TRUNC is set, there's no
> need to copy and free the filter entries.
> 

Nice cleanup. I'll add it for 3.17.

Thanks,

-- Steve

> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  kernel/trace/ftrace.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index ddfda763ded7..13885590a184 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -2759,7 +2759,13 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag,
>  		hash = ops->filter_hash;
>  
>  	if (file->f_mode & FMODE_WRITE) {
> -		iter->hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, hash);
> +		const int size_bits = FTRACE_HASH_DEFAULT_BITS;
> +
> +		if (file->f_flags & O_TRUNC)
> +			iter->hash = alloc_ftrace_hash(size_bits);
> +		else
> +			iter->hash = alloc_and_copy_ftrace_hash(size_bits, hash);
> +
>  		if (!iter->hash) {
>  			trace_parser_put(&iter->parser);
>  			kfree(iter);
> @@ -2768,10 +2774,6 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag,
>  		}
>  	}
>  
> -	if ((file->f_mode & FMODE_WRITE) &&
> -	    (file->f_flags & O_TRUNC))
> -		ftrace_filter_reset(iter->hash);
> -
>  	if (file->f_mode & FMODE_READ) {
>  		iter->pg = ftrace_pages_start;
>  


  reply	other threads:[~2014-06-11 14:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11  8:06 [PATCH 1/2] tracing: Fix memory leak on failure path in ftrace_allocate_pages() Namhyung Kim
2014-06-11  8:06 ` [PATCH 2/2] tracing: Do not copy hash if O_TRUNC is set Namhyung Kim
2014-06-11 14:05   ` Steven Rostedt [this message]
2014-06-11 14:03 ` [PATCH 1/2] tracing: Fix memory leak on failure path in ftrace_allocate_pages() Steven Rostedt
2014-06-12  1:08   ` Namhyung Kim

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=20140611100524.295efcce@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.