Messages in this thread |  | | | Date | Mon, 24 Nov 1997 20:27:05 -0500 | | From | mlord <> | | Subject | Re: possible bug in ll_rw_blk.c in 2.0.x and 2.1.x |
| |
Kelly French wrote: > > Here's my 2nd try on this one. Instead of a linked list, it's now an > ordered array. The search is still linear, but since the list is usually > short, I didn't see the need for a binary search. > > To recap, this replaces the static 4-entry array for the block device > stats in kstat with a dynamically allocated array so that we can hold more > devices. This patch also removes the overlapping stats when you have both > IDE and SCSI HD's.
How about something simpler, using fixed-size allocations per major, without a built-in linear search prior to each and every disk access?
Something like below?
-ml
/**********************************************************/ ++disk_stats[MAJOR(req->rq_dev)][unit].ds_disk_rio;
where "unit" is obtained from a switch() stmt similar to the existing code.
At this time, I would suggest that a coded limit would be a simpler alternative to dynamic expansion of the number of possible units per major, yielding code that might do something like this:
#define MAX_DISKSTATS_UNITS_PER_MAJOR 8 /* or 16, or whatever.. */ struct kernel_stat_disk *disk_stats[MAX_BLKDEV]; ... static inline void disk_stat_acct(int cmd, unsigned long nr_sectors,short disk_index) { struct kernel_stat_disk *stats; stats = disk_stats[MAJOR(req->rq_dev)]; if (!stats) { stats = disk_stats(MAJOR(req->rq_dev)] = kmalloc(sizeof(struct kernel_stat_disk) * MAX_DISKSTATS_UNITS_PER_MAJOR, GFP_KERNEL); } if (stats && disk_index < MAX_DISKSTATS_UNITS_PER_MAJOR) { if (cmd == READ) { ++stats[disk_index].ds_disk_rio; ++stats[disk_index].ds_disk_rblks; } else if (cmd == WRITE) { ++stats[disk_index].ds_disk_wio; ++stats[disk_index].ds_disk_wblks; } } } -- mlord@pobox.com The Linux IDE guy
|  |