Skip to content

Commit

Permalink
sched debug: BKL usage statistics
Browse files Browse the repository at this point in the history
add per task and per rq BKL usage statistics.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Ingo Molnar committed Oct 15, 2007
1 parent de8d585 commit b8efb56
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ struct sched_info {
/* timestamps */
unsigned long long last_arrival,/* when we last ran on a cpu */
last_queued; /* when we were last queued to run */
#ifdef CONFIG_SCHEDSTATS
/* BKL stats */
unsigned long bkl_cnt;
#endif
};
#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */

Expand Down
9 changes: 9 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ struct rq {
/* try_to_wake_up() stats */
unsigned long ttwu_cnt;
unsigned long ttwu_local;

/* BKL stats */
unsigned long bkl_cnt;
#endif
struct lock_class_key rq_lock_key;
};
Expand Down Expand Up @@ -3414,6 +3417,12 @@ static inline void schedule_debug(struct task_struct *prev)
profile_hit(SCHED_PROFILING, __builtin_return_address(0));

schedstat_inc(this_rq(), sched_cnt);
#ifdef CONFIG_SCHEDSTATS
if (unlikely(prev->lock_depth >= 0)) {
schedstat_inc(this_rq(), bkl_cnt);
schedstat_inc(prev, sched_info.bkl_cnt);
}
#endif
}

/*
Expand Down
4 changes: 4 additions & 0 deletions kernel/sched_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
SPLIT_NS(spread0));
SEQ_printf(m, " .%-30s: %ld\n", "nr_running", cfs_rq->nr_running);
SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight);
SEQ_printf(m, " .%-30s: %ld\n", "bkl_cnt",
rq->bkl_cnt);
}

static void print_cpu(struct seq_file *m, int cpu)
Expand Down Expand Up @@ -323,6 +325,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
PN(se.exec_max);
PN(se.slice_max);
PN(se.wait_max);
P(sched_info.bkl_cnt);
#endif
SEQ_printf(m, "%-25s:%20Ld\n",
"nr_switches", (long long)(p->nvcsw + p->nivcsw));
Expand Down Expand Up @@ -350,6 +353,7 @@ void proc_sched_set_task(struct task_struct *p)
p->se.exec_max = 0;
p->se.slice_max = 0;
p->se.wait_max = 0;
p->sched_info.bkl_cnt = 0;
#endif
p->se.sum_exec_runtime = 0;
p->se.prev_sum_exec_runtime = 0;
Expand Down

0 comments on commit b8efb56

Please sign in to comment.