genetic-zaphod-cpu-scheduler/genetic-io-sched-2.6.11-gl1.patch

175 lines
5 KiB
Diff
Raw Normal View History

2024-04-29 13:35:35 +00:00
Index: 2.6.11/drivers/block/genhd.c
===================================================================
--- 2.6.11.orig/drivers/block/genhd.c 2005-03-02 01:38:08.000000000 -0600
+++ 2.6.11/drivers/block/genhd.c 2005-04-15 11:35:40.763715300 -0500
@@ -31,6 +31,8 @@
char name[16];
} *major_names[MAX_PROBE_HASH];
+LIST_HEAD(gendisks);
+
/* index in the above - for now: assume no multimajor ranges */
static inline int major_to_index(int major)
{
@@ -589,6 +591,7 @@
kobj_set_kset_s(disk,block_subsys);
kobject_init(&disk->kobj);
rand_initialize_disk(disk);
+ list_add_tail(&disk->gendisks, &gendisks);
}
return disk;
}
Index: 2.6.11/drivers/block/ll_rw_blk.c
===================================================================
--- 2.6.11.orig/drivers/block/ll_rw_blk.c 2005-03-02 01:37:48.000000000 -0600
+++ 2.6.11/drivers/block/ll_rw_blk.c 2005-04-15 11:35:40.765716044 -0500
@@ -28,6 +28,7 @@
#include <linux/slab.h>
#include <linux/swap.h>
#include <linux/writeback.h>
+#include <linux/genetic.h>
/*
* for max sense size
@@ -2140,6 +2141,99 @@
__elv_add_request(q, req, ELEVATOR_INSERT_SORT, 0);
}
+#ifdef CONFIG_GENETIC_IOSCHED_AS
+extern struct list_head gendisks;
+
+void disk_stats_snapshot(phenotype_t * pt)
+{
+ struct list_head * d;
+ struct gendisk *disk;
+ struct disk_stats_snapshot * ss = (struct disk_stats_snapshot *)pt->child_ranking[0]->stats_snapshot;
+
+ memset(ss, 0, sizeof(struct disk_stats_snapshot));
+
+ list_for_each(d, &gendisks) {
+ disk = list_entry(d, struct gendisk, gendisks);
+
+ disk_round_stats(disk);
+
+ ss->reads += disk_stat_read(disk, reads);
+ ss->writes += disk_stat_read(disk, writes);
+ ss->read_sectors += disk_stat_read(disk, read_sectors);
+ ss->write_sectors += disk_stat_read(disk, write_sectors);
+ ss->time_in_queue += disk_stat_read(disk, time_in_queue);
+ }
+}
+
+unsigned long disk_num_ops_calc_fitness(genetic_child_t * child)
+{
+ struct list_head * d;
+ struct gendisk *disk;
+ struct disk_stats_snapshot * ss = (struct disk_stats_snapshot *)child->stats_snapshot;
+ unsigned long reads = 0;
+ unsigned long writes = 0;
+
+ list_for_each(d, &gendisks) {
+ disk = list_entry(d, struct gendisk, gendisks);
+
+ disk_round_stats(disk);
+
+ reads += disk_stat_read(disk, reads);
+ writes += disk_stat_read(disk, writes);
+ }
+
+ reads -= ss->reads;
+ writes -= ss->writes;
+
+ return reads + writes;
+}
+
+unsigned long disk_throughput_calc_fitness(genetic_child_t * child)
+{
+ struct list_head * d;
+ struct gendisk *disk;
+ struct disk_stats_snapshot * ss = (struct disk_stats_snapshot *)child->stats_snapshot;
+ unsigned long read_sectors = 0;
+ unsigned long write_sectors = 0;
+
+ list_for_each(d, &gendisks) {
+ disk = list_entry(d, struct gendisk, gendisks);
+
+ disk_round_stats(disk);
+
+ read_sectors += disk_stat_read(disk, read_sectors);
+ write_sectors += disk_stat_read(disk, write_sectors);
+ }
+
+ read_sectors -= ss->read_sectors;
+ write_sectors -= ss->write_sectors;
+
+ return read_sectors + write_sectors;
+}
+
+unsigned long disk_latency_calc_fitness(genetic_child_t * child)
+{
+ struct list_head * d;
+ struct gendisk *disk;
+ struct disk_stats_snapshot * ss = (struct disk_stats_snapshot *)child->stats_snapshot;
+ unsigned long time_in_queue = 0;
+
+ list_for_each(d, &gendisks) {
+ disk = list_entry(d, struct gendisk, gendisks);
+
+ disk_round_stats(disk);
+
+ time_in_queue += disk_stat_read(disk, time_in_queue);
+ }
+
+ time_in_queue = -(time_in_queue - ss->time_in_queue);
+
+ return time_in_queue;
+}
+
+
+#endif /* GENETIC_IOSCHED_AS */
+
/*
* disk_round_stats() - Round off the performance stats on a struct
* disk_stats.
@@ -2162,7 +2256,6 @@
__disk_stat_add(disk, time_in_queue,
disk->in_flight * (now - disk->stamp));
disk->stamp = now;
-
if (disk->in_flight)
__disk_stat_add(disk, io_ticks, (now - disk->stamp_idle));
disk->stamp_idle = now;
Index: 2.6.11/include/linux/genhd.h
===================================================================
--- 2.6.11.orig/include/linux/genhd.h 2005-03-02 01:37:49.000000000 -0600
+++ 2.6.11/include/linux/genhd.h 2005-04-15 11:35:40.766716416 -0500
@@ -121,6 +121,7 @@
atomic_t sync_io; /* RAID */
unsigned long stamp, stamp_idle;
int in_flight;
+ struct list_head gendisks;
#ifdef CONFIG_SMP
struct disk_stats *dkstats;
#else
Index: 2.6.11/include/linux/blkdev.h
===================================================================
--- 2.6.11.orig/include/linux/blkdev.h 2005-03-02 01:37:50.000000000 -0600
+++ 2.6.11/include/linux/blkdev.h 2005-04-15 11:35:40.767716788 -0500
@@ -724,5 +724,16 @@
#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
MODULE_ALIAS("block-major-" __stringify(major) "-*")
+#ifdef CONFIG_GENETIC_IOSCHED_AS
+
+struct disk_stats_snapshot
+{
+ unsigned long reads;
+ unsigned long writes;
+ unsigned long read_sectors;
+ unsigned long write_sectors;
+ unsigned long time_in_queue;
+};
+#endif /* CONFIG_GENETIC_IOSCHED_AS */
#endif