From: "Michael Kerrisk" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Joe Korty <joe.korty-oXJCJecloQs@public.gmane.org>
Cc: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] create /proc/timer-wheel-list
Date: Tue, 25 Nov 2008 11:06:44 -0500 [thread overview]
Message-ID: <517f3f820811250806n33850ea8ua8e203347c0f7ba6@mail.gmail.com> (raw)
In-Reply-To: <20081121221113.GA13566-jPwT5PJblzyhckIl5yWhCw@public.gmane.org>
Joe,
On Fri, Nov 21, 2008 at 5:11 PM, Joe Korty <joe.korty-oXJCJecloQs@public.gmane.org> wrote:
> Create /proc/timer_wheel_list.
>
> This does for the timer wheel what /proc/timer_list
> does for hrtimers -- provide a way of displaying what
> timers are running on what cpus, and their attributes.
Please CC linux-api on kernel-userland API changes.
See Documentation/SubmitChecklist and
http://thread.gmane.org/gmane.linux.ltp/5658.
Cheers,
Michael
> Index: 2.6.28-rc6/kernel/timer.c
> ===================================================================
> --- 2.6.28-rc6.orig/kernel/timer.c 2008-11-21 17:02:04.000000000 -0500
> +++ 2.6.28-rc6/kernel/timer.c 2008-11-21 17:04:25.000000000 -0500
> @@ -36,6 +36,8 @@
> #include <linux/syscalls.h>
> #include <linux/delay.h>
> #include <linux/tick.h>
> +#include <linux/proc_fs.h>
> +#include <linux/seq_file.h>
> #include <linux/kallsyms.h>
>
> #include <asm/uaccess.h>
> @@ -1568,6 +1570,113 @@
> open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
> }
>
> +#ifdef CONFIG_PROC_FS
> +
> +static void seq_printf_symbol(struct seq_file *m, void *symaddr, int width)
> +{
> + char symname[KSYM_NAME_LEN];
> + int stat, len = m->count;
> +
> + if (lookup_symbol_name((unsigned long)symaddr, symname) < 0)
> + stat = seq_printf(m, "<%p>", symaddr);
> + else
> + stat = seq_printf(m, "%s", symname);
> + if (width && stat == 0) {
> + len += (width - m->count);
> + if (len > 0)
> + seq_printf(m, "%*s", len, " ");
> + }
> +}
> +
> +static void print_single_timer(struct seq_file *m, struct timer_list *timer)
> +{
> + unsigned long base_jiffies = tbase_get_base(timer->base)->timer_jiffies;
> +
> + seq_printf(m, " %p - ", (void *)(timer->expires - base_jiffies));
> + seq_printf_symbol(m, timer->function, 24);
> + seq_printf(m, " (data ");
> + seq_printf_symbol(m, (void *)(timer->data), 24);
> + seq_printf(m, ")");
> +#ifdef CONFIG_TIMER_STATS
> + seq_printf(m, " from ");
> + seq_printf_symbol(m, timer->start_site, 28);
> + seq_printf(m, " %*s/%d",
> + TASK_COMM_LEN, timer->start_comm,
> + timer->start_pid);
> +#endif
> + seq_printf(m, "\n");
> +}
> +
> +static void print_timer_list(struct seq_file *m, struct list_head *head)
> +{
> + struct timer_list *timer;
> + struct list_head *item;
> +
> + for (item = head->next; item != head; item = item->next) {
> + timer = list_entry(item, struct timer_list, entry);
> + print_single_timer(m, timer);
> + }
> +}
> +
> +static void print_cpu_timers(struct seq_file *m, int cpu)
> +{
> + int i;
> + struct tvec_base *base = per_cpu(tvec_bases, cpu);
> +
> + spin_lock_irq(&base->lock);
> + seq_printf(m, "\ncpu: %d, base jiffies: %p\n\n",
> + cpu, (void *)(base->timer_jiffies));
> +
> + for (i = 0; i < TVR_SIZE; i++)
> + print_timer_list(m, base->tv1.vec + i);
> + for (i = 0; i < TVN_SIZE; i++) {
> + print_timer_list(m, base->tv2.vec + i);
> + print_timer_list(m, base->tv3.vec + i);
> + print_timer_list(m, base->tv4.vec + i);
> + print_timer_list(m, base->tv5.vec + i);
> + }
> + spin_unlock_irq(&base->lock);
> +}
> +
> +static int timer_list_show(struct seq_file *m, void *v)
> +{
> + int cpu;
> +
> + seq_printf(m, "Timer Wheel List Version: 1\n");
> + seq_printf(m, "Jiffies: %px\n", (void *)jiffies);
> +
> + for_each_online_cpu(cpu) {
> + print_cpu_timers(m, cpu);
> + }
> +
> + return 0;
> +}
> +
> +static int timer_list_open(struct inode *inode, struct file *filp)
> +{
> + return single_open(filp, timer_list_show, NULL);
> +}
> +
> +static struct file_operations timer_list_fops = {
> + .open = timer_list_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +static int __init init_timer_list_procfs(void)
> +{
> + struct proc_dir_entry *pe;
> +
> + pe = proc_create("timer_wheel_list", 0444, NULL, &timer_list_fops);
> + if (!pe)
> + return -ENOMEM;
> + return 0;
> +}
> +late_initcall(init_timer_list_procfs);
> +
> +#endif /* CONFIG_PROC_FS */
> +
> /**
> * msleep - sleep safely even with waitqueue interruptions
> * @msecs: Time in milliseconds to sleep for
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Michael Kerrisk Linux man-pages maintainer;
http://www.kernel.org/doc/man-pages/ Found a documentation bug?
http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next parent reply other threads:[~2008-11-25 16:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081121221113.GA13566@tsunami.ccur.com>
[not found] ` <20081121221113.GA13566-jPwT5PJblzyhckIl5yWhCw@public.gmane.org>
2008-11-25 16:06 ` Michael Kerrisk [this message]
2008-11-25 18:57 ` [PATCH] Display active jiffie timers in /proc/timer_list Joe Korty
[not found] ` <20081125185740.GA21806-jPwT5PJblzyhckIl5yWhCw@public.gmane.org>
2008-11-25 21:36 ` Thomas Gleixner
[not found] ` <alpine.LFD.2.00.0811252224430.3235-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-11-25 22:23 ` Joe Korty
2008-11-25 22:53 ` Thomas Gleixner
2008-11-26 16:48 ` [PATCH] Display active jiffie timers in /proc/timer_list, v2 Joe Korty
[not found] ` <20081126164845.GA17394-jPwT5PJblzyhckIl5yWhCw@public.gmane.org>
2008-11-26 17:07 ` Greg KH
[not found] ` <20081126170715.GA28422-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-11-26 17:34 ` Joe Korty
[not found] ` <20081126173410.GA17879-jPwT5PJblzyhckIl5yWhCw@public.gmane.org>
2008-11-26 17:39 ` Greg KH
[not found] ` <20081126173931.GA1636-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-11-26 21:06 ` [PATCH] ABI Documentation for /proc/timer_list Joe Korty
[not found] ` <20081126210613.GA20529-jPwT5PJblzyhckIl5yWhCw@public.gmane.org>
2008-11-28 21:37 ` Michael Kerrisk
[not found] ` <cfd18e0f0811281337j57166b4cv54e05296a779252e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-12-01 18:11 ` [PATCH] ABI Documentation for /proc/timer_list, v2 Joe Korty
2008-12-05 17:12 ` Randy Dunlap
[not found] ` <493960F2.6070102-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2008-12-05 19:01 ` Joe Korty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=517f3f820811250806n33850ea8ua8e203347c0f7ba6@mail.gmail.com \
--to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=joe.korty-oXJCJecloQs@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-X9Un+BFzKDI@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).