Release 4.15 kernel/time/timer_list.c
/*
* kernel/time/timer_list.c
*
* List pending timers
*
* Copyright(C) 2006, Red Hat, Inc., Ingo Molnar
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/proc_fs.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/kallsyms.h>
#include <linux/nmi.h>
#include <linux/uaccess.h>
#include "tick-internal.h"
struct timer_list_iter {
int cpu;
bool second_pass;
u64 now;
};
typedef void (*print_fn_t)(struct seq_file *m, unsigned int *classes);
/*
* This allows printing both to /proc/timer_list and
* to the console (on SysRq-Q):
*/
__printf(2, 3)
static void SEQ_printf(struct seq_file *m, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (m)
seq_vprintf(m, fmt, args);
else
vprintk(fmt, args);
va_end(args);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Joe Perches | 48 | 88.89% | 1 | 50.00% |
Ingo Molnar | 6 | 11.11% | 1 | 50.00% |
Total | 54 | 100.00% | 2 | 100.00% |
static void print_name_offset(struct seq_file *m, void *sym)
{
char symname[KSYM_NAME_LEN];
if (lookup_symbol_name((unsigned long)sym, symname) < 0)
SEQ_printf(m, "<%pK>", sym);
else
SEQ_printf(m, "%s", symname);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 39 | 70.91% | 1 | 33.33% |
Alexey Dobriyan | 15 | 27.27% | 1 | 33.33% |
Kees Cook | 1 | 1.82% | 1 | 33.33% |
Total | 55 | 100.00% | 3 | 100.00% |
static void
print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *timer,
int idx, u64 now)
{
SEQ_printf(m, " #%d: ", idx);
print_name_offset(m, taddr);
SEQ_printf(m, ", ");
print_name_offset(m, timer->function);
SEQ_printf(m, ", S:%02x", timer->state);
SEQ_printf(m, "\n");
SEQ_printf(m, " # expires at %Lu-%Lu nsecs [in %Ld to %Ld nsecs]\n",
(unsigned long long)ktime_to_ns(hrtimer_get_softexpires(timer)),
(unsigned long long)ktime_to_ns(hrtimer_get_expires(timer)),
(long long)(ktime_to_ns(hrtimer_get_softexpires(timer)) - now),
(long long)(ktime_to_ns(hrtimer_get_expires(timer)) - now));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 109 | 76.76% | 1 | 20.00% |
Arjan van de Ven | 26 | 18.31% | 2 | 40.00% |
Thomas Gleixner | 7 | 4.93% | 2 | 40.00% |
Total | 142 | 100.00% | 5 | 100.00% |
static void
print_active_timers(struct seq_file *m, struct hrtimer_clock_base *base,
u64 now)
{
struct hrtimer *timer, tmp;
unsigned long next = 0, i;
struct timerqueue_node *curr;
unsigned long flags;
next_one:
i = 0;
touch_nmi_watchdog();
raw_spin_lock_irqsave(&base->cpu_base->lock, flags);
curr = timerqueue_getnext(&base->active);
/*
* Crude but we have to do this O(N*N) thing, because
* we have to unlock the base when printing:
*/
while (curr && i < next) {
curr = timerqueue_iterate_next(curr);
i++;
}
if (curr) {
timer = container_of(curr, struct hrtimer, node);
tmp = *timer;
raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);
print_timer(m, timer, &tmp, i, now);
next++;
goto next_one;
}
raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 146 | 90.12% | 1 | 20.00% |
John Stultz | 8 | 4.94% | 1 | 20.00% |
Thomas Gleixner | 5 | 3.09% | 2 | 40.00% |
Tom Hromatka | 3 | 1.85% | 1 | 20.00% |
Total | 162 | 100.00% | 5 | 100.00% |
static void
print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
{
SEQ_printf(m, " .base: %pK\n", base);
SEQ_printf(m, " .index: %d\n", base->index);
SEQ_printf(m, " .resolution: %u nsecs\n", hrtimer_resolution);
SEQ_printf(m, " .get_time: ");
print_name_offset(m, base->get_time);
SEQ_printf(m, "\n");
#ifdef CONFIG_HIGH_RES_TIMERS
SEQ_printf(m, " .offset: %Lu nsecs\n",
(unsigned long long) ktime_to_ns(base->offset));
#endif
SEQ_printf(m, "active timers:\n");
print_active_timers(m, base, now + ktime_to_ns(base->offset));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 94 | 79.66% | 1 | 16.67% |
Thomas Gleixner | 10 | 8.47% | 2 | 33.33% |
John Stultz | 7 | 5.93% | 1 | 16.67% |
David S. Miller | 6 | 5.08% | 1 | 16.67% |
Kees Cook | 1 | 0.85% | 1 | 16.67% |
Total | 118 | 100.00% | 6 | 100.00% |
static void print_cpu(struct seq_file *m, int cpu, u64 now)
{
struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
int i;
SEQ_printf(m, "cpu: %d\n", cpu);
for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
SEQ_printf(m, " clock %d:\n", i);
print_base(m, cpu_base->clock_base + i, now);
}
#define P(x) \
SEQ_printf(m, " .%-15s: %Lu\n", #x, \
(unsigned long long)(cpu_base->x))
#define P_ns(x) \
SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \
(unsigned long long)(ktime_to_ns(cpu_base->x)))
#ifdef CONFIG_HIGH_RES_TIMERS
P_ns(expires_next);
P(hres_active);
P(nr_events);
P(nr_retries);
P(nr_hangs);
P(max_hang_time);
#endif
#undef P
#undef P_ns
#ifdef CONFIG_TICK_ONESHOT
# define P(x) \
SEQ_printf(m, " .%-15s: %Lu\n", #x, \
(unsigned long long)(ts->x))
# define P_ns(x) \
SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \
(unsigned long long)(ktime_to_ns(ts->x)))
{
struct tick_sched *ts = tick_get_tick_sched(cpu);
P(nohz_mode);
P_ns(last_tick);
P(tick_stopped);
P(idle_jiffies);
P(idle_calls);
P(idle_sleeps);
P_ns(idle_entrytime);
P_ns(idle_waketime);
P_ns(idle_exittime);
P_ns(idle_sleeptime);
P_ns(iowait_sleeptime);
P(last_jiffies);
P(next_timer);
P_ns(idle_expires);
SEQ_printf(m, "jiffies: %Lu\n",
(unsigned long long)jiffies);
}
#endif
#undef P
#undef P_ns
SEQ_printf(m, "\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 218 | 81.95% | 1 | 10.00% |
Thomas Gleixner | 26 | 9.77% | 4 | 40.00% |
David S. Miller | 8 | 3.01% | 1 | 10.00% |
Nathan Zimmer | 7 | 2.63% | 1 | 10.00% |
Arjan van de Ven | 5 | 1.88% | 1 | 10.00% |
Vegard Nossum | 1 | 0.38% | 1 | 10.00% |
Frédéric Weisbecker | 1 | 0.38% | 1 | 10.00% |
Total | 266 | 100.00% | 10 | 100.00% |
#ifdef CONFIG_GENERIC_CLOCKEVENTS
static void
print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
{
struct clock_event_device *dev = td->evtdev;
touch_nmi_watchdog();
SEQ_printf(m, "Tick Device: mode: %d\n", td->mode);
if (cpu < 0)
SEQ_printf(m, "Broadcast device\n");
else
SEQ_printf(m, "Per CPU device: %d\n", cpu);
SEQ_printf(m, "Clock Event Device: ");
if (!dev) {
SEQ_printf(m, "<NULL>\n");
return;
}
SEQ_printf(m, "%s\n", dev->name);
SEQ_printf(m, " max_delta_ns: %llu\n",
(unsigned long long) dev->max_delta_ns);
SEQ_printf(m, " min_delta_ns: %llu\n",
(unsigned long long) dev->min_delta_ns);
SEQ_printf(m, " mult: %u\n", dev->mult);
SEQ_printf(m, " shift: %u\n", dev->shift);
SEQ_printf(m, " mode: %d\n", clockevent_get_state(dev));
SEQ_printf(m, " next_event: %Ld nsecs\n",
(unsigned long long) ktime_to_ns(dev->next_event));
SEQ_printf(m, " set_next_event: ");
print_name_offset(m, dev->set_next_event);
SEQ_printf(m, "\n");
if (dev->set_state_shutdown) {
SEQ_printf(m, " shutdown: ");
print_name_offset(m, dev->set_state_shutdown);
SEQ_printf(m, "\n");
}
if (dev->set_state_periodic) {
SEQ_printf(m, " periodic: ");
print_name_offset(m, dev->set_state_periodic);
SEQ_printf(m, "\n");
}
if (dev->set_state_oneshot) {
SEQ_printf(m, " oneshot: ");
print_name_offset(m, dev->set_state_oneshot);
SEQ_printf(m, "\n");
}
if (dev->set_state_oneshot_stopped) {
SEQ_printf(m, " oneshot stopped: ");
print_name_offset(m, dev->set_state_oneshot_stopped);
SEQ_printf(m, "\n");
}
if (dev->tick_resume) {
SEQ_printf(m, " resume: ");
print_name_offset(m, dev->tick_resume);
SEQ_printf(m, "\n");
}
SEQ_printf(m, " event_handler: ");
print_name_offset(m, dev->event_handler);
SEQ_printf(m, "\n");
SEQ_printf(m, " retries: %lu\n", dev->retries);
SEQ_printf(m, "\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 182 | 45.27% | 1 | 7.69% |
Viresh Kumar | 158 | 39.30% | 5 | 38.46% |
Thomas Gleixner | 39 | 9.70% | 3 | 23.08% |
Jon Hunter | 12 | 2.99% | 1 | 7.69% |
Nathan Zimmer | 7 | 1.74% | 1 | 7.69% |
Tom Hromatka | 3 | 0.75% | 1 | 7.69% |
Vegard Nossum | 1 | 0.25% | 1 | 7.69% |
Total | 402 | 100.00% | 13 | 100.00% |
static void timer_list_show_tickdevices_header(struct seq_file *m)
{
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
print_tickdevice(m, tick_get_broadcast_device(), -1);
SEQ_printf(m, "tick_broadcast_mask: %*pb\n",
cpumask_pr_args(tick_get_broadcast_mask()));
#ifdef CONFIG_TICK_ONESHOT
SEQ_printf(m, "tick_broadcast_oneshot_mask: %*pb\n",
cpumask_pr_args(tick_get_broadcast_oneshot_mask()));
#endif
SEQ_printf(m, "\n");
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 53 | 81.54% | 1 | 20.00% |
Preeti U. Murthy | 4 | 6.15% | 1 | 20.00% |
Rusty Russell | 4 | 6.15% | 1 | 20.00% |
Thomas Gleixner | 3 | 4.62% | 1 | 20.00% |
Nathan Zimmer | 1 | 1.54% | 1 | 20.00% |
Total | 65 | 100.00% | 5 | 100.00% |
#endif
static inline void timer_list_header(struct seq_file *m, u64 now)
{
SEQ_printf(m, "Timer List Version: v0.8\n");
SEQ_printf(m, "HRTIMER_MAX_CLOCK_BASES: %d\n", HRTIMER_MAX_CLOCK_BASES);
SEQ_printf(m, "now at %Ld nsecs\n", (unsigned long long)now);
SEQ_printf(m, "\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 38 | 73.08% | 1 | 25.00% |
Nathan Zimmer | 13 | 25.00% | 2 | 50.00% |
Thomas Gleixner | 1 | 1.92% | 1 | 25.00% |
Total | 52 | 100.00% | 4 | 100.00% |
static int timer_list_show(struct seq_file *m, void *v)
{
struct timer_list_iter *iter = v;
if (iter->cpu == -1 && !iter->second_pass)
timer_list_header(m, iter->now);
else if (!iter->second_pass)
print_cpu(m, iter->cpu, iter->now);
#ifdef CONFIG_GENERIC_CLOCKEVENTS
else if (iter->cpu == -1 && iter->second_pass)
timer_list_show_tickdevices_header(m);
else
print_tickdevice(m, tick_get_device(iter->cpu), iter->cpu);
#endif
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nathan Zimmer | 89 | 80.91% | 3 | 75.00% |
Ingo Molnar | 21 | 19.09% | 1 | 25.00% |
Total | 110 | 100.00% | 4 | 100.00% |
void sysrq_timer_list_show(void)
{
u64 now = ktime_to_ns(ktime_get());
int cpu;
timer_list_header(NULL, now);
for_each_online_cpu(cpu)
print_cpu(NULL, cpu, now);
#ifdef CONFIG_GENERIC_CLOCKEVENTS
timer_list_show_tickdevices_header(NULL);
for_each_online_cpu(cpu)
print_tickdevice(NULL, tick_get_device(cpu), cpu);
#endif
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nathan Zimmer | 53 | 80.30% | 1 | 50.00% |
Ingo Molnar | 13 | 19.70% | 1 | 50.00% |
Total | 66 | 100.00% | 2 | 100.00% |
static void *move_iter(struct timer_list_iter *iter, loff_t offset)
{
for (; offset; offset--) {
iter->cpu = cpumask_next(iter->cpu, cpu_online_mask);
if (iter->cpu >= nr_cpu_ids) {
#ifdef CONFIG_GENERIC_CLOCKEVENTS
if (!iter->second_pass) {
iter->cpu = -1;
iter->second_pass = true;
} else
return NULL;
#else
return NULL;
#endif
}
}
return iter;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nathan Zimmer | 87 | 100.00% | 2 | 100.00% |
Total | 87 | 100.00% | 2 | 100.00% |
static void *timer_list_start(struct seq_file *file, loff_t *offset)
{
struct timer_list_iter *iter = file->private;
if (!*offset)
iter->now = ktime_to_ns(ktime_get());
iter->cpu = -1;
iter->second_pass = false;
return move_iter(iter, *offset);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nathan Zimmer | 63 | 100.00% | 2 | 100.00% |
Total | 63 | 100.00% | 2 | 100.00% |
static void *timer_list_next(struct seq_file *file, void *v, loff_t *offset)
{
struct timer_list_iter *iter = file->private;
++*offset;
return move_iter(iter, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nathan Zimmer | 41 | 100.00% | 2 | 100.00% |
Total | 41 | 100.00% | 2 | 100.00% |
static void timer_list_stop(struct seq_file *seq, void *v)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nathan Zimmer | 14 | 100.00% | 1 | 100.00% |
Total | 14 | 100.00% | 1 | 100.00% |
static const struct seq_operations timer_list_sops = {
.start = timer_list_start,
.next = timer_list_next,
.stop = timer_list_stop,
.show = timer_list_show,
};
static int timer_list_open(struct inode *inode, struct file *filp)
{
return seq_open_private(filp, &timer_list_sops,
sizeof(struct timer_list_iter));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 23 | 74.19% | 1 | 50.00% |
Nathan Zimmer | 8 | 25.81% | 1 | 50.00% |
Total | 31 | 100.00% | 2 | 100.00% |
static const struct file_operations timer_list_fops = {
.open = timer_list_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_private,
};
static int __init init_timer_list_procfs(void)
{
struct proc_dir_entry *pe;
pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
if (!pe)
return -ENOMEM;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 36 | 90.00% | 2 | 66.67% |
Denis V. Lunev | 4 | 10.00% | 1 | 33.33% |
Total | 40 | 100.00% | 3 | 100.00% |
__initcall(init_timer_list_procfs);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 1056 | 55.55% | 2 | 4.88% |
Nathan Zimmer | 426 | 22.41% | 3 | 7.32% |
Viresh Kumar | 158 | 8.31% | 5 | 12.20% |
Thomas Gleixner | 92 | 4.84% | 13 | 31.71% |
Joe Perches | 54 | 2.84% | 1 | 2.44% |
Arjan van de Ven | 31 | 1.63% | 3 | 7.32% |
Alexey Dobriyan | 16 | 0.84% | 2 | 4.88% |
John Stultz | 15 | 0.79% | 2 | 4.88% |
David S. Miller | 14 | 0.74% | 1 | 2.44% |
Jon Hunter | 12 | 0.63% | 1 | 2.44% |
Tom Hromatka | 9 | 0.47% | 1 | 2.44% |
Preeti U. Murthy | 4 | 0.21% | 1 | 2.44% |
Rusty Russell | 4 | 0.21% | 1 | 2.44% |
Denis V. Lunev | 4 | 0.21% | 1 | 2.44% |
Kees Cook | 2 | 0.11% | 1 | 2.44% |
Vegard Nossum | 2 | 0.11% | 1 | 2.44% |
Frédéric Weisbecker | 1 | 0.05% | 1 | 2.44% |
Linus Torvalds | 1 | 0.05% | 1 | 2.44% |
Total | 1901 | 100.00% | 41 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.