~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to debian/patches/features/all/rt/wait-simple-version.patch

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings, Bastian Blank, Ben Hutchings, Uwe Kleine-König
  • Date: 2012-03-04 15:32:20 UTC
  • mfrom: (1.3.14)
  • mto: This revision was merged to the branch mainline in revision 57.
  • Revision ID: package-import@ubuntu.com-20120304153220-zbhqnmufx18yk6q4
* New upstream stable update:
  http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.2.8
  - [i386] i387: move TS_USEDFPU flag from thread_info to task_struct
  - [x86] additional refactoring of FPU/SSE state save and restore
  http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.2.9
  - vfs: fix d_inode_lookup() dentry ref leak
  - target: Allow control CDBs with data > 1 page
  - epoll: introduce POLLFREE to flush ->signalfd_wqh before kfree()
  - epoll: ep_unregister_pollwait() can use the freed pwq->whead
  - epoll: limit paths (CVE-2011-1083)
  - cdrom: use copy_to_user() without the underscores

[ Bastian Blank ]
* [mips,mipsel] Also remove ext4 modules from installer.

[ Ben Hutchings ]
* Update debconf template translations:
  - Update Dutch (Willem Kuyn) (Closes: #658736)
  - Add Polish (Michał Kułach) (Closes: #658912)
* Bump ABI to 2
* fs: Introduce and enable security restrictions on links:
  - Do not follow symlinks in /tmp that are owned by other users
    (sysctl: fs.protected_symlinks)
  - Do not allow unprivileged users to create hard links to sensitive files
    (sysctl: fs.protected_hardlinks) (Closes: #609455)
    + This breaks the 'at' package in stable, which will be fixed shortly
      (see #597130)
  The precise restrictions are specified in Documentation/sysctl/fs.txt in
  the linux-doc-3.2 and linux-source-3.2 packages.
* iwlwifi: fix key removal (Closes: #651199)
* cgroups: Set CGROUP_PERF
* hid: Enable HID_HOLTEK, HID_PRIMAX, HID_SPEEDLINK, HID_WIIMOTE as modules,
  HID_ACRUX_FF
* media/rc: Enable RC_ATI_REMOTE as module
* gspca: Enable USB_GSPCA_TOPRO as module
* dvb-usb: Enable DVB_USB_PCTV452E, DVB_USB_MXL111SF as modules

[ Uwe Kleine-König ]
* [x86] Update rt featureset to 3.2.9-rt15

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Subject: wait-simple: Simple waitqueue implementation
2
 
From: Thomas Gleixner <tglx@linutronix.de>
3
 
Date: Mon, 12 Dec 2011 12:29:04 +0100
4
 
 
5
 
wait_queue is a swiss army knife and in most of the cases the
6
 
complexity is not needed. For RT waitqueues are a constant source of
7
 
trouble as we can't convert the head lock to a raw spinlock due to
8
 
fancy and long lasting callbacks.
9
 
 
10
 
Provide a slim version, which allows RT to replace wait queues. This
11
 
should go mainline as well, as it lowers memory consumption and
12
 
runtime overhead.
13
 
 
14
 
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
15
 
---
16
 
 include/linux/wait-simple.h |  152 ++++++++++++++++++++++++++++++++++++++++++++
17
 
 kernel/Makefile             |    2 
18
 
 kernel/wait-simple.c        |   63 ++++++++++++++++++
19
 
 3 files changed, 216 insertions(+), 1 deletion(-)
20
 
 
21
 
Index: linux-3.2/include/linux/wait-simple.h
22
 
===================================================================
23
 
--- /dev/null
24
 
+++ linux-3.2/include/linux/wait-simple.h
25
 
@@ -0,0 +1,152 @@
26
 
+#ifndef _LINUX_WAIT_SIMPLE_H
27
 
+#define _LINUX_WAIT_SIMPLE_H
28
 
+
29
 
+#include <linux/spinlock.h>
30
 
+#include <linux/list.h>
31
 
+
32
 
+#include <asm/current.h>
33
 
+
34
 
+struct swaiter {
35
 
+       struct task_struct      *task;
36
 
+       struct list_head        node;
37
 
+};
38
 
+
39
 
+#define DEFINE_SWAITER(name)                                   \
40
 
+       struct swaiter name = {                                 \
41
 
+               .task   = current,                              \
42
 
+               .node   = LIST_HEAD_INIT((name).node),          \
43
 
+       }
44
 
+
45
 
+struct swait_head {
46
 
+       raw_spinlock_t          lock;
47
 
+       struct list_head        list;
48
 
+};
49
 
+
50
 
+#define DEFINE_SWAIT_HEAD(name)                                        \
51
 
+       struct swait_head name = {                              \
52
 
+               .lock   = __RAW_SPIN_LOCK_UNLOCKED(name.lock),  \
53
 
+               .list   = LIST_HEAD_INIT((name).list),          \
54
 
+       }
55
 
+
56
 
+extern void __init_swait_head(struct swait_head *h, struct lock_class_key *key);
57
 
+
58
 
+#define init_swait_head(swh)                                   \
59
 
+       do {                                                    \
60
 
+               static struct lock_class_key __key;             \
61
 
+                                                               \
62
 
+               __init_swait_head((swh), &__key);               \
63
 
+       } while (0)
64
 
+
65
 
+/*
66
 
+ * Waiter functions
67
 
+ */
68
 
+static inline bool swaiter_enqueued(struct swaiter *w)
69
 
+{
70
 
+       return w->task != NULL;
71
 
+}
72
 
+
73
 
+extern void swait_prepare(struct swait_head *head, struct swaiter *w, int state);
74
 
+extern void swait_finish(struct swait_head *head, struct swaiter *w);
75
 
+
76
 
+/*
77
 
+ * Adds w to head->list. Must be called with head->lock locked.
78
 
+ */
79
 
+static inline void __swait_enqueue(struct swait_head *head, struct swaiter *w)
80
 
+{
81
 
+       list_add(&w->node, &head->list);
82
 
+}
83
 
+
84
 
+/*
85
 
+ * Removes w from head->list. Must be called with head->lock locked.
86
 
+ */
87
 
+static inline void __swait_dequeue(struct swaiter *w)
88
 
+{
89
 
+       list_del_init(&w->node);
90
 
+}
91
 
+
92
 
+/*
93
 
+ * Wakeup functions
94
 
+ */
95
 
+extern void __swait_wake(struct swait_head *head, unsigned int state);
96
 
+
97
 
+static inline void swait_wake(struct swait_head *head)
98
 
+{
99
 
+       __swait_wake(head, TASK_NORMAL);
100
 
+}
101
 
+
102
 
+/*
103
 
+ * Event API
104
 
+ */
105
 
+
106
 
+#define __swait_event(wq, condition)                                   \
107
 
+do {                                                                   \
108
 
+       DEFINE_SWAITER(__wait);                                         \
109
 
+                                                                       \
110
 
+       for (;;) {                                                      \
111
 
+               swait_prepare(&wq, &__wait, TASK_UNINTERRUPTIBLE);      \
112
 
+               if (condition)                                          \
113
 
+                       break;                                          \
114
 
+               schedule();                                             \
115
 
+       }                                                               \
116
 
+       swait_finish(&wq, &__wait);                                     \
117
 
+} while (0)
118
 
+
119
 
+/**
120
 
+ * swait_event - sleep until a condition gets true
121
 
+ * @wq: the waitqueue to wait on
122
 
+ * @condition: a C expression for the event to wait for
123
 
+ *
124
 
+ * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
125
 
+ * @condition evaluates to true. The @condition is checked each time
126
 
+ * the waitqueue @wq is woken up.
127
 
+ *
128
 
+ * wake_up() has to be called after changing any variable that could
129
 
+ * change the result of the wait condition.
130
 
+ */
131
 
+#define swait_event(wq, condition)                                     \
132
 
+do {                                                                   \
133
 
+       if (condition)                                                  \
134
 
+               break;                                                  \
135
 
+       __swait_event(wq, condition);                                   \
136
 
+} while (0)
137
 
+
138
 
+#define __swait_event_timeout(wq, condition, ret)                      \
139
 
+do {                                                                   \
140
 
+       DEFINE_SWAITER(__wait);                                         \
141
 
+                                                                       \
142
 
+       for (;;) {                                                      \
143
 
+               swait_prepare(&wq, &__wait, TASK_UNINTERRUPTIBLE);      \
144
 
+               if (condition)                                          \
145
 
+                       break;                                          \
146
 
+               ret = schedule_timeout(ret);                            \
147
 
+               if (!ret)                                               \
148
 
+                       break;                                          \
149
 
+       }                                                               \
150
 
+       swait_finish(&wq, &__wait);                                     \
151
 
+} while (0)
152
 
+
153
 
+/**
154
 
+ * swait_event_timeout - sleep until a condition gets true or a timeout elapses
155
 
+ * @wq: the waitqueue to wait on
156
 
+ * @condition: a C expression for the event to wait for
157
 
+ * @timeout: timeout, in jiffies
158
 
+ *
159
 
+ * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
160
 
+ * @condition evaluates to true. The @condition is checked each time
161
 
+ * the waitqueue @wq is woken up.
162
 
+ *
163
 
+ * wake_up() has to be called after changing any variable that could
164
 
+ * change the result of the wait condition.
165
 
+ *
166
 
+ * The function returns 0 if the @timeout elapsed, and the remaining
167
 
+ * jiffies if the condition evaluated to true before the timeout elapsed.
168
 
+ */
169
 
+#define swait_event_timeout(wq, condition, timeout)                    \
170
 
+({                                                                     \
171
 
+       long __ret = timeout;                                           \
172
 
+       if (!(condition))                                               \
173
 
+               __swait_event_timeout(wq, condition, __ret);            \
174
 
+       __ret;                                                          \
175
 
+})
176
 
+
177
 
+#endif
178
 
Index: linux-3.2/kernel/Makefile
179
 
===================================================================
180
 
--- linux-3.2.orig/kernel/Makefile
181
 
+++ linux-3.2/kernel/Makefile
182
 
@@ -10,7 +10,7 @@ obj-y     = sched.o fork.o exec_domain.o
183
 
            kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o \
184
 
            hrtimer.o nsproxy.o srcu.o semaphore.o \
185
 
            notifier.o ksysfs.o sched_clock.o cred.o \
186
 
-           async.o range.o
187
 
+           async.o range.o wait-simple.o
188
 
 obj-y += groups.o
189
 
 
190
 
 ifdef CONFIG_FUNCTION_TRACER
191
 
Index: linux-3.2/kernel/wait-simple.c
192
 
===================================================================
193
 
--- /dev/null
194
 
+++ linux-3.2/kernel/wait-simple.c
195
 
@@ -0,0 +1,63 @@
196
 
+/*
197
 
+ * Simple waitqueues without fancy flags and callbacks
198
 
+ *
199
 
+ * (C) 2011 Thomas Gleixner <tglx@linutronix.de>
200
 
+ *
201
 
+ * Based on kernel/wait.c
202
 
+ *
203
 
+ * For licencing details see kernel-base/COPYING
204
 
+ */
205
 
+#include <linux/init.h>
206
 
+#include <linux/export.h>
207
 
+#include <linux/sched.h>
208
 
+#include <linux/wait-simple.h>
209
 
+
210
 
+void __init_swait_head(struct swait_head *head, struct lock_class_key *key)
211
 
+{
212
 
+       raw_spin_lock_init(&head->lock);
213
 
+       lockdep_set_class(&head->lock, key);
214
 
+       INIT_LIST_HEAD(&head->list);
215
 
+}
216
 
+EXPORT_SYMBOL_GPL(__init_swait_head);
217
 
+
218
 
+void swait_prepare(struct swait_head *head, struct swaiter *w, int state)
219
 
+{
220
 
+       unsigned long flags;
221
 
+
222
 
+       raw_spin_lock_irqsave(&head->lock, flags);
223
 
+       w->task = current;
224
 
+       __swait_enqueue(head, w);
225
 
+       set_current_state(state);
226
 
+       raw_spin_unlock_irqrestore(&head->lock, flags);
227
 
+}
228
 
+EXPORT_SYMBOL_GPL(swait_prepare);
229
 
+
230
 
+void swait_finish(struct swait_head *head, struct swaiter *w)
231
 
+{
232
 
+       unsigned long flags;
233
 
+
234
 
+       __set_current_state(TASK_RUNNING);
235
 
+       if (w->task) {
236
 
+               raw_spin_lock_irqsave(&head->lock, flags);
237
 
+               __swait_dequeue(w);
238
 
+               raw_spin_unlock_irqrestore(&head->lock, flags);
239
 
+       }
240
 
+}
241
 
+EXPORT_SYMBOL_GPL(swait_finish);
242
 
+
243
 
+void __swait_wake(struct swait_head *head, unsigned int state)
244
 
+{
245
 
+       struct swaiter *curr, *next;
246
 
+       unsigned long flags;
247
 
+
248
 
+       raw_spin_lock_irqsave(&head->lock, flags);
249
 
+
250
 
+       list_for_each_entry_safe(curr, next, &head->list, node) {
251
 
+               if (wake_up_state(curr->task, state)) {
252
 
+                       __swait_dequeue(curr);
253
 
+                       curr->task = NULL;
254
 
+               }
255
 
+       }
256
 
+
257
 
+       raw_spin_unlock_irqrestore(&head->lock, flags);
258
 
+}