conditionally re-enable per-disk stats, convert to seq_file
Subsystems (3)
PATCH 1/1 conditionally re-enable per-disk stats, convert to seq_file
This patch against 2.4.20-pre1 converts /proc/partitions to the seq_file interface as in 2.5, makes it report the sard-style extended disk statistics condititional on CONFIG_BLK_STATS and disables the gathering of those totally otherwise to not waste memory and processing power.
This patch is based on the concept of Kurt's statistics patch, although it is implemented very differently to avoid #ifdef hell.
Documentation/Configure.help +11 -0
@@ -531,6 +531,17 @@ CONFIG_BLK_DEV_NBD If unsure, say N. +Per partition statistics in /proc/partitions +CONFIG_BLK_STATS + If you say yes here, your kernel will keep statistical information + for every partition. The information includes things as numbers of + read and write accesses, thenumber of merged requests etc. + + This is required for the full functionality of sar(8) and interesting + if you want to do performance tuning, by tweaking the elevator, e.g. + + If unsure, say N. + ATA/IDE/MFM/RLL support CONFIG_IDE If you say Y here, your kernel will be able to manage low cost mass
drivers/block/Config.in +2 -0
@@ -48,4 +48,6 @@ if [ "$CONFIG_BLK_DEV_RAM" = "y" -o "$CO fi dep_bool ' Initial RAM disk (initrd) support' CONFIG_BLK_DEV_INITRD $CONFIG_BLK_DEV_RAM +bool 'Per partition statistics in /proc/partitions' CONFIG_BLK_STATS + endmenu
drivers/block/genhd.c +69 -33
138 lines not on this page · raw message
drivers/block/ll_rw_blk.c +38 -21
121 lines not on this page · raw message
fs/proc/proc_misc.c +13 -10
@@ -55,7 +55,6 @@ extern int get_stram_list(char *);extern int get_module_list (char *);#endif extern int get_device_list (char *); -extern int get_partition_list (char *,char **,off_t ,int );extern int get_filesystem_list (char *);extern int get_exec_domain_list (char *);extern int get_irq_list (char *);
@@ -254,6 +253,18 @@ static int stram_read_proc(char *page, c }#endif +extern struct seq_operations partitions_op; +static int partitions_open (struct inode *inode,struct file *file) +{ +return seq_open (file, &partitions_op); +} +static struct file_operations proc_partitions_operations = { + open: partitions_open, + read: seq_read, + llseek: seq_lseek, + release: seq_release, +}; +#ifdef CONFIG_MODULES static int modules_read_proc (char *page,char **start,off_t off,int count,int *eof,void *data)
@@ -377,14 +388,6 @@ static int devices_read_proc(char *page,return proc_calc_metrics (page, start, off, count, eof, len); } -static int partitions_read_proc (char *page,char **start,off_t off, -int count,int *eof,void *data) -{ -int len =get_partition_list (page, start, off, count); -if (len < count) *eof =1 ; -return len; -} -#if !defined(CONFIG_ARCH_S390 )static int interrupts_read_proc (char *page,char **start,off_t off,int count,int *eof,void *data)
@@ -561,7 +564,6 @@ void __init proc_misc_init(void)#endif {"stat", kstat_read_proc}, {"devices", devices_read_proc}, - {"partitions", partitions_read_proc}, #if !defined(CONFIG_ARCH_S390) {"interrupts", interrupts_read_proc}, #endif
@@ -588,6 +590,7 @@ void __init proc_misc_init(void)if (entry) entry->proc_fops = &proc_kmsg_operations;create_seq_entry ("cpuinfo" ,0 , &proc_cpuinfo_operations); +create_seq_entry ("partitions" ,0 , &proc_partitions_operations);create_seq_entry ("slabinfo" ,S_IWUSR |S_IRUGO ,&proc_slabinfo_operations);#ifdef CONFIG_MODULES create_seq_entry ("ksyms" ,0 , &proc_ksyms_operations);
include/linux/genhd.h +13 -8
@@ -62,8 +62,8 @@ struct hd_struct {unsigned long start_sect;unsigned long nr_sects;devfs_handle_t de;/* primary (master) devfs entry */ -int number;/* stupid old code wastes space */ +#ifdef CONFIG_BLK_STATS /* Performance stats: */ unsigned int ios_in_flight;unsigned int io_ticks;
@@ -79,6 +79,7 @@ struct hd_struct {unsigned int wr_merges;unsigned int wr_ticks;unsigned int wr_sectors; +#endif /* CONFIG_BLK_STATS */ };#define GENHD_FL_REMOVABLE 1
@@ -259,18 +260,22 @@ struct unixware_disklabel {char *disk_name (struct gendisk *hd,int minor,char *buf); -/* -* disk_round_stats is used to round off the IO statistics for a disk -* for a complete clock tick. -*/ -void disk_round_stats (struct hd_struct *hd); -/* * Account for the completion of an IO request (used by drivers which * bypass the normal end_request processing) */ struct request ; -void req_finished_io (struct request *); + +#ifdef CONFIG_BLK_STATS +extern void disk_round_stats (struct hd_struct *hd); +extern void req_new_io (struct request *req,int merge,int sectors); +extern void req_merged_io (struct request *req); +extern void req_finished_io (struct request *req); +#else +static inline void req_new_io (struct request *req,int merge,int sectors) { } +static inline void req_merged_io (struct request *req) { } +static inline void req_finished_io (struct request *req) { } +#endif /* CONFIG_BLK_STATS */ extern void devfs_register_partitions (struct gendisk *dev,int minor,int unregister);
Hi Christoph,
Quoted 7 lines · Christoph Hellwig
This patch against 2.4.20-pre1 converts
/proc/partitionsto theseq_fileinterface as in 2.5, makes it report the sard-style extended disk statistics condititional onCONFIG_BLK_STATSand disables the gathering of those totally otherwise to not waste memory and processing power.This patch is based on the concept of Kurt's statistics patch, although it is implemented very differently to avoid #ifdef hell.
Actually, I was expecting criticism due to the ifdef stuff I did and was prepared to come up with something better. But I also learned never to put effort into something before being asked to ...
Your patch looks fine to me. Thanks for preparing it!
Regards,
Signature · 4 lines
Kurt Garloff <[email protected]> [Eindhoven, NL] Physics: Plasma simulations <[email protected]> [TU Eindhoven, NL] Linux: SCSI, Security <[email protected]> [SuSE Nuernberg, DE] (See mail header or public key servers for PGP2 and GPG public keys.)
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines
This patch against 2.4.20-pre1 converts
/proc/partitionsto theseq_fileinterface as in 2.5, makes it report the sard-style extended disk statistics condititional onCONFIG_BLK_STATSand disables the gathering of those totally otherwise to not waste memory and processing power.
But why in /proc/partitions ?
Maybe /proc/partitions can go away eventually with all info available under driverfs or so. But for the time being, /proc/partitions is used, and some changes are planned to make identification of the devices involved easier.
It is really ugly to stuff a lot of garbage into a file just because it happens to exist already. If you want disk statistics, why not put it in /proc/diskstatistics?
Andries
Quoted 8 lines · Andries Brouwer
But why in
/proc/partitions?
Maybe/proc/partitionscan go away eventually with all info available under driverfs or so. But for the time being,/proc/partitionsis used, and some changes are planned to make identification of the devices involved easier.
It is really ugly to stuff a lot of garbage into a file just because it happens to exist already. If you want disk statistics, why not put it in/proc/diskstatistics?
Because it's where existing tools expect it. I agree with you that we want a nicer interface for 2.6, but give the userbase some time to prepare for a new interface.
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Andries Brouwer
But why in
/proc/partitions?
Maybe/proc/partitionscan go away eventually with all info available under driverfs or so. But for the time being,/proc/partitionsis used, and some changes are planned to make identification of the devices involved easier.
It is really ugly to stuff a lot of garbage into a file just because it happens to exist already. If you want disk statistics, why not put it in/proc/diskstatistics?
Quoted 3 lines
Because it's where existing tools expect it. I agree with you that we want a nicer interface for 2.6, but give the userbase some time to prepare for a new interface.
You create a mess in the official kernel because your user space tools are broken? And it is easier to patch the kernel than to fix them, even though you'll have to fix them eventually?
And fixing these tools consists of replacing one filename?
On Wed, 7 Aug 2002, Andries Brouwer wrote:
| | > On Tue, Aug 06, 2002 at 04:08:48PM +0200, Christoph Hellwig wrote: | > > This patch against 2.4.20-pre1 converts /proc/partitions to the seq_file | > > interface as in 2.5, makes it report the sard-style extended disk | > > statistics condititional on CONFIG_BLK_STATS and disables the gathering | > > of those totally otherwise to not waste memory and processing power. | | But why in /proc/partitions ? | Maybe /proc/partitions can go away eventually with all info available | under driverfs or so. But for the time being, /proc/partitions is used, | and some changes are planned to make identification of the devices | involved easier. | It is really ugly to stuff a lot of garbage into a file just because | it happens to exist already. If you want disk statistics, why not | put it in /proc/diskstatistics?
me too.
I'd like to see the disk stats added, but not in /proc/partitions.
Signature · 1 line
~Randy
Quoted 7 lines · Randy.Dunlap
| It is really ugly to stuff a lot of garbage into a file just because | it happens to exist already. If you want disk statistics, why not | put it in /proc/diskstatistics?me too.
I'd like to see the disk stats added, but not in
/proc/partitions.
Feel free to implement it. This is the interface use by all major vendors for ages and the -ac kernel series. It's supported by unpatched upstream performace tools.
I'll keept this patch around for the few poort soul complaining that they don't get that's anymore after upgrading to the latest kernel.org source.