public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Steven Rostedt <srostedt@redhat.com>
Subject: Re: [PATCH 1/8] trace: remove deprecated entry->cpu
Date: Sun, 8 Feb 2009 13:29:11 +0100	[thread overview]
Message-ID: <20090208122910.GA6130@nowhere> (raw)
In-Reply-To: <20090208055340.560398185@goodmis.org>

On Sun, Feb 08, 2009 at 12:49:56AM -0500, Steven Rostedt wrote:
> From: Steven Rostedt <srostedt@redhat.com>
> 
> Impact: fix to prevent developers from using entry->cpu
> 
> With the new ring buffer infrastructure, the cpu for the entry is
> implicit with which CPU buffer it is on.
> 
> The original code use to record the current cpu into the generic
> entry header, which can be retrieved by entry->cpu. When the
> ring buffer was introduced, the users were convert to use the
> the cpu number of which cpu ring buffer was in use (this was passed
> to the tracers by the iterator: iter->cpu).
> 
> Unfortunately, the cpu item in the entry structure was never removed.
> This allowed for developers to use it instead of the proper iter->cpu,
> unknowingly, using an uninitialized variable. This was not the fault
> of the developers, since it would seem like the logical place to
> retrieve the cpu identifier.
> 
> This patch removes the cpu item from the entry structure and fixes
> all the users that should have been using iter->cpu.
> 
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>



Heh, we have sent the same patch at very few different hours...
Funny :-)


