BFS prerequisites and tidy up of resched functions
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / bfs / bfs-implement_prereqs.patch
1 --- linux-2.6.28.orig/kernel/sched_bfs.c        2011-06-18 18:46:15.009219526 +0200
2 +++ linux-2.6.28.new/kernel/sched_bfs.c 2011-06-18 19:06:34.087896512 +0200
3 @@ -229,9 +229,6 @@ struct rq {
4         struct sched_info rq_sched_info;
5  
6         /* sys_sched_yield() stats */
7 -       unsigned int yld_exp_empty;
8 -       unsigned int yld_act_empty;
9 -       unsigned int yld_both_empty;
10         unsigned int yld_count;
11  
12         /* schedule() stats */
13 @@ -2585,6 +2582,46 @@ void __wake_up_locked(wait_queue_head_t 
14         __wake_up_common(q, mode, 1, 0, NULL);
15  }
16  
17 +void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key)
18 +{
19 +       __wake_up_common(q, mode, 1, 0, key);
20 +}
21 +
22 +/**
23 + * __wake_up_sync_key - wake up threads blocked on a waitqueue.
24 + * @q: the waitqueue
25 + * @mode: which threads
26 + * @nr_exclusive: how many wake-one or wake-many threads to wake up
27 + * @key: opaque value to be passed to wakeup targets
28 + *
29 + * The sync wakeup differs that the waker knows that it will schedule
30 + * away soon, so while the target thread will be woken up, it will not
31 + * be migrated to another CPU - ie. the two threads are 'synchronised'
32 + * with each other. This can prevent needless bouncing between CPUs.
33 + *
34 + * On UP it can prevent extra preemption.
35 + *
36 + * It may be assumed that this function implies a write memory barrier before
37 + * changing the task state if and only if any tasks are woken up.
38 + */
39 +void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode,
40 +                       int nr_exclusive, void *key)
41 +{
42 +       unsigned long flags;
43 +       int sync = 1;
44 +
45 +       if (unlikely(!q))
46 +               return;
47 +
48 +       if (unlikely(!nr_exclusive))
49 +               sync = 0;
50 +
51 +       spin_lock_irqsave(&q->lock, flags);
52 +       __wake_up_common(q, mode, nr_exclusive, sync, key);
53 +       spin_unlock_irqrestore(&q->lock, flags);
54 +}
55 +EXPORT_SYMBOL_GPL(__wake_up_sync_key);
56 +
57  /**
58   * __wake_up_sync - wake up threads blocked on a waitqueue.
59   * @q: the waitqueue
60 @@ -2615,6 +2652,18 @@ void __wake_up_sync(wait_queue_head_t *q
61  }
62  EXPORT_SYMBOL_GPL(__wake_up_sync);     /* For internal use only */
63  
64 +/**
65 + * complete: - signals a single thread waiting on this completion
66 + * @x:  holds the state of this particular completion
67 + *
68 + * This will wake up a single thread waiting on this completion. Threads will be
69 + * awakened in the same order in which they were queued.
70 + *
71 + * See also complete_all(), wait_for_completion() and related routines.
72 + *
73 + * It may be assumed that this function implies a write memory barrier before
74 + * changing the task state if and only if any tasks are woken up.
75 + */
76  void complete(struct completion *x)
77  {
78         unsigned long flags;
79 @@ -2626,6 +2675,15 @@ void complete(struct completion *x)
80  }
81  EXPORT_SYMBOL(complete);
82  
83 +/**
84 + * complete_all: - signals all threads waiting on this completion
85 + * @x:  holds the state of this particular completion
86 + *
87 + * This will wake up all threads waiting on this particular completion event.
88 + *
89 + * It may be assumed that this function implies a write memory barrier before
90 + * changing the task state if and only if any tasks are woken up.
91 + */
92  void complete_all(struct completion *x)
93  {
94         unsigned long flags;
95 @@ -2677,12 +2735,31 @@ wait_for_common(struct completion *x, lo
96         return timeout;
97  }
98  
99 +/**
100 + * wait_for_completion: - waits for completion of a task
101 + * @x:  holds the state of this particular completion
102 + *
103 + * This waits to be signaled for completion of a specific task. It is NOT
104 + * interruptible and there is no timeout.
105 + *
106 + * See also similar routines (i.e. wait_for_completion_timeout()) with timeout
107 + * and interrupt capability. Also see complete().
108 + */
109  void __sched wait_for_completion(struct completion *x)
110  {
111         wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE);
112  }
113  EXPORT_SYMBOL(wait_for_completion);
114  
115 +/**
116 + * wait_for_completion_timeout: - waits for completion of a task (w/timeout)
117 + * @x:  holds the state of this particular completion
118 + * @timeout:  timeout value in jiffies
119 + *
120 + * This waits for either a completion of a specific task to be signaled or for a
121 + * specified timeout to expire. The timeout is in jiffies. It is not
122 + * interruptible.
123 + */
124  unsigned long __sched
125  wait_for_completion_timeout(struct completion *x, unsigned long timeout)
126  {
127 @@ -2690,6 +2767,13 @@ wait_for_completion_timeout(struct compl
128  }
129  EXPORT_SYMBOL(wait_for_completion_timeout);
130  
131 +/**
132 + * wait_for_completion_interruptible: - waits for completion of a task (w/intr)
133 + * @x:  holds the state of this particular completion
134 + *
135 + * This waits for completion of a specific task to be signaled. It is
136 + * interruptible.
137 + */
138  int __sched wait_for_completion_interruptible(struct completion *x)
139  {
140         long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_INTERRUPTIBLE);
141 @@ -2699,6 +2783,14 @@ int __sched wait_for_completion_interrup
142  }
143  EXPORT_SYMBOL(wait_for_completion_interruptible);
144  
145 +/**
146 + * wait_for_completion_interruptible_timeout: - waits for completion (w/(to,intr))
147 + * @x:  holds the state of this particular completion
148 + * @timeout:  timeout value in jiffies
149 + *
150 + * This waits for either a completion of a specific task to be signaled or for a
151 + * specified timeout to expire. It is interruptible. The timeout is in jiffies.
152 + */
153  unsigned long __sched
154  wait_for_completion_interruptible_timeout(struct completion *x,
155                                           unsigned long timeout)
156 @@ -2707,6 +2799,13 @@ wait_for_completion_interruptible_timeou
157  }
158  EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
159  
160 +/**
161 + * wait_for_completion_killable: - waits for completion of a task (killable)
162 + * @x:  holds the state of this particular completion
163 + *
164 + * This waits to be signaled for completion of a specific task. It can be
165 + * interrupted by a kill signal.
166 + */
167  int __sched wait_for_completion_killable(struct completion *x)
168  {
169         long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);