direct-io.hg

changeset 2285:6a83ce7a1b78

bitkeeper revision 1.1159.1.83 (41239710AGSmTMRcmNzZofG14BmziA)

Yet another tqueue fixup.
author kaf24@scramble.cl.cam.ac.uk
date Wed Aug 18 17:51:12 2004 +0000 (2004-08-18)
parents b7320c51e09a
children 6160f02c8c62 56635b4b9dc0
files linux-2.4.26-xen-sparse/include/asm-xen/queues.h linux-2.6.7-xen-sparse/include/asm-xen/queues.h
line diff
     1.1 --- a/linux-2.4.26-xen-sparse/include/asm-xen/queues.h	Wed Aug 18 17:34:14 2004 +0000
     1.2 +++ b/linux-2.4.26-xen-sparse/include/asm-xen/queues.h	Wed Aug 18 17:51:12 2004 +0000
     1.3 @@ -1,18 +1,5 @@
     1.4  
     1.5 -/*
     1.6 - * Oh dear. Task queues were removed from Linux 2.6 and replaced by work 
     1.7 - * queues. Unfortunately the semantics is not the same. With task queues we 
     1.8 - * can defer work until a particular event occurs -- this is not
     1.9 - * straightforwardly done with work queues (queued work is performed asap, or
    1.10 - * after some fixed timeout). Conversely, work queues are a (slightly) neater
    1.11 - * way of deferring work to a process context than using task queues in 2.4.
    1.12 - * 
    1.13 - * So, what we do here is a bit weird:
    1.14 - *  1. On 2.4, we emulate work queues over task queues.
    1.15 - *  2. On 2.6, we emulate task queues over work queues.
    1.16 - * 
    1.17 - * Note how much harder the latter is. :-)
    1.18 - */
    1.19 +/* Work-queue emulation over task queues. Pretty simple. */
    1.20  
    1.21  #ifndef __QUEUES_H__
    1.22  #define __QUEUES_H__
     2.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/queues.h	Wed Aug 18 17:34:14 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/queues.h	Wed Aug 18 17:51:12 2004 +0000
     2.3 @@ -7,11 +7,9 @@
     2.4   * after some fixed timeout). Conversely, work queues are a (slightly) neater
     2.5   * way of deferring work to a process context than using task queues in 2.4.
     2.6   * 
     2.7 - * So, what we do here is a bit weird:
     2.8 - *  1. On 2.4, we emulate work queues over task queues.
     2.9 - *  2. On 2.6, we emulate task queues over work queues.
    2.10 - * 
    2.11 - * Note how much harder the latter is. :-)
    2.12 + * This is a bit of a needless reimplementation -- should have just pulled
    2.13 + * the code from 2.4, but I tried leveraging work queues to simplify things.
    2.14 + * They didn't help. :-(
    2.15   */
    2.16  
    2.17  #ifndef __QUEUES_H__
    2.18 @@ -22,19 +20,19 @@
    2.19  #include <linux/workqueue.h>
    2.20  
    2.21  struct tq_struct { 
    2.22 -    struct work_struct work;
    2.23 -    struct list_head   list;
    2.24 -    unsigned long      pending;
    2.25 +    void (*fn)(void *);
    2.26 +    void *arg;
    2.27 +    struct list_head list;
    2.28 +    unsigned long pending;
    2.29  };
    2.30  #define INIT_TQUEUE(_name, _fn, _arg)               \
    2.31      do {                                            \
    2.32          INIT_LIST_HEAD(&(_name)->list);             \
    2.33          (_name)->pending = 0;                       \
    2.34 -        INIT_WORK(&(_name)->work, (_fn), (_arg));   \
    2.35 +        (_name)->fn = (_fn); (_name)->arg = (_arg); \
    2.36      } while ( 0 )
    2.37 -#define DECLARE_TQUEUE(_name, _fn, _arg)                                    \
    2.38 -    struct tq_struct _name = { __WORK_INITIALIZER((_name).work, _fn, _arg), \
    2.39 -                               LIST_HEAD_INIT((_name).list), 0 }
    2.40 +#define DECLARE_TQUEUE(_name, _fn, _arg)            \
    2.41 +    struct tq_struct _name = { (_fn), (_arg), LIST_HEAD_INIT((_name).list), 0 }
    2.42  
    2.43  typedef struct {
    2.44      struct list_head list;
    2.45 @@ -59,6 +57,8 @@ static inline void run_task_queue(task_q
    2.46      struct list_head head, *ent;
    2.47      struct tq_struct *tqe;
    2.48      unsigned long flags;
    2.49 +    void (*fn)(void *);
    2.50 +    void *arg;
    2.51  
    2.52      spin_lock_irqsave(&tql->lock, flags);
    2.53      list_add(&head, &tql->list);
    2.54 @@ -70,8 +70,11 @@ static inline void run_task_queue(task_q
    2.55          ent = head.next;
    2.56          list_del_init(ent);
    2.57          tqe = list_entry(ent, struct tq_struct, list);
    2.58 -        wmb(); tqe->pending = 0;
    2.59 -        schedule_work(&tqe->work);
    2.60 +        fn  = tqe->fn;
    2.61 +        arg = tqe->arg;
    2.62 +        wmb();
    2.63 +        tqe->pending = 0;
    2.64 +        fn(arg);
    2.65      }
    2.66  }
    2.67