]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] cfq-iosched: move tasklist walk to elevator.c
authorChristoph Hellwig <hch@lst.de>
Sun, 30 Oct 2005 23:01:39 +0000 (15:01 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 31 Oct 2005 01:37:17 +0000 (17:37 -0800)
We're trying to get rid of as much as possible tasklist walks, or at
least moving them to core code.  This patch falls into the second
category.

Instead of walking the tasklist in cfq-iosched move that into
elv_unregister.  The added benefit is that with this change the as
ioscheduler might be might unloadable more easily aswell.

The new code uses read_lock instead of read_lock_irq because the
tasklist_lock only needs irq disabling for writers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/block/as-iosched.c
drivers/block/cfq-iosched.c
drivers/block/elevator.c

index 56417223481946ca499c8305da27ef065485068f..c6744ff382944a590767cef1827e627c1915c7ad 100644 (file)
@@ -1973,8 +1973,8 @@ static int __init as_init(void)
 
 static void __exit as_exit(void)
 {
-       kmem_cache_destroy(arq_pool);
        elv_unregister(&iosched_as);
+       kmem_cache_destroy(arq_pool);
 }
 
 module_init(as_init);
index 94690e4d41e096b4a988eb5a27f76d8d1925fc72..5281f8e70510cda1717f2bd385e0c19353476fdd 100644 (file)
@@ -2418,28 +2418,8 @@ static int __init cfq_init(void)
 
 static void __exit cfq_exit(void)
 {
-       struct task_struct *g, *p;
-       unsigned long flags;
-
-       read_lock_irqsave(&tasklist_lock, flags);
-
-       /*
-        * iterate each process in the system, removing our io_context
-        */
-       do_each_thread(g, p) {
-               struct io_context *ioc = p->io_context;
-
-               if (ioc && ioc->cic) {
-                       ioc->cic->exit(ioc->cic);
-                       cfq_free_io_context(ioc->cic);
-                       ioc->cic = NULL;
-               }
-       } while_each_thread(g, p);
-
-       read_unlock_irqrestore(&tasklist_lock, flags);
-
-       cfq_slab_kill();
        elv_unregister(&iosched_cfq);
+       cfq_slab_kill();
 }
 
 module_init(cfq_init);
index 55621d5c577403e3024a6dac9b580185c6c6b9cf..58e881bfd189ad4a677bc02e8d8b71663cb7e351 100644 (file)
@@ -642,6 +642,27 @@ EXPORT_SYMBOL_GPL(elv_register);
 
 void elv_unregister(struct elevator_type *e)
 {
+       struct task_struct *g, *p;
+
+       /*
+        * Iterate every thread in the process to remove the io contexts.
+        */
+       read_lock(&tasklist_lock);
+       do_each_thread(g, p) {
+               struct io_context *ioc = p->io_context;
+               if (ioc && ioc->cic) {
+                       ioc->cic->exit(ioc->cic);
+                       ioc->cic->dtor(ioc->cic);
+                       ioc->cic = NULL;
+               }
+               if (ioc && ioc->aic) {
+                       ioc->aic->exit(ioc->aic);
+                       ioc->aic->dtor(ioc->aic);
+                       ioc->aic = NULL;
+               }
+       } while_each_thread(g, p);
+       read_unlock(&tasklist_lock);
+
        spin_lock_irq(&elv_list_lock);
        list_del_init(&e->list);
        spin_unlock_irq(&elv_list_lock);