> ---
>  kernel/trace/trace.c             |    2 +-
>  kernel/trace/trace.h             |    1 -
>  kernel/trace/trace_hw_branches.c |    3 +--
>  kernel/trace/trace_output.c      |    6 +++---
>  4 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index fd51cf0..bd4d9f8 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1531,7 +1531,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
>  
>  	if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
>  		SEQ_PUT_FIELD_RET(s, entry->pid);
> -		SEQ_PUT_FIELD_RET(s, entry->cpu);
> +		SEQ_PUT_FIELD_RET(s, iter->cpu);
>  		SEQ_PUT_FIELD_RET(s, iter->ts);
>  	}
>  
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index f0c7a0f..5efc4c7 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -45,7 +45,6 @@ enum trace_type {
>   */
>  struct trace_entry {
>  	unsigned char		type;
> -	unsigned char		cpu;
>  	unsigned char		flags;
>  	unsigned char		preempt_count;
>  	int			pid;
> diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c
> index fff3545..549238a 100644
> --- a/kernel/trace/trace_hw_branches.c
> +++ b/kernel/trace/trace_hw_branches.c
> @@ -159,7 +159,7 @@ static enum print_line_t bts_trace_print_line(struct trace_iterator *iter)
>  	trace_assign_type(it, entry);
>  
>  	if (entry->type == TRACE_HW_BRANCHES) {
> -		if (trace_seq_printf(seq, "%4d  ", entry->cpu) &&
> +		if (trace_seq_printf(seq, "%4d  ", iter->cpu) &&
>  		    seq_print_ip_sym(seq, it->to, symflags) &&
>  		    trace_seq_printf(seq, "\t  <-  ") &&
>  		    seq_print_ip_sym(seq, it->from, symflags) &&
> @@ -195,7 +195,6 @@ void trace_hw_branch(u64 from, u64 to)
>  	entry	= ring_buffer_event_data(event);
>  	tracing_generic_entry_update(&entry->ent, 0, from);
>  	entry->ent.type = TRACE_HW_BRANCHES;
> -	entry->ent.cpu = cpu;
>  	entry->from = from;
>  	entry->to   = to;
>  	ring_buffer_unlock_commit(tr->buffer, event, irq2);
> diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
> index b7380ee..463a310 100644
> --- a/kernel/trace/trace_output.c
> +++ b/kernel/trace/trace_output.c
> @@ -333,7 +333,7 @@ int trace_print_context(struct trace_iterator *iter)
>  	unsigned long secs = (unsigned long)t;
>  
>  	return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ",
> -				comm, entry->pid, entry->cpu, secs, usec_rem);
> +				comm, entry->pid, iter->cpu, secs, usec_rem);
>  }
>  
>  int trace_print_lat_context(struct trace_iterator *iter)
> @@ -356,7 +356,7 @@ int trace_print_lat_context(struct trace_iterator *iter)
>  		char *comm = trace_find_cmdline(entry->pid);
>  		ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08lx]"
>  				       " %ld.%03ldms (+%ld.%03ldms): ", comm,
> -				       entry->pid, entry->cpu, entry->flags,
> +				       entry->pid, iter->cpu, entry->flags,
>  				       entry->preempt_count, iter->idx,
>  				       ns2usecs(iter->ts),
>  				       abs_usecs / USEC_PER_MSEC,
> @@ -364,7 +364,7 @@ int trace_print_lat_context(struct trace_iterator *iter)
>  				       rel_usecs / USEC_PER_MSEC,
>  				       rel_usecs % USEC_PER_MSEC);
>  	} else {
> -		ret = lat_print_generic(s, entry, entry->cpu);
> +		ret = lat_print_generic(s, entry, iter->cpu);
>  		if (ret)
>  			ret = lat_print_timestamp(s, abs_usecs, rel_usecs);
>  	}
> -- 
> 1.5.6.5
> 
> -- 


  reply	other threads:[~2009-02-08 12:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-08  5:49 [PATCH 0/8] git pull request for tip/tracing/core Steven Rostedt
2009-02-08  5:49 ` [PATCH 1/8] trace: remove deprecated entry->cpu Steven Rostedt
2009-02-08 12:29   ` Frederic Weisbecker [this message]
2009-02-08  5:49 ` [PATCH 2/8] ring-buffer: add NMI protection for spinlocks Steven Rostedt
2009-02-08  5:49 ` [PATCH 3/8] ring-buffer: allow tracing_off to be used in core kernel code Steven Rostedt
2009-02-08  5:49 ` [PATCH 4/8] ftrace, x86: rename in_nmi variable Steven Rostedt
2009-02-08  5:50 ` [PATCH 5/8] nmi: add generic nmi tracking state Steven Rostedt
2009-02-08  5:50 ` [PATCH 6/8] ftrace: change function graph tracer to use new in_nmi Steven Rostedt
2009-02-08  5:50 ` [PATCH 7/8] ring-buffer: use generic version of in_nmi Steven Rostedt
2009-02-08  5:50 ` [PATCH 8/8] trace: trivial fixes in comment typos Steven Rostedt
2009-02-09  9:37 ` [PATCH 0/8] git pull request for tip/tracing/core Ingo Molnar
2009-02-11 15:36   ` Ingo Molnar
2009-02-11 15:46     ` Steven Rostedt
2009-02-11 16:25       ` Ingo Molnar
2009-02-11 16:33         ` Steven Rostedt
2009-02-11 16:49     ` Steven Rostedt
2009-02-11 16:59       ` Steven Rostedt
2009-02-11 17:16         ` Ingo Molnar
2009-02-11 17:30           ` Steven Rostedt
2009-02-11 17:31             ` Ingo Molnar
2009-02-11 17:57               ` Luck, Tony
2009-02-11 18:23                 ` Steven Rostedt
2009-02-11 18:34                   ` Luck, Tony
2009-02-11 18:42                     ` Steven Rostedt
2009-02-11 20:20                       ` Ingo Molnar
2009-02-11 20:39                 ` Jack Steiner
2009-02-12  2:39                 ` Kenji Kaneshige
2009-02-12  2:43                   ` Steven Rostedt
2009-02-12  3:15                     ` Kenji Kaneshige
2009-02-12  3:22                       ` 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=20090208122910.GA6130@nowhere \
    --to=fweisbec@gmail.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    --cc=tglx@linutronix.de \
    /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