tracing: fixes for 2.6.32
Subsystems (2)
Steven Rostedt
maintainerIngo,
Please pull the latest tip/tracing/core tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core
Carsten Emde (3):
tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce
tracing: remove unused local variables in tracer probe functions
tracing: do not update tracing_max_latency when tracer is stopped
----
include/trace/events/block.h | 4 +++- kernel/trace/trace.c | 5 +++++ kernel/trace/trace.h | 1 + kernel/trace/trace_irqsoff.c | 16 ++++------------ kernel/trace/trace_sched_wakeup.c | 16 ++++------------ 5 files changed, 17 insertions(+), 25 deletions(-)
Steven Rostedt
maintainerPATCH 2/3 tracing: remove unused local variables in tracer probe functions
From: Carsten Emde <[email protected]>
When the nsecs_to_usecs() conversion in probe_wakeup_sched_switch() and check_critical_timing() was moved to a later stage in order to avoid unnecessary computing, it was overlooked to remove the original variables, assignments and comments..
--- kernel/trace/trace_irqsoff.c | 12 +----------- kernel/trace/trace_sched_wakeup.c | 10 ---------- 2 files changed, 1 insertions(+), 21 deletions(-)
kernel/trace/trace_irqsoff.c +1 -11
@@ -129,15 +129,10 @@ check_critical_timing(struct trace_array *tr, unsigned long parent_ip, int cpu) { -unsigned long latency, t0, t1;cycle_t T0 ,T1 , delta;unsigned long flags;int pc; -/* -* usecs conversion is slow so we try to delay the conversion -* as long as possible: -*/ T0 = data->preempt_timestamp;T1 =ftrace_now (cpu); delta =T1 -T0 ;
@@ -157,17 +152,12 @@ check_critical_timing(struct trace_array *tr,trace_function (tr,CALLER_ADDR0 , parent_ip, flags, pc); - latency =nsecs_to_usecs (delta); -if (data->critical_sequence != max_sequence) goto out_unlock; - tracing_max_latency = delta; - t0 =nsecs_to_usecs (T0 ); - t1 =nsecs_to_usecs (T1 ); - data->critical_end = parent_ip; + tracing_max_latency = delta;update_max_tr_single (tr, current, cpu); max_sequence++;
kernel/trace/trace_sched_wakeup.c +0 -10
@@ -110,7 +110,6 @@ static void notrace probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next) { - unsigned long latency = 0, t0 = 0, t1 = 0; struct trace_array_cpu *data;cycle_t T0 ,T1 , delta;unsigned long flags;
@@ -156,10 +155,6 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,trace_function (wakeup_trace,CALLER_ADDR0 ,CALLER_ADDR1 , flags, pc);tracing_sched_switch_trace (wakeup_trace, prev, next, flags, pc); -/* -* usecs conversion is slow so we try to delay the conversion -* as long as possible: -*/ T0 = data->preempt_timestamp;T1 =ftrace_now (cpu); delta =T1 -T0 ;
@@ -167,12 +162,7 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,if (!report_latency (delta)) goto out_unlock; - latency =nsecs_to_usecs (delta); - tracing_max_latency = delta; - t0 =nsecs_to_usecs (T0 ); - t1 =nsecs_to_usecs (T1 ); -update_max_tr (wakeup_trace, wakeup_task, wakeup_cpu); out_unlock:
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 3/3 tracing: do not update tracing_max_latency when tracer is stopped
In reply to Steven RostedtFrom: Carsten Emde <[email protected]>
The state of the function pair tracing_stop()/tracing_start() is correctly considered when tracer data are updated. However, the global and externally accessible variable tracing_max_latency is always updated
- even when tracing is stopped.
The update should only occur, if tracing was not stopped.
--- kernel/trace/trace.c | 5 +++++ kernel/trace/trace.h | 1 + kernel/trace/trace_irqsoff.c | 6 ++++-- kernel/trace/trace_sched_wakeup.c | 6 ++++-- 4 files changed, 14 insertions(+), 4 deletions(-)
kernel/trace/trace.c +5 -0
@@ -825,6 +825,11 @@ static void trace_init_cmdlines(void) cmdline_idx =0 ; } +int is_tracing_stopped (void ) +{ +return trace_stop_count; +} +/** * ftrace_off_permanent - disable all ftrace code permanently *
kernel/trace/trace.h +1 -0
@@ -461,6 +461,7 @@ void tracing_stop_sched_switch_record(void);void tracing_start_sched_switch_record (void );int register_tracer (struct tracer *type);void unregister_tracer (struct tracer *type); +int is_tracing_stopped (void );extern unsigned long nsecs_to_usecs (unsigned long nsecs);
kernel/trace/trace_irqsoff.c +4 -2
@@ -157,8 +157,10 @@ check_critical_timing(struct trace_array *tr, data->critical_end = parent_ip; - tracing_max_latency = delta; -update_max_tr_single (tr, current, cpu); +if (likely (!is_tracing_stopped ())) { + tracing_max_latency = delta; +update_max_tr_single (tr, current, cpu); + } max_sequence++;
kernel/trace/trace_sched_wakeup.c +4 -2
@@ -162,8 +162,10 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,if (!report_latency (delta)) goto out_unlock; - tracing_max_latency = delta; -update_max_tr (wakeup_trace, wakeup_task, wakeup_cpu); +if (likely (!is_tracing_stopped ())) { + tracing_max_latency = delta; +update_max_tr (wakeup_trace, wakeup_task, wakeup_cpu); + } out_unlock:__wakeup_reset (wakeup_trace);
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 1/3 tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce
In reply to Steven RostedtFrom: Carsten Emde <[email protected]>
Booting 2.6.31 and executing
echo 1 >/sys/kernel/debug/tracing/events/enable
leads to
BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<c032a583>] ftrace_raw_event_block_bio_bounce+0x4b/0xb9
Apparently,
bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask);
is called in block/blk-map.c:58 where bio->bi_bdev in set to NULL and still is NULL when an attempt is made to evaluate bio->bi_bdev->bd_dev in include/trace/events/block.h:189.
The tracepoint should ensure bio->bi_bdev is not dereferenced, if NULL.
LKML-Reference: <[email protected]>
--- include/trace/events/block.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
include/trace/events/block.h +3 -1
@@ -171,6 +171,7 @@ TRACE_EVENT(block_rq_complete, (unsigned long long )__entry->sector, __entry->nr_sector, __entry->errors) ); + TRACE_EVENT(block_bio_bounce, TP_PROTO(struct request_queue *q, struct bio *bio),
@@ -186,7 +187,8 @@ TRACE_EVENT(block_bio_bounce, ),TP_fast_assign ( - __entry->dev = bio->bi_bdev->bd_dev; + __entry->dev = bio->bi_bdev ? + bio->bi_bdev->bd_dev : 0; __entry->sector = bio->bi_sector; __entry->nr_sector = bio->bi_size >>9 ;blk_fill_rwbs (__entry->rwbs, bio->bi_rw, bio->bi_size);
Signature · 3 lines
1.6.3.3 --