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> [rameezmustafa@codeaurora.org: Initialize variables in load_balance() to avoid crashes and inaccurate tracing.] Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org> [joonwoop@codeaurora.org: fixed minor conflict in include/trace/events/sched.h.] Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
This commit is contained in:
parent
387dcd0663
commit
521a572def
2 changed files with 59 additions and 3 deletions
|
@ -254,6 +254,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),
|
||||
|
|
|
@ -6966,10 +6966,10 @@ static int load_balance(int this_cpu, struct rq *this_rq,
|
|||
struct sched_domain *sd, enum cpu_idle_type idle,
|
||||
int *continue_balancing)
|
||||
{
|
||||
int ld_moved, cur_ld_moved, active_balance = 0;
|
||||
int ld_moved = 0, cur_ld_moved, active_balance = 0;
|
||||
struct sched_domain *sd_parent = sd->parent;
|
||||
struct sched_group *group;
|
||||
struct rq *busiest;
|
||||
struct sched_group *group = NULL;
|
||||
struct rq *busiest = NULL;
|
||||
unsigned long flags;
|
||||
struct cpumask *cpus = this_cpu_cpumask_var_ptr(load_balance_mask);
|
||||
|
||||
|
@ -6983,6 +6983,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
|
|||
.cpus = cpus,
|
||||
.fbq_type = all,
|
||||
.tasks = LIST_HEAD_INIT(env.tasks),
|
||||
.imbalance = 0,
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -7227,6 +7228,11 @@ out_one_pinned:
|
|||
|
||||
ld_moved = 0;
|
||||
out:
|
||||
trace_sched_load_balance(this_cpu, idle, *continue_balancing,
|
||||
group ? group->cpumask[0] : 0,
|
||||
busiest ? busiest->nr_running : 0,
|
||||
env.imbalance, env.flags, ld_moved,
|
||||
sd->balance_interval);
|
||||
return ld_moved;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue