Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 162940
b: refs/heads/master
c: 478142c
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Sep 10, 2009
1 parent 3606669 commit 2e9c67d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d8eeb2d3b26d25c44c10f28430e2157a2d20bd1d
refs/heads/master: 478142c39c8c2f5f63038e5f2224e6729406e587
36 changes: 22 additions & 14 deletions trunk/kernel/trace/trace_sched_wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static int __read_mostly tracer_enabled;

static struct task_struct *wakeup_task;
static int wakeup_cpu;
static int wakeup_current_cpu;
static unsigned wakeup_prio = -1;
static int wakeup_rt;

Expand Down Expand Up @@ -56,33 +57,23 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
resched = ftrace_preempt_disable();

cpu = raw_smp_processor_id();
if (cpu != wakeup_current_cpu)
goto out_enable;

data = tr->data[cpu];
disabled = atomic_inc_return(&data->disabled);
if (unlikely(disabled != 1))
goto out;

local_irq_save(flags);
__raw_spin_lock(&wakeup_lock);

if (unlikely(!wakeup_task))
goto unlock;

/*
* The task can't disappear because it needs to
* wake up first, and we have the wakeup_lock.
*/
if (task_cpu(wakeup_task) != cpu)
goto unlock;

trace_function(tr, ip, parent_ip, flags, pc);

unlock:
__raw_spin_unlock(&wakeup_lock);
local_irq_restore(flags);

out:
atomic_dec(&data->disabled);

out_enable:
ftrace_preempt_enable(resched);
}

Expand All @@ -107,6 +98,14 @@ static int report_latency(cycle_t delta)
return 1;
}

static void probe_wakeup_migrate_task(struct task_struct *task, int cpu)
{
if (task != wakeup_task)
return;

wakeup_current_cpu = cpu;
}

static void notrace
probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
Expand Down Expand Up @@ -244,6 +243,7 @@ probe_wakeup(struct rq *rq, struct task_struct *p, int success)
__wakeup_reset(wakeup_trace);

wakeup_cpu = task_cpu(p);
wakeup_current_cpu = wakeup_cpu;
wakeup_prio = p->prio;

wakeup_task = p;
Expand Down Expand Up @@ -293,6 +293,13 @@ static void start_wakeup_tracer(struct trace_array *tr)
goto fail_deprobe_wake_new;
}

ret = register_trace_sched_migrate_task(probe_wakeup_migrate_task);
if (ret) {
pr_info("wakeup trace: Couldn't activate tracepoint"
" probe to kernel_sched_migrate_task\n");
return;
}

wakeup_reset(tr);

/*
Expand Down Expand Up @@ -325,6 +332,7 @@ static void stop_wakeup_tracer(struct trace_array *tr)
unregister_trace_sched_switch(probe_wakeup_sched_switch);
unregister_trace_sched_wakeup_new(probe_wakeup);
unregister_trace_sched_wakeup(probe_wakeup);
unregister_trace_sched_migrate_task(probe_wakeup_migrate_task);
}

static int __wakeup_tracer_init(struct trace_array *tr)
Expand Down

0 comments on commit 2e9c67d

Please sign in to comment.