Skip to content

Commit

Permalink
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/tip/linux-2.6-tip

* 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86, ds, bts: cleanup/fix DS configuration
  ring-buffer: reset timestamps when ring buffer is reset
  trace: set max latency variable to zero on default
  trace: stop all recording to ring buffer on ftrace_dump
  trace: print ftrace_dump at KERN_EMERG log level
  ring_buffer: reset write when reserve buffer fail
  tracing/function-graph-tracer: fix a regression while suspend to disk
  ring-buffer: fix alignment problem
  • Loading branch information
Linus Torvalds committed Jan 31, 2009
2 parents e81cfd2 + ba2607f commit f649043
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
31 changes: 17 additions & 14 deletions arch/x86/kernel/ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* - buffer allocation (memory accounting)
*
*
* Copyright (C) 2007-2008 Intel Corporation.
* Markus Metzger <markus.t.metzger@intel.com>, 2007-2008
* Copyright (C) 2007-2009 Intel Corporation.
* Markus Metzger <markus.t.metzger@intel.com>, 2007-2009
*/


Expand Down Expand Up @@ -890,7 +890,7 @@ int ds_set_pebs_reset(struct pebs_tracer *tracer, u64 value)
}

static const struct ds_configuration ds_cfg_netburst = {
.name = "netburst",
.name = "Netburst",
.ctl[dsf_bts] = (1 << 2) | (1 << 3),
.ctl[dsf_bts_kernel] = (1 << 5),
.ctl[dsf_bts_user] = (1 << 6),
Expand All @@ -904,7 +904,7 @@ static const struct ds_configuration ds_cfg_netburst = {
#endif
};
static const struct ds_configuration ds_cfg_pentium_m = {
.name = "pentium m",
.name = "Pentium M",
.ctl[dsf_bts] = (1 << 6) | (1 << 7),

.sizeof_field = sizeof(long),
Expand All @@ -915,8 +915,8 @@ static const struct ds_configuration ds_cfg_pentium_m = {
.sizeof_rec[ds_pebs] = sizeof(long) * 18,
#endif
};
static const struct ds_configuration ds_cfg_core2 = {
.name = "core 2",
static const struct ds_configuration ds_cfg_core2_atom = {
.name = "Core 2/Atom",
.ctl[dsf_bts] = (1 << 6) | (1 << 7),
.ctl[dsf_bts_kernel] = (1 << 9),
.ctl[dsf_bts_user] = (1 << 10),
Expand Down Expand Up @@ -949,19 +949,22 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
switch (c->x86) {
case 0x6:
switch (c->x86_model) {
case 0 ... 0xC:
/* sorry, don't know about them */
break;
case 0xD:
case 0xE: /* Pentium M */
case 0x9:
case 0xd: /* Pentium M */
ds_configure(&ds_cfg_pentium_m);
break;
default: /* Core2, Atom, ... */
ds_configure(&ds_cfg_core2);
case 0xf:
case 0x17: /* Core2 */
case 0x1c: /* Atom */
ds_configure(&ds_cfg_core2_atom);
break;
case 0x1a: /* i7 */
default:
/* sorry, don't know about them */
break;
}
break;
case 0xF:
case 0xf:
switch (c->x86_model) {
case 0x0:
case 0x1:
Expand Down
27 changes: 27 additions & 0 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/clocksource.h>
#include <linux/kallsyms.h>
#include <linux/seq_file.h>
#include <linux/suspend.h>
#include <linux/debugfs.h>
#include <linux/hardirq.h>
#include <linux/kthread.h>
Expand Down Expand Up @@ -1965,6 +1966,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
#ifdef CONFIG_FUNCTION_GRAPH_TRACER

static atomic_t ftrace_graph_active;
static struct notifier_block ftrace_suspend_notifier;

int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
{
Expand Down Expand Up @@ -2043,13 +2045,37 @@ static int start_graph_tracing(void)
return ret;
}

/*
* Hibernation protection.
* The state of the current task is too much unstable during
* suspend/restore to disk. We want to protect against that.
*/
static int
ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
void *unused)
{
switch (state) {
case PM_HIBERNATION_PREPARE:
pause_graph_tracing();
break;

case PM_POST_HIBERNATION:
unpause_graph_tracing();
break;
}
return NOTIFY_DONE;
}

int register_ftrace_graph(trace_func_graph_ret_t retfunc,
trace_func_graph_ent_t entryfunc)
{
int ret = 0;

mutex_lock(&ftrace_sysctl_lock);

ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
register_pm_notifier(&ftrace_suspend_notifier);

atomic_inc(&ftrace_graph_active);
ret = start_graph_tracing();
if (ret) {
Expand All @@ -2075,6 +2101,7 @@ void unregister_ftrace_graph(void)
ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
ftrace_graph_entry = ftrace_graph_entry_stub;
ftrace_shutdown(FTRACE_STOP_FUNC_RET);
unregister_pm_notifier(&ftrace_suspend_notifier);

mutex_unlock(&ftrace_sysctl_lock);
}
Expand Down
15 changes: 9 additions & 6 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static inline int test_time_stamp(u64 delta)
return 0;
}

#define BUF_PAGE_SIZE (PAGE_SIZE - sizeof(struct buffer_data_page))
#define BUF_PAGE_SIZE (PAGE_SIZE - offsetof(struct buffer_data_page, data))

/*
* head_page == tail_page && head == tail then buffer is empty.
Expand Down Expand Up @@ -1025,12 +1025,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
}

if (next_page == head_page) {
if (!(buffer->flags & RB_FL_OVERWRITE)) {
/* reset write */
if (tail <= BUF_PAGE_SIZE)
local_set(&tail_page->write, tail);
if (!(buffer->flags & RB_FL_OVERWRITE))
goto out_unlock;
}

/* tail_page has not moved yet? */
if (tail_page == cpu_buffer->tail_page) {
Expand Down Expand Up @@ -1105,6 +1101,10 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
return event;

out_unlock:
/* reset write */
if (tail <= BUF_PAGE_SIZE)
local_set(&tail_page->write, tail);

__raw_spin_unlock(&cpu_buffer->lock);
local_irq_restore(flags);
return NULL;
Expand Down Expand Up @@ -2174,6 +2174,9 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)

cpu_buffer->overrun = 0;
cpu_buffer->entries = 0;

cpu_buffer->write_stamp = 0;
cpu_buffer->read_stamp = 0;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE)

unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX;
unsigned long __read_mostly tracing_max_latency;
unsigned long __read_mostly tracing_thresh;

/*
Expand Down Expand Up @@ -3736,7 +3736,7 @@ static struct notifier_block trace_die_notifier = {
* it if we decide to change what log level the ftrace dump
* should be at.
*/
#define KERN_TRACE KERN_INFO
#define KERN_TRACE KERN_EMERG

static void
trace_printk_seq(struct trace_seq *s)
Expand Down Expand Up @@ -3770,6 +3770,7 @@ void ftrace_dump(void)
dump_ran = 1;

/* No turning back! */
tracing_off();
ftrace_kill();

for_each_tracing_cpu(cpu) {
Expand Down
1 change: 1 addition & 0 deletions kernel/trace/trace_irqsoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ static void stop_irqsoff_tracer(struct trace_array *tr)

static void __irqsoff_tracer_init(struct trace_array *tr)
{
tracing_max_latency = 0;
irqsoff_trace = tr;
/* make sure that the tracer is visible */
smp_wmb();
Expand Down
1 change: 1 addition & 0 deletions kernel/trace/trace_sched_wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ static void stop_wakeup_tracer(struct trace_array *tr)

static int wakeup_tracer_init(struct trace_array *tr)
{
tracing_max_latency = 0;
wakeup_trace = tr;
start_wakeup_tracer(tr);
return 0;
Expand Down

0 comments on commit f649043

Please sign in to comment.