tracing/sched: add load balancer tracepoint

When doing performance analysis it can be useful to see exactly
what is going on with the load balancer - when it runs and why
exactly it may not be redistributing load.

This additional tracepoint will show the idle context of the
load balance operation (idle, not idle, newly idle), various
values from the load balancing operation, the final result,
and the new balance interval.

Change-Id: I1538c411c5f9d17d7d37d84ead6210756be2d884
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
This commit is contained in:
Steve Muckle 2013-11-19 14:16:53 -08:00
parent 442d78071b
commit 26126dd5dc
2 changed files with 56 additions and 1 deletions

View File

@ -245,6 +245,56 @@ TRACE_EVENT(sched_cpu_hotplug,
__entry->status ? "online" : "offline", __entry->error)
);
/*
* Tracepoint for load balancing:
*/
#if NR_CPUS > 32
#error "Unsupported NR_CPUS for lb tracepoint."
#endif
TRACE_EVENT(sched_load_balance,
TP_PROTO(int cpu, enum cpu_idle_type idle, int balance,
unsigned long group_mask, int busiest_nr_running,
unsigned long imbalance, unsigned int env_flags, int ld_moved,
unsigned int balance_interval),
TP_ARGS(cpu, idle, balance, group_mask, busiest_nr_running,
imbalance, env_flags, ld_moved, balance_interval),
TP_STRUCT__entry(
__field( int, cpu)
__field( enum cpu_idle_type, idle)
__field( int, balance)
__field( unsigned long, group_mask)
__field( int, busiest_nr_running)
__field( unsigned long, imbalance)
__field( unsigned int, env_flags)
__field( int, ld_moved)
__field( unsigned int, balance_interval)
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->idle = idle;
__entry->balance = balance;
__entry->group_mask = group_mask;
__entry->busiest_nr_running = busiest_nr_running;
__entry->imbalance = imbalance;
__entry->env_flags = env_flags;
__entry->ld_moved = ld_moved;
__entry->balance_interval = balance_interval;
),
TP_printk("cpu=%d state=%s balance=%d group=%#lx busy_nr=%d imbalance=%ld flags=%#x ld_moved=%d bal_int=%d",
__entry->cpu,
__entry->idle == CPU_IDLE ? "idle" :
(__entry->idle == CPU_NEWLY_IDLE ? "newly_idle" : "busy"),
__entry->balance,
__entry->group_mask, __entry->busiest_nr_running,
__entry->imbalance, __entry->env_flags, __entry->ld_moved,
__entry->balance_interval)
);
DECLARE_EVENT_CLASS(sched_process_template,
TP_PROTO(struct task_struct *p),

View File

@ -5027,7 +5027,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
{
int ld_moved, cur_ld_moved, active_balance = 0;
struct sched_group *group;
struct rq *busiest;
struct rq *busiest = NULL;
unsigned long flags;
struct cpumask *cpus = __get_cpu_var(load_balance_mask);
@ -5249,6 +5249,11 @@ out_one_pinned:
ld_moved = 0;
out:
trace_sched_load_balance(this_cpu, idle, *balance,
group ? group->cpumask[0] : 0,
busiest ? busiest->nr_running : 0,
env.imbalance, env.flags, ld_moved,
sd->balance_interval);
return ld_moved;
}