* [PATCH] Fix overbroad /proc/timer_list file permissions
@ 2008-11-25 22:44 Joe Korty
2008-11-25 23:14 ` [PATCH] Add per-cpu indexing to /proc/timer_list Joe Korty
0 siblings, 1 reply; 4+ messages in thread
From: Joe Korty @ 2008-11-25 22:44 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar; +Cc: linux-kernel
Fix overbroad file permissions on /proc/timer_list.
/proc/timer_list has 0644 permissions, this should be 0444.
Signed-off-by: Joe Korty <joe.korty@ccur.com>
Index: 2.6.28-rc6/kernel/time/timer_list.c
===================================================================
--- 2.6.28-rc6.orig/kernel/time/timer_list.c 2008-11-25 17:32:46.000000000 -0500
+++ 2.6.28-rc6/kernel/time/timer_list.c 2008-11-25 17:33:16.000000000 -0500
@@ -286,7 +286,7 @@
{
struct proc_dir_entry *pe;
- pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
+ pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
if (!pe)
return -ENOMEM;
return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Add per-cpu indexing to /proc/timer_list
2008-11-25 22:44 [PATCH] Fix overbroad /proc/timer_list file permissions Joe Korty
@ 2008-11-25 23:14 ` Joe Korty
2008-11-26 4:50 ` Alexey Dobriyan
0 siblings, 1 reply; 4+ messages in thread
From: Joe Korty @ 2008-11-25 23:14 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar; +Cc: linux-kernel
Per-cpu indexing of /proc/timer_list.
/proc/timer_list, potentially a very large file, is in
danger of overflowing its seq_file buffer. So 'split up'
the buffering on cpu ID boundaries. This should make this
file more likely to be useful on largish SMP systems.
The model followed is that in /proc/interrupts, which
splits up its buffering on (most) irq boundaries.
Signed-off-by: Joe Korty <joe.korty@ccur.com>
Index: 2.6.28-rc6/kernel/time/timer_list.c
===================================================================
--- 2.6.28-rc6.orig/kernel/time/timer_list.c 2008-11-25 17:50:43.000000000 -0500
+++ 2.6.28-rc6/kernel/time/timer_list.c 2008-11-25 18:03:44.000000000 -0500
@@ -250,36 +250,70 @@
static int timer_list_show(struct seq_file *m, void *v)
{
u64 now = ktime_to_ns(ktime_get());
- int cpu;
+ int i = *(loff_t *)v;
- SEQ_printf(m, "Timer List Version: v0.4\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);
-
- for_each_online_cpu(cpu)
- print_cpu(m, cpu, now);
-
- SEQ_printf(m, "\n");
- timer_list_show_tickdevices(m);
+ if (i == 0) {
+ SEQ_printf(m, "Timer List Version: v0.4\n");
+ SEQ_printf(m, "HRTIMER_MAX_CLOCK_BASES: %d\n",
+ HRTIMER_MAX_CLOCK_BASES);
+ SEQ_printf(m, "now at %lld nsecs\n",
+ (unsigned long long)now);
+ }
+
+ if (i < nr_cpu_ids) {
+ if (cpu_online(i))
+ print_cpu(m, i, now);
+ }
+
+ if (i == nr_cpu_ids) {
+ SEQ_printf(m, "\n");
+ timer_list_show_tickdevices(m);
+ }
return 0;
}
void sysrq_timer_list_show(void)
{
- timer_list_show(NULL, NULL);
+ int i;
+ for (i = 0; i <= nr_cpu_ids; i++) {
+ loff_t v = i;
+ timer_list_show(NULL, &v);
+ }
+}
+
+static void *timer_list_start(struct seq_file *m, loff_t *pos)
+{
+ return (*pos <= nr_cpu_ids) ? pos : NULL;
}
+static void *timer_list_next(struct seq_file *m, void *v, loff_t *pos)
+{
+ (*pos)++;
+ if (*pos > nr_cpu_ids)
+ return NULL;
+ return pos;
+}
+
+static void timer_list_stop(struct seq_file *m, void *v) { }
+
+static const struct seq_operations timer_list_seq_ops = {
+ .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 single_open(filp, timer_list_show, NULL);
+ return seq_open(filp, &timer_list_seq_ops);
}
static struct file_operations timer_list_fops = {
.open = timer_list_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = single_release,
+ .release = seq_release,
};
static int __init init_timer_list_procfs(void)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add per-cpu indexing to /proc/timer_list
2008-11-25 23:14 ` [PATCH] Add per-cpu indexing to /proc/timer_list Joe Korty
@ 2008-11-26 4:50 ` Alexey Dobriyan
2008-11-26 14:39 ` Joe Korty
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2008-11-26 4:50 UTC (permalink / raw)
To: Joe Korty; +Cc: Thomas Gleixner, Ingo Molnar, linux-kernel
On Tue, Nov 25, 2008 at 06:14:45PM -0500, Joe Korty wrote:
> Per-cpu indexing of /proc/timer_list.
>
> /proc/timer_list, potentially a very large file, is in
> danger of overflowing its seq_file buffer. So 'split up'
> the buffering on cpu ID boundaries. This should make this
> file more likely to be useful on largish SMP systems.
What do you mean?
You can't overflow seq_file buffer unless kmalloc() will fail large
allocation. And changing internals doesn't change amount of stuff
to be shown, which is the only thing which can lead to large buffer
need.
> The model followed is that in /proc/interrupts, which
> splits up its buffering on (most) irq boundaries.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add per-cpu indexing to /proc/timer_list
2008-11-26 4:50 ` Alexey Dobriyan
@ 2008-11-26 14:39 ` Joe Korty
0 siblings, 0 replies; 4+ messages in thread
From: Joe Korty @ 2008-11-26 14:39 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Thomas Gleixner, Ingo Molnar, linux-kernel
On Wed, Nov 26, 2008 at 07:50:04AM +0300, Alexey Dobriyan wrote:
> On Tue, Nov 25, 2008 at 06:14:45PM -0500, Joe Korty wrote:
> > Per-cpu indexing of /proc/timer_list.
> >
> > /proc/timer_list, potentially a very large file, is in
> > danger of overflowing its seq_file buffer. So 'split up'
> > the buffering on cpu ID boundaries. This should make this
> > file more likely to be useful on largish SMP systems.
>
> What do you mean?
>
> You can't overflow seq_file buffer unless kmalloc() will fail large
> allocation. And changing internals doesn't change amount of stuff
> to be shown, which is the only thing which can lead to large buffer
> need.
You're right, I missed the re-malloc part.
Joe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-11-26 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-25 22:44 [PATCH] Fix overbroad /proc/timer_list file permissions Joe Korty
2008-11-25 23:14 ` [PATCH] Add per-cpu indexing to /proc/timer_list Joe Korty
2008-11-26 4:50 ` Alexey Dobriyan
2008-11-26 14:39 ` Joe Korty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox