linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jake Moilanen <moilanen@austin.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: [ANNOUNCE 2/4][RFC] Genetic Algorithm Library
Date: Thu, 6 Jan 2005 10:18:38 -0600	[thread overview]
Message-ID: <20050106101838.067732c7@localhost> (raw)
In-Reply-To: <20050106100844.53a762a0@localhost>

This is the base patch for the io-schedulers.  

It contains the fitness routine, disk_calc_fitness(), that could use a
rework. 

Signed-off-by: Jake Moilanen <moilanen@austin.ibm.com>

---


diff -puN drivers/block/genhd.c~genetic-io-sched drivers/block/genhd.c
--- linux-2.6.9/drivers/block/genhd.c~genetic-io-sched	Wed Jan  5 15:45:57 2005
+++ linux-2.6.9-moilanen/drivers/block/genhd.c	Wed Jan  5 15:45:57 2005
@@ -32,6 +32,8 @@ static struct blk_major_name {
 
 static spinlock_t major_names_lock = SPIN_LOCK_UNLOCKED;
 
+LIST_HEAD(gendisks);
+
 /* index in the above - for now: assume no multimajor ranges */
 static inline int major_to_index(int major)
 {
@@ -556,6 +558,7 @@ struct gendisk *alloc_disk(int minors)
 		kobj_set_kset_s(disk,block_subsys);
 		kobject_init(&disk->kobj);
 		rand_initialize_disk(disk);
+		list_add_tail(&disk->gendisks, &gendisks);
 	}
 	return disk;
 }
diff -puN drivers/block/ll_rw_blk.c~genetic-io-sched drivers/block/ll_rw_blk.c
--- linux-2.6.9/drivers/block/ll_rw_blk.c~genetic-io-sched	Wed Jan  5 15:45:57 2005
+++ linux-2.6.9-moilanen/drivers/block/ll_rw_blk.c	Wed Jan  5 15:45:57 2005
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/writeback.h>
+#include <linux/genetic.h>
 
 /*
  * for max sense size
@@ -2115,6 +2116,81 @@ static inline void add_request(request_q
 	__elv_add_request(q, req, ELEVATOR_INSERT_SORT, 0);
 }
  
+#ifdef CONFIG_GENETIC_IOSCHED_AS
+extern struct list_head gendisks;
+
+void disk_stats_snapshot(void)
+{
+	struct list_head * d;
+	struct gendisk *disk;
+    
+	list_for_each(d, &gendisks) {
+	    disk = list_entry(d, struct gendisk, gendisks);
+
+	    disk_round_stats(disk);
+
+	    disk->reads_snap = disk_stat_read(disk, reads);
+	    disk->writes_snap = disk_stat_read(disk, writes);
+	    disk->read_sectors_snap = disk_stat_read(disk, read_sectors);
+	    disk->write_sectors_snap = disk_stat_read(disk, write_sectors);
+	    disk->time_in_queue_snap = disk_stat_read(disk, time_in_queue);
+	}
+}
+
+/* XXX is this the best method to calc fitness */
+unsigned long disk_calc_fitness(void)
+{
+	struct list_head * d;
+	struct gendisk *disk;
+	unsigned long reads, writes, time_in_queue;
+	unsigned long read_sectors, write_sectors;
+	unsigned long disk_fitness;
+	unsigned long total_fitness = 0;
+    
+	list_for_each(d, &gendisks) {
+	    disk = list_entry(d, struct gendisk, gendisks);
+
+	    disk_round_stats(disk);
+	    
+	    reads = disk_stat_read(disk, reads) - disk->reads_snap;
+	    writes = disk_stat_read(disk, writes) - disk->writes_snap;
+
+	    read_sectors = disk_stat_read(disk, read_sectors) - disk->read_sectors_snap;
+	    write_sectors = disk_stat_read(disk, write_sectors) - disk->write_sectors_snap;
+
+	    time_in_queue = disk_stat_read(disk, time_in_queue)	- disk->time_in_queue_snap;
+
+	    /* Various attempts at collecting good fitness */
+#if 0
+	    if (time_in_queue)
+		disk_fitness = ((reads + writes) 2 * HZ) / time_in_queue;
+	    else
+		disk_fitness = 0;
+
+#endif
+
+#if 1
+	    if (time_in_queue)
+		disk_fitness = ((read_sectors + write_sectors) * 2 * HZ) / time_in_queue;
+	    else
+		disk_fitness = 0;
+#endif
+
+#if 0
+	    disk_fitness = reads + writes;
+#endif
+
+#if 0
+	    disk_fitness = read_sectors + write_sectors;
+#endif
+	    
+	    total_fitness += disk_fitness;
+	}
+
+	return total_fitness;
+}
+#endif
+
 /*
  * disk_round_stats()	- Round off the performance stats on a struct
  * disk_stats.
@@ -2137,7 +2213,6 @@ void disk_round_stats(struct gendisk *di
 	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;
diff -puN include/linux/genhd.h~genetic-io-sched include/linux/genhd.h
--- linux-2.6.9/include/linux/genhd.h~genetic-io-sched	Wed Jan  5 15:45:57 2005
+++ linux-2.6.9-moilanen/include/linux/genhd.h	Wed Jan  5 15:45:57 2005
@@ -120,11 +120,20 @@ struct gendisk {
 	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
 	struct disk_stats dkstats;
 #endif
+#ifdef CONFIG_GENETIC_LIB
+	unsigned reads_snap;
+	unsigned writes_snap;
+	unsigned read_sectors_snap;
+	unsigned write_sectors_snap;
+	unsigned time_in_queue_snap;
+#endif	
+
 };
 
 /* 

_

  parent reply	other threads:[~2005-01-06 16:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-06 16:08 [ANNOUNCE 0/4][RFC] Genetic Algorithm Library Jake Moilanen
2005-01-06 16:14 ` [ANNOUNCE 1/4][RFC] " Jake Moilanen
2005-01-06 17:20   ` Cal Peake
2005-01-06 17:26     ` Cal Peake
2005-01-06 16:18 ` Jake Moilanen [this message]
2005-01-06 16:22 ` [ANNOUNCE 3/4][RFC] " Jake Moilanen
2005-01-06 16:27 ` [ANNOUNCE 4/4][RFC] " Jake Moilanen
2005-01-08 14:05 ` [ANNOUNCE 0/4][RFC] " James Bruce
2005-01-08 14:19   ` James Bruce
2005-01-08 22:56     ` Jake Moilanen
2005-01-08 15:37 ` Pedro Larroy
2005-01-10 15:54   ` Jake Moilanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050106101838.067732c7@localhost \
    --to=moilanen@austin.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).