Skip to contentSkip to conversation

Scalable statistics counters

PATCH In review Ravikiran G Thirumalai 3 participants 6 messages Aug 12, 2002 – Aug 13, 2002 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Scalable statistics counters

Hi Andrew,
Here is the new statctr patch with some of the changes suggested by Christoph. Do you think the foll patch is ready to get into the mainline kernel now? If so, will you forward this to Linus or shall I send the patch to him? The following patch works on 2.5.31. I will be mailing out the 2.5.31 version of Dipankar's kmalloc_percpu dynamic memory allocator in a separate mail (since statctrs depend on them ).

Thanks,
Kiran

fs/proc/proc_misc.c +1 -1
diff -ruN -X dontdiff linux-2.5.31/fs/proc/proc_misc.c statctr-2.5.31/fs/proc/proc_misc.c
@@ -63,7 +63,7 @@
 extern int get_ds1286_status(char *);
 #endif
 
-static int proc_calc_metrics(char *page, char **start, off_t off,
+int proc_calc_metrics(char *page, char **start, off_t off,
 				 int count, int *eof, int len)
 {
 	if (len <= off+count) *eof = 1;
fs/proc/root.c +2 -0
diff -ruN -X dontdiff linux-2.5.31/fs/proc/root.c statctr-2.5.31/fs/proc/root.c
@@ -19,6 +19,7 @@
 #include <linux/smp_lock.h>
 
 struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
+struct proc_dir_entry *proc_statistics;
 
 #ifdef CONFIG_SYSCTL
 struct proc_dir_entry *proc_sys_root;
@@ -77,6 +78,7 @@
 	proc_rtas_init();
 #endif
 	proc_bus = proc_mkdir("bus", 0);
+	proc_statistics = proc_mkdir("statistics", 0);
 }
 
 static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry)
include/linux/proc_fs.h +1 -0
diff -ruN -X dontdiff linux-2.5.31/include/linux/proc_fs.h statctr-2.5.31/include/linux/proc_fs.h
@@ -101,6 +101,7 @@
 extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
 
 extern int proc_match(int, const char *,struct proc_dir_entry *);
+extern int proc_calc_metrics(char *, char **, off_t, int, int *, int);
 
 /*
  * These are generic /proc routines that use the internal
include/linux/statctr.h +254 -0

254 lines not on this page · raw message

kernel/Makefile +3 -2
diff -ruN -X dontdiff linux-2.5.31/kernel/Makefile statctr-2.5.31/kernel/Makefile
@@ -10,12 +10,13 @@
 O_TARGET := kernel.o
 
 export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \
-		printk.o platform.o suspend.o dma.o
+		printk.o platform.o suspend.o dma.o statctr.o
 
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    module.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o context.o futex.o platform.o
+	    signal.o sys.o kmod.o context.o futex.o platform.o \
+	    statctr.o
 
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o
kernel/statctr.c +211 -0

211 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Ravikiran G Thirumalai

Hi Andrew,
Here is the new statctr patch with some of the changes suggested by Christoph. Do you think the foll patch is ready to get into the mainline kernel now? If so, will you forward this to Linus or shall I send the patch to him? The following patch works on 2.5.31. I will be mailing out the 2.5.31 version of Dipankar's kmalloc_percpu dynamic memory allocator in a separate mail (since statctrs depend on them ).

But you ignored the most important suggestion. Using proc_calc_metrics() in new code is a mistake. It's a sign you want to use the seq_file interface. And exporting it outside proc_misc.c is an even bigger mistake.

#2 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 7 lines · Ravikiran G Thirumalai

Hi Andrew,
Here is the new statctr patch with some of the changes suggested by Christoph. Do you think the foll patch is ready to get into the mainline kernel now? If so, will you forward this to Linus or shall I send the patch to him? The following patch works on 2.5.31. I will be mailing out the 2.5.31 version of Dipankar's kmalloc_percpu dynamic memory allocator in a separate mail (since statctrs depend on them ).

Quoted 3 lines

But you ignored the most important suggestion. Using proc_calc_metrics() in new code is a mistake. It's a sign you want to use the seq_file interface. And exporting it outside proc_misc.c is an even bigger mistake.

Christoph,

Suppose I use seq_file interface and not put all statctrs in one /proc file, how do I associate the statctr data structure with the /proc inode ? IOW, how do I quickly get the statctr_pentry corresponding to the counter in statctr_open() ?

Thanks

Signature · 2 lines
Dipankar Sarma  <[email protected]> http://lse.sourceforge.net
Linux Technology Center, IBM Software Lab, Bangalore, India.
#3 lore raw
Quoted 4 lines · Dipankar Sarma

Suppose I use seq_file interface and not put all statctrs in one /proc file, how do I associate the statctr data structure with the /proc inode ? IOW, how do I quickly get the statctr_pentry corresponding to the counter in statctr_open() ?

Stuff it into the ->private member of struct seq_file in your open method. BTW, what about renaming statctr_pentry to statctr_group?

#4 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Dipankar Sarma

Suppose I use seq_file interface and not put all statctrs in one /proc file, how do I associate the statctr data structure with the /proc inode ? IOW, how do I quickly get the statctr_pentry corresponding to the counter in statctr_open() ?

Stuff it into the ->private member of struct seq_file in your open method.

Yes, that I learnt by looking at mounts_open(), the problem is how do I get the statctr_pentry (or statctr_group if you like) in the open method ? It seems to me that in order to do this, we need the following -

1. An exported wrapper create_statctr_entry() around create_seq_entry() code that sticks the statctr_group pointer into proc_entry->data.
2. Some way to get the proc entry from the inode in statctr_open() and stick it to seq_file->private for seq_file methods to use.

Is this understanding correct or is there a better and simpler way to do this ?

Thanks

Signature · 2 lines
Dipankar Sarma  <[email protected]> http://lse.sourceforge.net
Linux Technology Center, IBM Software Lab, Bangalore, India.
#5 lore raw
Quoted 6 lines · Dipankar Sarma

...
Yes, that I learnt by looking at mounts_open(), the problem is how do I get the statctr_pentry (or statctr_group if you like) in the open method ? It seems to me that in order to do this, we need the following -

Quoted 9 lines

1. An exported wrapper create_statctr_entry() around create_seq_entry() code that sticks the statctr_group pointer into proc_entry->data.
2. Some way to get the proc entry from the inode in statctr_open() and stick it to seq_file->private for seq_file methods to use.

Is this understanding correct or is there a better and simpler way to do this ?

Christoph,
I have used the above mentioned method now, alongwith the PDE macro to get the proc_dir_entry from the inode. I'll post the patch after testing it..

Thanks,
Kiran