diff options
author | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-06-28 14:06:39 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-06-28 14:06:39 -0400 |
commit | f28e71617ddaf2483e3e5c5237103484a303743f (patch) | |
tree | 67627d2d8ddbf6a4449371e9261d796c013b1fa1 /Documentation | |
parent | dc6a78f1af10d28fb8c395034ae1e099b85c05b0 (diff) | |
parent | a39727f212426b9d5f9267b3318a2afaf9922d3b (diff) |
Merge ../linux-2.6/
Conflicts:
drivers/scsi/aacraid/comminit.c
Fixed up by removing the now renamed CONFIG_IOMMU option from
aacraid
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'Documentation')
23 files changed, 1861 insertions, 81 deletions
diff --git a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl index 158ffe9bfade..644c3884fab9 100644 --- a/Documentation/DocBook/kernel-locking.tmpl +++ b/Documentation/DocBook/kernel-locking.tmpl | |||
@@ -1590,7 +1590,7 @@ the amount of locking which needs to be done. | |||
1590 | <para> | 1590 | <para> |
1591 | Our final dilemma is this: when can we actually destroy the | 1591 | Our final dilemma is this: when can we actually destroy the |
1592 | removed element? Remember, a reader might be stepping through | 1592 | removed element? Remember, a reader might be stepping through |
1593 | this element in the list right now: it we free this element and | 1593 | this element in the list right now: if we free this element and |
1594 | the <symbol>next</symbol> pointer changes, the reader will jump | 1594 | the <symbol>next</symbol> pointer changes, the reader will jump |
1595 | off into garbage and crash. We need to wait until we know that | 1595 | off into garbage and crash. We need to wait until we know that |
1596 | all the readers who were traversing the list when we deleted the | 1596 | all the readers who were traversing the list when we deleted the |
diff --git a/Documentation/RCU/torture.txt b/Documentation/RCU/torture.txt index e4c38152f7f7..a4948591607d 100644 --- a/Documentation/RCU/torture.txt +++ b/Documentation/RCU/torture.txt | |||
@@ -7,7 +7,7 @@ The CONFIG_RCU_TORTURE_TEST config option is available for all RCU | |||
7 | implementations. It creates an rcutorture kernel module that can | 7 | implementations. It creates an rcutorture kernel module that can |
8 | be loaded to run a torture test. The test periodically outputs | 8 | be loaded to run a torture test. The test periodically outputs |
9 | status messages via printk(), which can be examined via the dmesg | 9 | status messages via printk(), which can be examined via the dmesg |
10 | command (perhaps grepping for "rcutorture"). The test is started | 10 | command (perhaps grepping for "torture"). The test is started |
11 | when the module is loaded, and stops when the module is unloaded. | 11 | when the module is loaded, and stops when the module is unloaded. |
12 | 12 | ||
13 | However, actually setting this config option to "y" results in the system | 13 | However, actually setting this config option to "y" results in the system |
@@ -35,6 +35,19 @@ stat_interval The number of seconds between output of torture | |||
35 | be printed -only- when the module is unloaded, and this | 35 | be printed -only- when the module is unloaded, and this |
36 | is the default. | 36 | is the default. |
37 | 37 | ||
38 | shuffle_interval | ||
39 | The number of seconds to keep the test threads affinitied | ||
40 | to a particular subset of the CPUs. Used in conjunction | ||
41 | with test_no_idle_hz. | ||
42 | |||
43 | test_no_idle_hz Whether or not to test the ability of RCU to operate in | ||
44 | a kernel that disables the scheduling-clock interrupt to | ||
45 | idle CPUs. Boolean parameter, "1" to test, "0" otherwise. | ||
46 | |||
47 | torture_type The type of RCU to test: "rcu" for the rcu_read_lock() | ||
48 | API, "rcu_bh" for the rcu_read_lock_bh() API, and "srcu" | ||
49 | for the "srcu_read_lock()" API. | ||
50 | |||
38 | verbose Enable debug printk()s. Default is disabled. | 51 | verbose Enable debug printk()s. Default is disabled. |
39 | 52 | ||
40 | 53 | ||
@@ -42,14 +55,14 @@ OUTPUT | |||
42 | 55 | ||
43 | The statistics output is as follows: | 56 | The statistics output is as follows: |
44 | 57 | ||
45 | rcutorture: --- Start of test: nreaders=16 stat_interval=0 verbose=0 | 58 | rcu-torture: --- Start of test: nreaders=16 stat_interval=0 verbose=0 |
46 | rcutorture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915 | 59 | rcu-torture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915 |
47 | rcutorture: Reader Pipe: 1466408 9747 0 0 0 0 0 0 0 0 0 | 60 | rcu-torture: Reader Pipe: 1466408 9747 0 0 0 0 0 0 0 0 0 |
48 | rcutorture: Reader Batch: 1464477 11678 0 0 0 0 0 0 0 0 | 61 | rcu-torture: Reader Batch: 1464477 11678 0 0 0 0 0 0 0 0 |
49 | rcutorture: Free-Block Circulation: 1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0 | 62 | rcu-torture: Free-Block Circulation: 1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0 |
50 | rcutorture: --- End of test | 63 | rcu-torture: --- End of test |
51 | 64 | ||
52 | The command "dmesg | grep rcutorture:" will extract this information on | 65 | The command "dmesg | grep torture:" will extract this information on |
53 | most systems. On more esoteric configurations, it may be necessary to | 66 | most systems. On more esoteric configurations, it may be necessary to |
54 | use other commands to access the output of the printk()s used by | 67 | use other commands to access the output of the printk()s used by |
55 | the RCU torture test. The printk()s use KERN_ALERT, so they should | 68 | the RCU torture test. The printk()s use KERN_ALERT, so they should |
@@ -115,8 +128,9 @@ The following script may be used to torture RCU: | |||
115 | modprobe rcutorture | 128 | modprobe rcutorture |
116 | sleep 100 | 129 | sleep 100 |
117 | rmmod rcutorture | 130 | rmmod rcutorture |
118 | dmesg | grep rcutorture: | 131 | dmesg | grep torture: |
119 | 132 | ||
120 | The output can be manually inspected for the error flag of "!!!". | 133 | The output can be manually inspected for the error flag of "!!!". |
121 | One could of course create a more elaborate script that automatically | 134 | One could of course create a more elaborate script that automatically |
122 | checked for such errors. | 135 | checked for such errors. The "rmmod" command forces a "SUCCESS" or |
136 | "FAILURE" indication to be printk()ed. | ||
diff --git a/Documentation/arm/Samsung-S3C24XX/Overview.txt b/Documentation/arm/Samsung-S3C24XX/Overview.txt index 8c6ee684174c..3e46d2a31158 100644 --- a/Documentation/arm/Samsung-S3C24XX/Overview.txt +++ b/Documentation/arm/Samsung-S3C24XX/Overview.txt | |||
@@ -7,11 +7,13 @@ Introduction | |||
7 | ------------ | 7 | ------------ |
8 | 8 | ||
9 | The Samsung S3C24XX range of ARM9 System-on-Chip CPUs are supported | 9 | The Samsung S3C24XX range of ARM9 System-on-Chip CPUs are supported |
10 | by the 's3c2410' architecture of ARM Linux. Currently the S3C2410 and | 10 | by the 's3c2410' architecture of ARM Linux. Currently the S3C2410, |
11 | the S3C2440 are supported CPUs. | 11 | S3C2440 and S3C2442 devices are supported. |
12 | 12 | ||
13 | Support for the S3C2400 series is in progress. | 13 | Support for the S3C2400 series is in progress. |
14 | 14 | ||
15 | Support for the S3C2412 and S3C2413 CPUs is being merged. | ||
16 | |||
15 | 17 | ||
16 | Configuration | 18 | Configuration |
17 | ------------- | 19 | ------------- |
@@ -43,9 +45,18 @@ Machines | |||
43 | 45 | ||
44 | Samsung's own development board, geared for PDA work. | 46 | Samsung's own development board, geared for PDA work. |
45 | 47 | ||
48 | Samsung/Aiji SMDK2412 | ||
49 | |||
50 | The S3C2412 version of the SMDK2440. | ||
51 | |||
52 | Samsung/Aiji SMDK2413 | ||
53 | |||
54 | The S3C2412 version of the SMDK2440. | ||
55 | |||
46 | Samsung/Meritech SMDK2440 | 56 | Samsung/Meritech SMDK2440 |
47 | 57 | ||
48 | The S3C2440 compatible version of the SMDK2440 | 58 | The S3C2440 compatible version of the SMDK2440, which has the |
59 | option of an S3C2440 or S3C2442 CPU module. | ||
49 | 60 | ||
50 | Thorcom VR1000 | 61 | Thorcom VR1000 |
51 | 62 | ||
@@ -211,24 +222,6 @@ Port Contributors | |||
211 | Lucas Correia Villa Real (S3C2400 port) | 222 | Lucas Correia Villa Real (S3C2400 port) |
212 | 223 | ||
213 | 224 | ||
214 | Document Changes | ||
215 | ---------------- | ||
216 | |||
217 | 05 Sep 2004 - BJD - Added Document Changes section | ||
218 | 05 Sep 2004 - BJD - Added Klaus Fetscher to list of contributors | ||
219 | 25 Oct 2004 - BJD - Added Dimitry Andric to list of contributors | ||
220 | 25 Oct 2004 - BJD - Updated the MTD from the 2.6.9 merge | ||
221 | 21 Jan 2005 - BJD - Added rx3715, added Shannon to contributors | ||
222 | 10 Feb 2005 - BJD - Added Guillaume Gourat to contributors | ||
223 | 02 Mar 2005 - BJD - Added SMDK2440 to list of machines | ||
224 | 06 Mar 2005 - BJD - Added Christer Weinigel | ||
225 | 08 Mar 2005 - BJD - Added LCVR to list of people, updated introduction | ||
226 | 08 Mar 2005 - BJD - Added section on adding machines | ||
227 | 09 Sep 2005 - BJD - Added section on platform data | ||
228 | 11 Feb 2006 - BJD - Added I2C, RTC and Watchdog sections | ||
229 | 11 Feb 2006 - BJD - Added Osiris machine, and S3C2400 information | ||
230 | |||
231 | |||
232 | Document Author | 225 | Document Author |
233 | --------------- | 226 | --------------- |
234 | 227 | ||
diff --git a/Documentation/arm/Samsung-S3C24XX/S3C2412.txt b/Documentation/arm/Samsung-S3C24XX/S3C2412.txt new file mode 100644 index 000000000000..cb82a7fc7901 --- /dev/null +++ b/Documentation/arm/Samsung-S3C24XX/S3C2412.txt | |||
@@ -0,0 +1,120 @@ | |||
1 | S3C2412 ARM Linux Overview | ||
2 | ========================== | ||
3 | |||
4 | Introduction | ||
5 | ------------ | ||
6 | |||
7 | The S3C2412 is part of the S3C24XX range of ARM9 System-on-Chip CPUs | ||
8 | from Samsung. This part has an ARM926-EJS core, capable of running up | ||
9 | to 266MHz (see data-sheet for more information) | ||
10 | |||
11 | |||
12 | Clock | ||
13 | ----- | ||
14 | |||
15 | The core clock code provides a set of clocks to the drivers, and allows | ||
16 | for source selection and a number of other features. | ||
17 | |||
18 | |||
19 | Power | ||
20 | ----- | ||
21 | |||
22 | No support for suspend/resume to RAM in the current system. | ||
23 | |||
24 | |||
25 | DMA | ||
26 | --- | ||
27 | |||
28 | No current support for DMA. | ||
29 | |||
30 | |||
31 | GPIO | ||
32 | ---- | ||
33 | |||
34 | There is support for setting the GPIO to input/output/special function | ||
35 | and reading or writing to them. | ||
36 | |||
37 | |||
38 | UART | ||
39 | ---- | ||
40 | |||
41 | The UART hardware is similar to the S3C2440, and is supported by the | ||
42 | s3c2410 driver in the drivers/serial directory. | ||
43 | |||
44 | |||
45 | NAND | ||
46 | ---- | ||
47 | |||
48 | The NAND hardware is similar to the S3C2440, and is supported by the | ||
49 | s3c2410 driver in the drivers/mtd/nand directory. | ||
50 | |||
51 | |||
52 | USB Host | ||
53 | -------- | ||
54 | |||
55 | The USB hardware is similar to the S3C2410, with extended clock source | ||
56 | control. The OHCI portion is supported by the ohci-s3c2410 driver, and | ||
57 | the clock control selection is supported by the core clock code. | ||
58 | |||
59 | |||
60 | USB Device | ||
61 | ---------- | ||
62 | |||
63 | No current support in the kernel | ||
64 | |||
65 | |||
66 | IRQs | ||
67 | ---- | ||
68 | |||
69 | All the standard, and external interrupt sources are supported. The | ||
70 | extra sub-sources are not yet supported. | ||
71 | |||
72 | |||
73 | RTC | ||
74 | --- | ||
75 | |||
76 | The RTC hardware is similar to the S3C2410, and is supported by the | ||
77 | s3c2410-rtc driver. | ||
78 | |||
79 | |||
80 | Watchdog | ||
81 | -------- | ||
82 | |||
83 | The watchdog harware is the same as the S3C2410, and is supported by | ||
84 | the s3c2410_wdt driver. | ||
85 | |||
86 | |||
87 | MMC/SD/SDIO | ||
88 | ----------- | ||
89 | |||
90 | No current support for the MMC/SD/SDIO block. | ||
91 | |||
92 | IIC | ||
93 | --- | ||
94 | |||
95 | The IIC hardware is the same as the S3C2410, and is supported by the | ||
96 | i2c-s3c24xx driver. | ||
97 | |||
98 | |||
99 | IIS | ||
100 | --- | ||
101 | |||
102 | No current support for the IIS interface. | ||
103 | |||
104 | |||
105 | SPI | ||
106 | --- | ||
107 | |||
108 | No current support for the SPI interfaces. | ||
109 | |||
110 | |||
111 | ATA | ||
112 | --- | ||
113 | |||
114 | No current support for the on-board ATA block. | ||
115 | |||
116 | |||
117 | Document Author | ||
118 | --------------- | ||
119 | |||
120 | Ben Dooks, (c) 2006 Simtec Electronics | ||
diff --git a/Documentation/arm/Samsung-S3C24XX/S3C2413.txt b/Documentation/arm/Samsung-S3C24XX/S3C2413.txt new file mode 100644 index 000000000000..ab2a88858f12 --- /dev/null +++ b/Documentation/arm/Samsung-S3C24XX/S3C2413.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | S3C2413 ARM Linux Overview | ||
2 | ========================== | ||
3 | |||
4 | Introduction | ||
5 | ------------ | ||
6 | |||
7 | The S3C2413 is an extended version of the S3C2412, with an camera | ||
8 | interface and mobile DDR memory support. See the S3C2412 support | ||
9 | documentation for more information. | ||
10 | |||
11 | |||
12 | Camera Interface | ||
13 | --------------- | ||
14 | |||
15 | This block is currently not supported. | ||
16 | |||
17 | |||
18 | Document Author | ||
19 | --------------- | ||
20 | |||
21 | Ben Dooks, (c) 2006 Simtec Electronics | ||
diff --git a/Documentation/atomic_ops.txt b/Documentation/atomic_ops.txt index 23a1c2402bcc..2a63d5662a93 100644 --- a/Documentation/atomic_ops.txt +++ b/Documentation/atomic_ops.txt | |||
@@ -157,13 +157,13 @@ For example, smp_mb__before_atomic_dec() can be used like so: | |||
157 | smp_mb__before_atomic_dec(); | 157 | smp_mb__before_atomic_dec(); |
158 | atomic_dec(&obj->ref_count); | 158 | atomic_dec(&obj->ref_count); |
159 | 159 | ||
160 | It makes sure that all memory operations preceeding the atomic_dec() | 160 | It makes sure that all memory operations preceding the atomic_dec() |
161 | call are strongly ordered with respect to the atomic counter | 161 | call are strongly ordered with respect to the atomic counter |
162 | operation. In the above example, it guarentees that the assignment of | 162 | operation. In the above example, it guarantees that the assignment of |
163 | "1" to obj->dead will be globally visible to other cpus before the | 163 | "1" to obj->dead will be globally visible to other cpus before the |
164 | atomic counter decrement. | 164 | atomic counter decrement. |
165 | 165 | ||
166 | Without the explicitl smp_mb__before_atomic_dec() call, the | 166 | Without the explicit smp_mb__before_atomic_dec() call, the |
167 | implementation could legally allow the atomic counter update visible | 167 | implementation could legally allow the atomic counter update visible |
168 | to other cpus before the "obj->dead = 1;" assignment. | 168 | to other cpus before the "obj->dead = 1;" assignment. |
169 | 169 | ||
@@ -173,11 +173,11 @@ ordering with respect to memory operations after an atomic_dec() call | |||
173 | (smp_mb__{before,after}_atomic_inc()). | 173 | (smp_mb__{before,after}_atomic_inc()). |
174 | 174 | ||
175 | A missing memory barrier in the cases where they are required by the | 175 | A missing memory barrier in the cases where they are required by the |
176 | atomic_t implementation above can have disasterous results. Here is | 176 | atomic_t implementation above can have disastrous results. Here is |
177 | an example, which follows a pattern occuring frequently in the Linux | 177 | an example, which follows a pattern occurring frequently in the Linux |
178 | kernel. It is the use of atomic counters to implement reference | 178 | kernel. It is the use of atomic counters to implement reference |
179 | counting, and it works such that once the counter falls to zero it can | 179 | counting, and it works such that once the counter falls to zero it can |
180 | be guarenteed that no other entity can be accessing the object: | 180 | be guaranteed that no other entity can be accessing the object: |
181 | 181 | ||
182 | static void obj_list_add(struct obj *obj) | 182 | static void obj_list_add(struct obj *obj) |
183 | { | 183 | { |
@@ -291,9 +291,9 @@ to the size of an "unsigned long" C data type, and are least of that | |||
291 | size. The endianness of the bits within each "unsigned long" are the | 291 | size. The endianness of the bits within each "unsigned long" are the |
292 | native endianness of the cpu. | 292 | native endianness of the cpu. |
293 | 293 | ||
294 | void set_bit(unsigned long nr, volatils unsigned long *addr); | 294 | void set_bit(unsigned long nr, volatile unsigned long *addr); |
295 | void clear_bit(unsigned long nr, volatils unsigned long *addr); | 295 | void clear_bit(unsigned long nr, volatile unsigned long *addr); |
296 | void change_bit(unsigned long nr, volatils unsigned long *addr); | 296 | void change_bit(unsigned long nr, volatile unsigned long *addr); |
297 | 297 | ||
298 | These routines set, clear, and change, respectively, the bit number | 298 | These routines set, clear, and change, respectively, the bit number |
299 | indicated by "nr" on the bit mask pointed to by "ADDR". | 299 | indicated by "nr" on the bit mask pointed to by "ADDR". |
@@ -301,9 +301,9 @@ indicated by "nr" on the bit mask pointed to by "ADDR". | |||
301 | They must execute atomically, yet there are no implicit memory barrier | 301 | They must execute atomically, yet there are no implicit memory barrier |
302 | semantics required of these interfaces. | 302 | semantics required of these interfaces. |
303 | 303 | ||
304 | int test_and_set_bit(unsigned long nr, volatils unsigned long *addr); | 304 | int test_and_set_bit(unsigned long nr, volatile unsigned long *addr); |
305 | int test_and_clear_bit(unsigned long nr, volatils unsigned long *addr); | 305 | int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr); |
306 | int test_and_change_bit(unsigned long nr, volatils unsigned long *addr); | 306 | int test_and_change_bit(unsigned long nr, volatile unsigned long *addr); |
307 | 307 | ||
308 | Like the above, except that these routines return a boolean which | 308 | Like the above, except that these routines return a boolean which |
309 | indicates whether the changed bit was set _BEFORE_ the atomic bit | 309 | indicates whether the changed bit was set _BEFORE_ the atomic bit |
@@ -335,7 +335,7 @@ subsequent memory operation is made visible. For example: | |||
335 | /* ... */; | 335 | /* ... */; |
336 | obj->killed = 1; | 336 | obj->killed = 1; |
337 | 337 | ||
338 | The implementation of test_and_set_bit() must guarentee that | 338 | The implementation of test_and_set_bit() must guarantee that |
339 | "obj->dead = 1;" is visible to cpus before the atomic memory operation | 339 | "obj->dead = 1;" is visible to cpus before the atomic memory operation |
340 | done by test_and_set_bit() becomes visible. Likewise, the atomic | 340 | done by test_and_set_bit() becomes visible. Likewise, the atomic |
341 | memory operation done by test_and_set_bit() must become visible before | 341 | memory operation done by test_and_set_bit() must become visible before |
@@ -474,7 +474,7 @@ Now, as far as memory barriers go, as long as spin_lock() | |||
474 | strictly orders all subsequent memory operations (including | 474 | strictly orders all subsequent memory operations (including |
475 | the cas()) with respect to itself, things will be fine. | 475 | the cas()) with respect to itself, things will be fine. |
476 | 476 | ||
477 | Said another way, _atomic_dec_and_lock() must guarentee that | 477 | Said another way, _atomic_dec_and_lock() must guarantee that |
478 | a counter dropping to zero is never made visible before the | 478 | a counter dropping to zero is never made visible before the |
479 | spinlock being acquired. | 479 | spinlock being acquired. |
480 | 480 | ||
diff --git a/Documentation/console/console.txt b/Documentation/console/console.txt new file mode 100644 index 000000000000..d3e17447321c --- /dev/null +++ b/Documentation/console/console.txt | |||
@@ -0,0 +1,144 @@ | |||
1 | Console Drivers | ||
2 | =============== | ||
3 | |||
4 | The linux kernel has 2 general types of console drivers. The first type is | ||
5 | assigned by the kernel to all the virtual consoles during the boot process. | ||
6 | This type will be called 'system driver', and only one system driver is allowed | ||
7 | to exist. The system driver is persistent and it can never be unloaded, though | ||
8 | it may become inactive. | ||
9 | |||
10 | The second type has to be explicitly loaded and unloaded. This will be called | ||
11 | 'modular driver' by this document. Multiple modular drivers can coexist at | ||
12 | any time with each driver sharing the console with other drivers including | ||
13 | the system driver. However, modular drivers cannot take over the console | ||
14 | that is currently occupied by another modular driver. (Exception: Drivers that | ||
15 | call take_over_console() will succeed in the takeover regardless of the type | ||
16 | of driver occupying the consoles.) They can only take over the console that is | ||
17 | occupied by the system driver. In the same token, if the modular driver is | ||
18 | released by the console, the system driver will take over. | ||
19 | |||
20 | Modular drivers, from the programmer's point of view, has to call: | ||
21 | |||
22 | take_over_console() - load and bind driver to console layer | ||
23 | give_up_console() - unbind and unload driver | ||
24 | |||
25 | In newer kernels, the following are also available: | ||
26 | |||
27 | register_con_driver() | ||
28 | unregister_con_driver() | ||
29 | |||
30 | If sysfs is enabled, the contents of /sys/class/vtconsole can be | ||
31 | examined. This shows the console backends currently registered by the | ||
32 | system which are named vtcon<n> where <n> is an integer fro 0 to 15. Thus: | ||
33 | |||
34 | ls /sys/class/vtconsole | ||
35 | . .. vtcon0 vtcon1 | ||
36 | |||
37 | Each directory in /sys/class/vtconsole has 3 files: | ||
38 | |||
39 | ls /sys/class/vtconsole/vtcon0 | ||
40 | . .. bind name uevent | ||
41 | |||
42 | What do these files signify? | ||
43 | |||
44 | 1. bind - this is a read/write file. It shows the status of the driver if | ||
45 | read, or acts to bind or unbind the driver to the virtual consoles | ||
46 | when written to. The possible values are: | ||
47 | |||
48 | 0 - means the driver is not bound and if echo'ed, commands the driver | ||
49 | to unbind | ||
50 | |||
51 | 1 - means the driver is bound and if echo'ed, commands the driver to | ||
52 | bind | ||
53 | |||
54 | 2. name - read-only file. Shows the name of the driver in this format: | ||
55 | |||
56 | cat /sys/class/vtconsole/vtcon0/name | ||
57 | (S) VGA+ | ||
58 | |||
59 | '(S)' stands for a (S)ystem driver, ie, it cannot be directly | ||
60 | commanded to bind or unbind | ||
61 | |||
62 | 'VGA+' is the name of the driver | ||
63 | |||
64 | cat /sys/class/vtconsole/vtcon1/name | ||
65 | (M) frame buffer device | ||
66 | |||
67 | In this case, '(M)' stands for a (M)odular driver, one that can be | ||
68 | directly commanded to bind or unbind. | ||
69 | |||
70 | 3. uevent - ignore this file | ||
71 | |||
72 | When unbinding, the modular driver is detached first, and then the system | ||
73 | driver takes over the consoles vacated by the driver. Binding, on the other | ||
74 | hand, will bind the driver to the consoles that are currently occupied by a | ||
75 | system driver. | ||
76 | |||
77 | NOTE1: Binding and binding must be selected in Kconfig. It's under: | ||
78 | |||
79 | Device Drivers -> Character devices -> Support for binding and unbinding | ||
80 | console drivers | ||
81 | |||
82 | NOTE2: If any of the virtual consoles are in KD_GRAPHICS mode, then binding or | ||
83 | unbinding will not succeed. An example of an application that sets the console | ||
84 | to KD_GRAPHICS is X. | ||
85 | |||
86 | How useful is this feature? This is very useful for console driver | ||
87 | developers. By unbinding the driver from the console layer, one can unload the | ||
88 | driver, make changes, recompile, reload and rebind the driver without any need | ||
89 | for rebooting the kernel. For regular users who may want to switch from | ||
90 | framebuffer console to VGA console and vice versa, this feature also makes | ||
91 | this possible. (NOTE NOTE NOTE: Please read fbcon.txt under Documentation/fb | ||
92 | for more details). | ||
93 | |||
94 | Notes for developers: | ||
95 | ===================== | ||
96 | |||
97 | take_over_console() is now broken up into: | ||
98 | |||
99 | register_con_driver() | ||
100 | bind_con_driver() - private function | ||
101 | |||
102 | give_up_console() is a wrapper to unregister_con_driver(), and a driver must | ||
103 | be fully unbound for this call to succeed. con_is_bound() will check if the | ||
104 | driver is bound or not. | ||
105 | |||
106 | Guidelines for console driver writers: | ||
107 | ===================================== | ||
108 | |||
109 | In order for binding to and unbinding from the console to properly work, | ||
110 | console drivers must follow these guidelines: | ||
111 | |||
112 | 1. All drivers, except system drivers, must call either register_con_driver() | ||
113 | or take_over_console(). register_con_driver() will just add the driver to | ||
114 | the console's internal list. It won't take over the | ||
115 | console. take_over_console(), as it name implies, will also take over (or | ||
116 | bind to) the console. | ||
117 | |||
118 | 2. All resources allocated during con->con_init() must be released in | ||
119 | con->con_deinit(). | ||
120 | |||
121 | 3. All resources allocated in con->con_startup() must be released when the | ||
122 | driver, which was previously bound, becomes unbound. The console layer | ||
123 | does not have a complementary call to con->con_startup() so it's up to the | ||
124 | driver to check when it's legal to release these resources. Calling | ||
125 | con_is_bound() in con->con_deinit() will help. If the call returned | ||
126 | false(), then it's safe to release the resources. This balance has to be | ||
127 | ensured because con->con_startup() can be called again when a request to | ||
128 | rebind the driver to the console arrives. | ||
129 | |||
130 | 4. Upon exit of the driver, ensure that the driver is totally unbound. If the | ||
131 | condition is satisfied, then the driver must call unregister_con_driver() | ||
132 | or give_up_console(). | ||
133 | |||
134 | 5. unregister_con_driver() can also be called on conditions which make it | ||
135 | impossible for the driver to service console requests. This can happen | ||
136 | with the framebuffer console that suddenly lost all of its drivers. | ||
137 | |||
138 | The current crop of console drivers should still work correctly, but binding | ||
139 | and unbinding them may cause problems. With minimal fixes, these drivers can | ||
140 | be made to work correctly. | ||
141 | |||
142 | ========================== | ||
143 | Antonino Daplas <adaplas@pol.net> | ||
144 | |||
diff --git a/Documentation/driver-model/overview.txt b/Documentation/driver-model/overview.txt index ac4a7a737e43..2050c9ffc629 100644 --- a/Documentation/driver-model/overview.txt +++ b/Documentation/driver-model/overview.txt | |||
@@ -18,7 +18,7 @@ Traditional driver models implemented some sort of tree-like structure | |||
18 | (sometimes just a list) for the devices they control. There wasn't any | 18 | (sometimes just a list) for the devices they control. There wasn't any |
19 | uniformity across the different bus types. | 19 | uniformity across the different bus types. |
20 | 20 | ||
21 | The current driver model provides a comon, uniform data model for describing | 21 | The current driver model provides a common, uniform data model for describing |
22 | a bus and the devices that can appear under the bus. The unified bus | 22 | a bus and the devices that can appear under the bus. The unified bus |
23 | model includes a set of common attributes which all busses carry, and a set | 23 | model includes a set of common attributes which all busses carry, and a set |
24 | of common callbacks, such as device discovery during bus probing, bus | 24 | of common callbacks, such as device discovery during bus probing, bus |
diff --git a/Documentation/fb/fbcon.txt b/Documentation/fb/fbcon.txt index 08dce0f631bf..f373df12ed4c 100644 --- a/Documentation/fb/fbcon.txt +++ b/Documentation/fb/fbcon.txt | |||
@@ -135,10 +135,10 @@ C. Boot options | |||
135 | 135 | ||
136 | The angle can be changed anytime afterwards by 'echoing' the same | 136 | The angle can be changed anytime afterwards by 'echoing' the same |
137 | numbers to any one of the 2 attributes found in | 137 | numbers to any one of the 2 attributes found in |
138 | /sys/class/graphics/fb{x} | 138 | /sys/class/graphics/fbcon |
139 | 139 | ||
140 | con_rotate - rotate the display of the active console | 140 | rotate - rotate the display of the active console |
141 | con_rotate_all - rotate the display of all consoles | 141 | rotate_all - rotate the display of all consoles |
142 | 142 | ||
143 | Console rotation will only become available if Console Rotation | 143 | Console rotation will only become available if Console Rotation |
144 | Support is compiled in your kernel. | 144 | Support is compiled in your kernel. |
@@ -148,5 +148,177 @@ C. Boot options | |||
148 | Actually, the underlying fb driver is totally ignorant of console | 148 | Actually, the underlying fb driver is totally ignorant of console |
149 | rotation. | 149 | rotation. |
150 | 150 | ||
151 | --- | 151 | C. Attaching, Detaching and Unloading |
152 | |||
153 | Before going on on how to attach, detach and unload the framebuffer console, an | ||
154 | illustration of the dependencies may help. | ||
155 | |||
156 | The console layer, as with most subsystems, needs a driver that interfaces with | ||
157 | the hardware. Thus, in a VGA console: | ||
158 | |||
159 | console ---> VGA driver ---> hardware. | ||
160 | |||
161 | Assuming the VGA driver can be unloaded, one must first unbind the VGA driver | ||
162 | from the console layer before unloading the driver. The VGA driver cannot be | ||
163 | unloaded if it is still bound to the console layer. (See | ||
164 | Documentation/console/console.txt for more information). | ||
165 | |||
166 | This is more complicated in the case of the the framebuffer console (fbcon), | ||
167 | because fbcon is an intermediate layer between the console and the drivers: | ||
168 | |||
169 | console ---> fbcon ---> fbdev drivers ---> hardware | ||
170 | |||
171 | The fbdev drivers cannot be unloaded if it's bound to fbcon, and fbcon cannot | ||
172 | be unloaded if it's bound to the console layer. | ||
173 | |||
174 | So to unload the fbdev drivers, one must first unbind fbcon from the console, | ||
175 | then unbind the fbdev drivers from fbcon. Fortunately, unbinding fbcon from | ||
176 | the console layer will automatically unbind framebuffer drivers from | ||
177 | fbcon. Thus, there is no need to explicitly unbind the fbdev drivers from | ||
178 | fbcon. | ||
179 | |||
180 | So, how do we unbind fbcon from the console? Part of the answer is in | ||
181 | Documentation/console/console.txt. To summarize: | ||
182 | |||
183 | Echo a value to the bind file that represents the framebuffer console | ||
184 | driver. So assuming vtcon1 represents fbcon, then: | ||
185 | |||
186 | echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console to | ||
187 | console layer | ||
188 | echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from | ||
189 | console layer | ||
190 | |||
191 | If fbcon is detached from the console layer, your boot console driver (which is | ||
192 | usually VGA text mode) will take over. A few drivers (rivafb and i810fb) will | ||
193 | restore VGA text mode for you. With the rest, before detaching fbcon, you | ||
194 | must take a few additional steps to make sure that your VGA text mode is | ||
195 | restored properly. The following is one of the several methods that you can do: | ||
196 | |||
197 | 1. Download or install vbetool. This utility is included with most | ||
198 | distributions nowadays, and is usually part of the suspend/resume tool. | ||
199 | |||
200 | 2. In your kernel configuration, ensure that CONFIG_FRAMEBUFFER_CONSOLE is set | ||
201 | to 'y' or 'm'. Enable one or more of your favorite framebuffer drivers. | ||
202 | |||
203 | 3. Boot into text mode and as root run: | ||
204 | |||
205 | vbetool vbestate save > <vga state file> | ||
206 | |||
207 | The above command saves the register contents of your graphics | ||
208 | hardware to <vga state file>. You need to do this step only once as | ||
209 | the state file can be reused. | ||
210 | |||
211 | 4. If fbcon is compiled as a module, load fbcon by doing: | ||
212 | |||
213 | modprobe fbcon | ||
214 | |||
215 | 5. Now to detach fbcon: | ||
216 | |||
217 | vbetool vbestate restore < <vga state file> && \ | ||
218 | echo 0 > /sys/class/vtconsole/vtcon1/bind | ||
219 | |||
220 | 6. That's it, you're back to VGA mode. And if you compiled fbcon as a module, | ||
221 | you can unload it by 'rmmod fbcon' | ||
222 | |||
223 | 7. To reattach fbcon: | ||
224 | |||
225 | echo 1 > /sys/class/vtconsole/vtcon1/bind | ||
226 | |||
227 | 8. Once fbcon is unbound, all drivers registered to the system will also | ||
228 | become unbound. This means that fbcon and individual framebuffer drivers | ||
229 | can be unloaded or reloaded at will. Reloading the drivers or fbcon will | ||
230 | automatically bind the console, fbcon and the drivers together. Unloading | ||
231 | all the drivers without unloading fbcon will make it impossible for the | ||
232 | console to bind fbcon. | ||
233 | |||
234 | Notes for vesafb users: | ||
235 | ======================= | ||
236 | |||
237 | Unfortunately, if your bootline includes a vga=xxx parameter that sets the | ||
238 | hardware in graphics mode, such as when loading vesafb, vgacon will not load. | ||
239 | Instead, vgacon will replace the default boot console with dummycon, and you | ||
240 | won't get any display after detaching fbcon. Your machine is still alive, so | ||
241 | you can reattach vesafb. However, to reattach vesafb, you need to do one of | ||
242 | the following: | ||
243 | |||
244 | Variation 1: | ||
245 | |||
246 | a. Before detaching fbcon, do | ||
247 | |||
248 | vbetool vbemode save > <vesa state file> # do once for each vesafb mode, | ||
249 | # the file can be reused | ||
250 | |||
251 | b. Detach fbcon as in step 5. | ||
252 | |||
253 | c. Attach fbcon | ||
254 | |||
255 | vbetool vbestate restore < <vesa state file> && \ | ||
256 | echo 1 > /sys/class/vtconsole/vtcon1/bind | ||
257 | |||
258 | Variation 2: | ||
259 | |||
260 | a. Before detaching fbcon, do: | ||
261 | echo <ID> > /sys/class/tty/console/bind | ||
262 | |||
263 | |||
264 | vbetool vbemode get | ||
265 | |||
266 | b. Take note of the mode number | ||
267 | |||
268 | b. Detach fbcon as in step 5. | ||
269 | |||
270 | c. Attach fbcon: | ||
271 | |||
272 | vbetool vbemode set <mode number> && \ | ||
273 | echo 1 > /sys/class/vtconsole/vtcon1/bind | ||
274 | |||
275 | Samples: | ||
276 | ======== | ||
277 | |||
278 | Here are 2 sample bash scripts that you can use to bind or unbind the | ||
279 | framebuffer console driver if you are in an X86 box: | ||
280 | |||
281 | --------------------------------------------------------------------------- | ||
282 | #!/bin/bash | ||
283 | # Unbind fbcon | ||
284 | |||
285 | # Change this to where your actual vgastate file is located | ||
286 | # Or Use VGASTATE=$1 to indicate the state file at runtime | ||
287 | VGASTATE=/tmp/vgastate | ||
288 | |||
289 | # path to vbetool | ||
290 | VBETOOL=/usr/local/bin | ||
291 | |||
292 | |||
293 | for (( i = 0; i < 16; i++)) | ||
294 | do | ||
295 | if test -x /sys/class/vtconsole/vtcon$i; then | ||
296 | if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \ | ||
297 | = 1 ]; then | ||
298 | if test -x $VBETOOL/vbetool; then | ||
299 | echo Unbinding vtcon$i | ||
300 | $VBETOOL/vbetool vbestate restore < $VGASTATE | ||
301 | echo 0 > /sys/class/vtconsole/vtcon$i/bind | ||
302 | fi | ||
303 | fi | ||
304 | fi | ||
305 | done | ||
306 | |||
307 | --------------------------------------------------------------------------- | ||
308 | #!/bin/bash | ||
309 | # Bind fbcon | ||
310 | |||
311 | for (( i = 0; i < 16; i++)) | ||
312 | do | ||
313 | if test -x /sys/class/vtconsole/vtcon$i; then | ||
314 | if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \ | ||
315 | = 1 ]; then | ||
316 | echo Unbinding vtcon$i | ||
317 | echo 1 > /sys/class/vtconsole/vtcon$i/bind | ||
318 | fi | ||
319 | fi | ||
320 | done | ||
321 | --------------------------------------------------------------------------- | ||
322 | |||
323 | -- | ||
152 | Antonino Daplas <adaplas@pol.net> | 324 | Antonino Daplas <adaplas@pol.net> |
diff --git a/Documentation/filesystems/ext3.txt b/Documentation/filesystems/ext3.txt index afb1335c05d6..4aecc9bdb273 100644 --- a/Documentation/filesystems/ext3.txt +++ b/Documentation/filesystems/ext3.txt | |||
@@ -113,6 +113,14 @@ noquota | |||
113 | grpquota | 113 | grpquota |
114 | usrquota | 114 | usrquota |
115 | 115 | ||
116 | bh (*) ext3 associates buffer heads to data pages to | ||
117 | nobh (a) cache disk block mapping information | ||
118 | (b) link pages into transaction to provide | ||
119 | ordering guarantees. | ||
120 | "bh" option forces use of buffer heads. | ||
121 | "nobh" option tries to avoid associating buffer | ||
122 | heads (supported only for "writeback" mode). | ||
123 | |||
116 | 124 | ||
117 | Specification | 125 | Specification |
118 | ============= | 126 | ============= |
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index a9c00facdf40..14ef3868a328 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
@@ -1123,6 +1123,14 @@ The top Makefile exports the following variables: | |||
1123 | $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE). The user may | 1123 | $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE). The user may |
1124 | override this value on the command line if desired. | 1124 | override this value on the command line if desired. |
1125 | 1125 | ||
1126 | INSTALL_MOD_STRIP | ||
1127 | |||
1128 | If this variable is specified, will cause modules to be stripped | ||
1129 | after they are installed. If INSTALL_MOD_STRIP is '1', then the | ||
1130 | default option --strip-debug will be used. Otherwise, | ||
1131 | INSTALL_MOD_STRIP will used as the option(s) to the strip command. | ||
1132 | |||
1133 | |||
1126 | === 8 Makefile language | 1134 | === 8 Makefile language |
1127 | 1135 | ||
1128 | The kernel Makefiles are designed to run with GNU Make. The Makefiles | 1136 | The kernel Makefiles are designed to run with GNU Make. The Makefiles |
diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt index dcf5580380ab..9b9b454b048a 100644 --- a/Documentation/kdump/gdbmacros.txt +++ b/Documentation/kdump/gdbmacros.txt | |||
@@ -175,7 +175,7 @@ end | |||
175 | document trapinfo | 175 | document trapinfo |
176 | Run info threads and lookup pid of thread #1 | 176 | Run info threads and lookup pid of thread #1 |
177 | 'trapinfo <pid>' will tell you by which trap & possibly | 177 | 'trapinfo <pid>' will tell you by which trap & possibly |
178 | addresthe kernel paniced. | 178 | address the kernel panicked. |
179 | end | 179 | end |
180 | 180 | ||
181 | 181 | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index bca6f389da66..0d189c93eeaf 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -61,6 +61,7 @@ parameter is applicable: | |||
61 | MTD MTD support is enabled. | 61 | MTD MTD support is enabled. |
62 | NET Appropriate network support is enabled. | 62 | NET Appropriate network support is enabled. |
63 | NUMA NUMA support is enabled. | 63 | NUMA NUMA support is enabled. |
64 | GENERIC_TIME The generic timeofday code is enabled. | ||
64 | NFS Appropriate NFS support is enabled. | 65 | NFS Appropriate NFS support is enabled. |
65 | OSS OSS sound support is enabled. | 66 | OSS OSS sound support is enabled. |
66 | PARIDE The ParIDE subsystem is enabled. | 67 | PARIDE The ParIDE subsystem is enabled. |
@@ -179,6 +180,11 @@ running once the system is up. | |||
179 | override platform specific driver. | 180 | override platform specific driver. |
180 | See also Documentation/acpi-hotkey.txt. | 181 | See also Documentation/acpi-hotkey.txt. |
181 | 182 | ||
183 | acpi_pm_good [IA-32,X86-64] | ||
184 | Override the pmtimer bug detection: force the kernel | ||
185 | to assume that this machine's pmtimer latches its value | ||
186 | and always returns good values. | ||
187 | |||
182 | enable_timer_pin_1 [i386,x86-64] | 188 | enable_timer_pin_1 [i386,x86-64] |
183 | Enable PIN 1 of APIC timer | 189 | Enable PIN 1 of APIC timer |
184 | Can be useful to work around chipset bugs | 190 | Can be useful to work around chipset bugs |
@@ -341,10 +347,11 @@ running once the system is up. | |||
341 | Value can be changed at runtime via | 347 | Value can be changed at runtime via |
342 | /selinux/checkreqprot. | 348 | /selinux/checkreqprot. |
343 | 349 | ||
344 | clock= [BUGS=IA-32,HW] gettimeofday timesource override. | 350 | clock= [BUGS=IA-32, HW] gettimeofday clocksource override. |
345 | Forces specified timesource (if avaliable) to be used | 351 | [Deprecated] |
346 | when calculating gettimeofday(). If specicified | 352 | Forces specified clocksource (if avaliable) to be used |
347 | timesource is not avalible, it defaults to PIT. | 353 | when calculating gettimeofday(). If specified |
354 | clocksource is not avalible, it defaults to PIT. | ||
348 | Format: { pit | tsc | cyclone | pmtmr } | 355 | Format: { pit | tsc | cyclone | pmtmr } |
349 | 356 | ||
350 | disable_8254_timer | 357 | disable_8254_timer |
@@ -1617,6 +1624,10 @@ running once the system is up. | |||
1617 | 1624 | ||
1618 | time Show timing data prefixed to each printk message line | 1625 | time Show timing data prefixed to each printk message line |
1619 | 1626 | ||
1627 | clocksource= [GENERIC_TIME] Override the default clocksource | ||
1628 | Override the default clocksource and use the clocksource | ||
1629 | with the name specified. | ||
1630 | |||
1620 | tipar.timeout= [HW,PPT] | 1631 | tipar.timeout= [HW,PPT] |
1621 | Set communications timeout in tenths of a second | 1632 | Set communications timeout in tenths of a second |
1622 | (default 15). | 1633 | (default 15). |
@@ -1658,6 +1669,10 @@ running once the system is up. | |||
1658 | usbhid.mousepoll= | 1669 | usbhid.mousepoll= |
1659 | [USBHID] The interval which mice are to be polled at. | 1670 | [USBHID] The interval which mice are to be polled at. |
1660 | 1671 | ||
1672 | vdso= [IA-32] | ||
1673 | vdso=1: enable VDSO (default) | ||
1674 | vdso=0: disable VDSO mapping | ||
1675 | |||
1661 | video= [FB] Frame buffer configuration | 1676 | video= [FB] Frame buffer configuration |
1662 | See Documentation/fb/modedb.txt. | 1677 | See Documentation/fb/modedb.txt. |
1663 | 1678 | ||
diff --git a/Documentation/keys.txt b/Documentation/keys.txt index 3bbe157b45e4..61c0fad2fe2f 100644 --- a/Documentation/keys.txt +++ b/Documentation/keys.txt | |||
@@ -241,25 +241,30 @@ The security class "key" has been added to SELinux so that mandatory access | |||
241 | controls can be applied to keys created within various contexts. This support | 241 | controls can be applied to keys created within various contexts. This support |
242 | is preliminary, and is likely to change quite significantly in the near future. | 242 | is preliminary, and is likely to change quite significantly in the near future. |
243 | Currently, all of the basic permissions explained above are provided in SELinux | 243 | Currently, all of the basic permissions explained above are provided in SELinux |
244 | as well; SE Linux is simply invoked after all basic permission checks have been | 244 | as well; SELinux is simply invoked after all basic permission checks have been |
245 | performed. | 245 | performed. |
246 | 246 | ||
247 | Each key is labeled with the same context as the task to which it belongs. | 247 | The value of the file /proc/self/attr/keycreate influences the labeling of |
248 | Typically, this is the same task that was running when the key was created. | 248 | newly-created keys. If the contents of that file correspond to an SELinux |
249 | The default keyrings are handled differently, but in a way that is very | 249 | security context, then the key will be assigned that context. Otherwise, the |
250 | intuitive: | 250 | key will be assigned the current context of the task that invoked the key |
251 | creation request. Tasks must be granted explicit permission to assign a | ||
252 | particular context to newly-created keys, using the "create" permission in the | ||
253 | key security class. | ||
251 | 254 | ||
252 | (*) The user and user session keyrings that are created when the user logs in | 255 | The default keyrings associated with users will be labeled with the default |
253 | are currently labeled with the context of the login manager. | 256 | context of the user if and only if the login programs have been instrumented to |
254 | 257 | properly initialize keycreate during the login process. Otherwise, they will | |
255 | (*) The keyrings associated with new threads are each labeled with the context | 258 | be labeled with the context of the login program itself. |
256 | of their associated thread, and both session and process keyrings are | ||
257 | handled similarly. | ||
258 | 259 | ||
259 | Note, however, that the default keyrings associated with the root user are | 260 | Note, however, that the default keyrings associated with the root user are |
260 | labeled with the default kernel context, since they are created early in the | 261 | labeled with the default kernel context, since they are created early in the |
261 | boot process, before root has a chance to log in. | 262 | boot process, before root has a chance to log in. |
262 | 263 | ||
264 | The keyrings associated with new threads are each labeled with the context of | ||
265 | their associated thread, and both session and process keyrings are handled | ||
266 | similarly. | ||
267 | |||
263 | 268 | ||
264 | ================ | 269 | ================ |
265 | NEW PROCFS FILES | 270 | NEW PROCFS FILES |
@@ -270,9 +275,17 @@ about the status of the key service: | |||
270 | 275 | ||
271 | (*) /proc/keys | 276 | (*) /proc/keys |
272 | 277 | ||
273 | This lists all the keys on the system, giving information about their | 278 | This lists the keys that are currently viewable by the task reading the |
274 | type, description and permissions. The payload of the key is not available | 279 | file, giving information about their type, description and permissions. |
275 | this way: | 280 | It is not possible to view the payload of the key this way, though some |
281 | information about it may be given. | ||
282 | |||
283 | The only keys included in the list are those that grant View permission to | ||
284 | the reading process whether or not it possesses them. Note that LSM | ||
285 | security checks are still performed, and may further filter out keys that | ||
286 | the current process is not authorised to view. | ||
287 | |||
288 | The contents of the file look like this: | ||
276 | 289 | ||
277 | SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY | 290 | SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY |
278 | 00000001 I----- 39 perm 1f3f0000 0 0 keyring _uid_ses.0: 1/4 | 291 | 00000001 I----- 39 perm 1f3f0000 0 0 keyring _uid_ses.0: 1/4 |
@@ -300,7 +313,7 @@ about the status of the key service: | |||
300 | (*) /proc/key-users | 313 | (*) /proc/key-users |
301 | 314 | ||
302 | This file lists the tracking data for each user that has at least one key | 315 | This file lists the tracking data for each user that has at least one key |
303 | on the system. Such data includes quota information and statistics: | 316 | on the system. Such data includes quota information and statistics: |
304 | 317 | ||
305 | [root@andromeda root]# cat /proc/key-users | 318 | [root@andromeda root]# cat /proc/key-users |
306 | 0: 46 45/45 1/100 13/10000 | 319 | 0: 46 45/45 1/100 13/10000 |
diff --git a/Documentation/md.txt b/Documentation/md.txt index 03a13c462cf2..0668f9dc9d29 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt | |||
@@ -200,6 +200,17 @@ All md devices contain: | |||
200 | This can be written only while the array is being assembled, not | 200 | This can be written only while the array is being assembled, not |
201 | after it is started. | 201 | after it is started. |
202 | 202 | ||
203 | layout | ||
204 | The "layout" for the array for the particular level. This is | ||
205 | simply a number that is interpretted differently by different | ||
206 | levels. It can be written while assembling an array. | ||
207 | |||
208 | resync_start | ||
209 | The point at which resync should start. If no resync is needed, | ||
210 | this will be a very large number. At array creation it will | ||
211 | default to 0, though starting the array as 'clean' will | ||
212 | set it much larger. | ||
213 | |||
203 | new_dev | 214 | new_dev |
204 | This file can be written but not read. The value written should | 215 | This file can be written but not read. The value written should |
205 | be a block device number as major:minor. e.g. 8:0 | 216 | be a block device number as major:minor. e.g. 8:0 |
@@ -207,6 +218,54 @@ All md devices contain: | |||
207 | available. It will then appear at md/dev-XXX (depending on the | 218 | available. It will then appear at md/dev-XXX (depending on the |
208 | name of the device) and further configuration is then possible. | 219 | name of the device) and further configuration is then possible. |
209 | 220 | ||
221 | safe_mode_delay | ||
222 | When an md array has seen no write requests for a certain period | ||
223 | of time, it will be marked as 'clean'. When another write | ||
224 | request arrive, the array is marked as 'dirty' before the write | ||
225 | commenses. This is known as 'safe_mode'. | ||
226 | The 'certain period' is controlled by this file which stores the | ||
227 | period as a number of seconds. The default is 200msec (0.200). | ||
228 | Writing a value of 0 disables safemode. | ||
229 | |||
230 | array_state | ||
231 | This file contains a single word which describes the current | ||
232 | state of the array. In many cases, the state can be set by | ||
233 | writing the word for the desired state, however some states | ||
234 | cannot be explicitly set, and some transitions are not allowed. | ||
235 | |||
236 | clear | ||
237 | No devices, no size, no level | ||
238 | Writing is equivalent to STOP_ARRAY ioctl | ||
239 | inactive | ||
240 | May have some settings, but array is not active | ||
241 | all IO results in error | ||
242 | When written, doesn't tear down array, but just stops it | ||
243 | suspended (not supported yet) | ||
244 | All IO requests will block. The array can be reconfigured. | ||
245 | Writing this, if accepted, will block until array is quiessent | ||
246 | readonly | ||
247 | no resync can happen. no superblocks get written. | ||
248 | write requests fail | ||
249 | read-auto | ||
250 | like readonly, but behaves like 'clean' on a write request. | ||
251 | |||
252 | clean - no pending writes, but otherwise active. | ||
253 | When written to inactive array, starts without resync | ||
254 | If a write request arrives then | ||
255 | if metadata is known, mark 'dirty' and switch to 'active'. | ||
256 | if not known, block and switch to write-pending | ||
257 | If written to an active array that has pending writes, then fails. | ||
258 | active | ||
259 | fully active: IO and resync can be happening. | ||
260 | When written to inactive array, starts with resync | ||
261 | |||
262 | write-pending | ||
263 | clean, but writes are blocked waiting for 'active' to be written. | ||
264 | |||
265 | active-idle | ||
266 | like active, but no writes have been seen for a while (safe_mode_delay). | ||
267 | |||
268 | |||
210 | sync_speed_min | 269 | sync_speed_min |
211 | sync_speed_max | 270 | sync_speed_max |
212 | This are similar to /proc/sys/dev/raid/speed_limit_{min,max} | 271 | This are similar to /proc/sys/dev/raid/speed_limit_{min,max} |
@@ -250,10 +309,18 @@ Each directory contains: | |||
250 | faulty - device has been kicked from active use due to | 309 | faulty - device has been kicked from active use due to |
251 | a detected fault | 310 | a detected fault |
252 | in_sync - device is a fully in-sync member of the array | 311 | in_sync - device is a fully in-sync member of the array |
312 | writemostly - device will only be subject to read | ||
313 | requests if there are no other options. | ||
314 | This applies only to raid1 arrays. | ||
253 | spare - device is working, but not a full member. | 315 | spare - device is working, but not a full member. |
254 | This includes spares that are in the process | 316 | This includes spares that are in the process |
255 | of being recoverred to | 317 | of being recoverred to |
256 | This list make grow in future. | 318 | This list make grow in future. |
319 | This can be written to. | ||
320 | Writing "faulty" simulates a failure on the device. | ||
321 | Writing "remove" removes the device from the array. | ||
322 | Writing "writemostly" sets the writemostly flag. | ||
323 | Writing "-writemostly" clears the writemostly flag. | ||
257 | 324 | ||
258 | errors | 325 | errors |
259 | An approximate count of read errors that have been detected on | 326 | An approximate count of read errors that have been detected on |
diff --git a/Documentation/pi-futex.txt b/Documentation/pi-futex.txt new file mode 100644 index 000000000000..5d61dacd21f6 --- /dev/null +++ b/Documentation/pi-futex.txt | |||
@@ -0,0 +1,121 @@ | |||
1 | Lightweight PI-futexes | ||
2 | ---------------------- | ||
3 | |||
4 | We are calling them lightweight for 3 reasons: | ||
5 | |||
6 | - in the user-space fastpath a PI-enabled futex involves no kernel work | ||
7 | (or any other PI complexity) at all. No registration, no extra kernel | ||
8 | calls - just pure fast atomic ops in userspace. | ||
9 | |||
10 | - even in the slowpath, the system call and scheduling pattern is very | ||
11 | similar to normal futexes. | ||
12 | |||
13 | - the in-kernel PI implementation is streamlined around the mutex | ||
14 | abstraction, with strict rules that keep the implementation | ||
15 | relatively simple: only a single owner may own a lock (i.e. no | ||
16 | read-write lock support), only the owner may unlock a lock, no | ||
17 | recursive locking, etc. | ||
18 | |||
19 | Priority Inheritance - why? | ||
20 | --------------------------- | ||
21 | |||
22 | The short reply: user-space PI helps achieving/improving determinism for | ||
23 | user-space applications. In the best-case, it can help achieve | ||
24 | determinism and well-bound latencies. Even in the worst-case, PI will | ||
25 | improve the statistical distribution of locking related application | ||
26 | delays. | ||
27 | |||
28 | The longer reply: | ||
29 | ----------------- | ||
30 | |||
31 | Firstly, sharing locks between multiple tasks is a common programming | ||
32 | technique that often cannot be replaced with lockless algorithms. As we | ||
33 | can see it in the kernel [which is a quite complex program in itself], | ||
34 | lockless structures are rather the exception than the norm - the current | ||
35 | ratio of lockless vs. locky code for shared data structures is somewhere | ||
36 | between 1:10 and 1:100. Lockless is hard, and the complexity of lockless | ||
37 | algorithms often endangers to ability to do robust reviews of said code. | ||
38 | I.e. critical RT apps often choose lock structures to protect critical | ||
39 | data structures, instead of lockless algorithms. Furthermore, there are | ||
40 | cases (like shared hardware, or other resource limits) where lockless | ||
41 | access is mathematically impossible. | ||
42 | |||
43 | Media players (such as Jack) are an example of reasonable application | ||
44 | design with multiple tasks (with multiple priority levels) sharing | ||
45 | short-held locks: for example, a highprio audio playback thread is | ||
46 | combined with medium-prio construct-audio-data threads and low-prio | ||
47 | display-colory-stuff threads. Add video and decoding to the mix and | ||
48 | we've got even more priority levels. | ||
49 | |||
50 | So once we accept that synchronization objects (locks) are an | ||
51 | unavoidable fact of life, and once we accept that multi-task userspace | ||
52 | apps have a very fair expectation of being able to use locks, we've got | ||
53 | to think about how to offer the option of a deterministic locking | ||
54 | implementation to user-space. | ||
55 | |||
56 | Most of the technical counter-arguments against doing priority | ||
57 | inheritance only apply to kernel-space locks. But user-space locks are | ||
58 | different, there we cannot disable interrupts or make the task | ||
59 | non-preemptible in a critical section, so the 'use spinlocks' argument | ||
60 | does not apply (user-space spinlocks have the same priority inversion | ||
61 | problems as other user-space locking constructs). Fact is, pretty much | ||
62 | the only technique that currently enables good determinism for userspace | ||
63 | locks (such as futex-based pthread mutexes) is priority inheritance: | ||
64 | |||
65 | Currently (without PI), if a high-prio and a low-prio task shares a lock | ||
66 | [this is a quite common scenario for most non-trivial RT applications], | ||
67 | even if all critical sections are coded carefully to be deterministic | ||
68 | (i.e. all critical sections are short in duration and only execute a | ||
69 | limited number of instructions), the kernel cannot guarantee any | ||
70 | deterministic execution of the high-prio task: any medium-priority task | ||
71 | could preempt the low-prio task while it holds the shared lock and | ||
72 | executes the critical section, and could delay it indefinitely. | ||
73 | |||
74 | Implementation: | ||
75 | --------------- | ||
76 | |||
77 | As mentioned before, the userspace fastpath of PI-enabled pthread | ||
78 | mutexes involves no kernel work at all - they behave quite similarly to | ||
79 | normal futex-based locks: a 0 value means unlocked, and a value==TID | ||
80 | means locked. (This is the same method as used by list-based robust | ||
81 | futexes.) Userspace uses atomic ops to lock/unlock these mutexes without | ||
82 | entering the kernel. | ||
83 | |||
84 | To handle the slowpath, we have added two new futex ops: | ||
85 | |||
86 | FUTEX_LOCK_PI | ||
87 | FUTEX_UNLOCK_PI | ||
88 | |||
89 | If the lock-acquire fastpath fails, [i.e. an atomic transition from 0 to | ||
90 | TID fails], then FUTEX_LOCK_PI is called. The kernel does all the | ||
91 | remaining work: if there is no futex-queue attached to the futex address | ||
92 | yet then the code looks up the task that owns the futex [it has put its | ||
93 | own TID into the futex value], and attaches a 'PI state' structure to | ||
94 | the futex-queue. The pi_state includes an rt-mutex, which is a PI-aware, | ||
95 | kernel-based synchronization object. The 'other' task is made the owner | ||
96 | of the rt-mutex, and the FUTEX_WAITERS bit is atomically set in the | ||
97 | futex value. Then this task tries to lock the rt-mutex, on which it | ||
98 | blocks. Once it returns, it has the mutex acquired, and it sets the | ||
99 | futex value to its own TID and returns. Userspace has no other work to | ||
100 | perform - it now owns the lock, and futex value contains | ||
101 | FUTEX_WAITERS|TID. | ||
102 | |||
103 | If the unlock side fastpath succeeds, [i.e. userspace manages to do a | ||
104 | TID -> 0 atomic transition of the futex value], then no kernel work is | ||
105 | triggered. | ||
106 | |||
107 | If the unlock fastpath fails (because the FUTEX_WAITERS bit is set), | ||
108 | then FUTEX_UNLOCK_PI is called, and the kernel unlocks the futex on the | ||
109 | behalf of userspace - and it also unlocks the attached | ||
110 | pi_state->rt_mutex and thus wakes up any potential waiters. | ||
111 | |||
112 | Note that under this approach, contrary to previous PI-futex approaches, | ||
113 | there is no prior 'registration' of a PI-futex. [which is not quite | ||
114 | possible anyway, due to existing ABI properties of pthread mutexes.] | ||
115 | |||
116 | Also, under this scheme, 'robustness' and 'PI' are two orthogonal | ||
117 | properties of futexes, and all four combinations are possible: futex, | ||
118 | robust-futex, PI-futex, robust+PI-futex. | ||
119 | |||
120 | More details about priority inheritance can be found in | ||
121 | Documentation/rtmutex.txt. | ||
diff --git a/Documentation/robust-futexes.txt b/Documentation/robust-futexes.txt index df82d75245a0..76e8064b8c3a 100644 --- a/Documentation/robust-futexes.txt +++ b/Documentation/robust-futexes.txt | |||
@@ -95,7 +95,7 @@ comparison. If the thread has registered a list, then normally the list | |||
95 | is empty. If the thread/process crashed or terminated in some incorrect | 95 | is empty. If the thread/process crashed or terminated in some incorrect |
96 | way then the list might be non-empty: in this case the kernel carefully | 96 | way then the list might be non-empty: in this case the kernel carefully |
97 | walks the list [not trusting it], and marks all locks that are owned by | 97 | walks the list [not trusting it], and marks all locks that are owned by |
98 | this thread with the FUTEX_OWNER_DEAD bit, and wakes up one waiter (if | 98 | this thread with the FUTEX_OWNER_DIED bit, and wakes up one waiter (if |
99 | any). | 99 | any). |
100 | 100 | ||
101 | The list is guaranteed to be private and per-thread at do_exit() time, | 101 | The list is guaranteed to be private and per-thread at do_exit() time, |
diff --git a/Documentation/rt-mutex-design.txt b/Documentation/rt-mutex-design.txt new file mode 100644 index 000000000000..c472ffacc2f6 --- /dev/null +++ b/Documentation/rt-mutex-design.txt | |||
@@ -0,0 +1,781 @@ | |||
1 | # | ||
2 | # Copyright (c) 2006 Steven Rostedt | ||
3 | # Licensed under the GNU Free Documentation License, Version 1.2 | ||
4 | # | ||
5 | |||
6 | RT-mutex implementation design | ||
7 | ------------------------------ | ||
8 | |||
9 | This document tries to describe the design of the rtmutex.c implementation. | ||
10 | It doesn't describe the reasons why rtmutex.c exists. For that please see | ||
11 | Documentation/rt-mutex.txt. Although this document does explain problems | ||
12 | that happen without this code, but that is in the concept to understand | ||
13 | what the code actually is doing. | ||
14 | |||
15 | The goal of this document is to help others understand the priority | ||
16 | inheritance (PI) algorithm that is used, as well as reasons for the | ||
17 | decisions that were made to implement PI in the manner that was done. | ||
18 | |||
19 | |||
20 | Unbounded Priority Inversion | ||
21 | ---------------------------- | ||
22 | |||
23 | Priority inversion is when a lower priority process executes while a higher | ||
24 | priority process wants to run. This happens for several reasons, and | ||
25 | most of the time it can't be helped. Anytime a high priority process wants | ||
26 | to use a resource that a lower priority process has (a mutex for example), | ||
27 | the high priority process must wait until the lower priority process is done | ||
28 | with the resource. This is a priority inversion. What we want to prevent | ||
29 | is something called unbounded priority inversion. That is when the high | ||
30 | priority process is prevented from running by a lower priority process for | ||
31 | an undetermined amount of time. | ||
32 | |||
33 | The classic example of unbounded priority inversion is were you have three | ||
34 | processes, let's call them processes A, B, and C, where A is the highest | ||
35 | priority process, C is the lowest, and B is in between. A tries to grab a lock | ||
36 | that C owns and must wait and lets C run to release the lock. But in the | ||
37 | meantime, B executes, and since B is of a higher priority than C, it preempts C, | ||
38 | but by doing so, it is in fact preempting A which is a higher priority process. | ||
39 | Now there's no way of knowing how long A will be sleeping waiting for C | ||
40 | to release the lock, because for all we know, B is a CPU hog and will | ||
41 | never give C a chance to release the lock. This is called unbounded priority | ||
42 | inversion. | ||
43 | |||
44 | Here's a little ASCII art to show the problem. | ||
45 | |||
46 | grab lock L1 (owned by C) | ||
47 | | | ||
48 | A ---+ | ||
49 | C preempted by B | ||
50 | | | ||
51 | C +----+ | ||
52 | |||
53 | B +--------> | ||
54 | B now keeps A from running. | ||
55 | |||
56 | |||
57 | Priority Inheritance (PI) | ||
58 | ------------------------- | ||
59 | |||
60 | There are several ways to solve this issue, but other ways are out of scope | ||
61 | for this document. Here we only discuss PI. | ||
62 | |||
63 | PI is where a process inherits the priority of another process if the other | ||
64 | process blocks on a lock owned by the current process. To make this easier | ||
65 | to understand, let's use the previous example, with processes A, B, and C again. | ||
66 | |||
67 | This time, when A blocks on the lock owned by C, C would inherit the priority | ||
68 | of A. So now if B becomes runnable, it would not preempt C, since C now has | ||
69 | the high priority of A. As soon as C releases the lock, it loses its | ||
70 | inherited priority, and A then can continue with the resource that C had. | ||
71 | |||
72 | Terminology | ||
73 | ----------- | ||
74 | |||
75 | Here I explain some terminology that is used in this document to help describe | ||
76 | the design that is used to implement PI. | ||
77 | |||
78 | PI chain - The PI chain is an ordered series of locks and processes that cause | ||
79 | processes to inherit priorities from a previous process that is | ||
80 | blocked on one of its locks. This is described in more detail | ||
81 | later in this document. | ||
82 | |||
83 | mutex - In this document, to differentiate from locks that implement | ||
84 | PI and spin locks that are used in the PI code, from now on | ||
85 | the PI locks will be called a mutex. | ||
86 | |||
87 | lock - In this document from now on, I will use the term lock when | ||
88 | referring to spin locks that are used to protect parts of the PI | ||
89 | algorithm. These locks disable preemption for UP (when | ||
90 | CONFIG_PREEMPT is enabled) and on SMP prevents multiple CPUs from | ||
91 | entering critical sections simultaneously. | ||
92 | |||
93 | spin lock - Same as lock above. | ||
94 | |||
95 | waiter - A waiter is a struct that is stored on the stack of a blocked | ||
96 | process. Since the scope of the waiter is within the code for | ||
97 | a process being blocked on the mutex, it is fine to allocate | ||
98 | the waiter on the process's stack (local variable). This | ||
99 | structure holds a pointer to the task, as well as the mutex that | ||
100 | the task is blocked on. It also has the plist node structures to | ||
101 | place the task in the waiter_list of a mutex as well as the | ||
102 | pi_list of a mutex owner task (described below). | ||
103 | |||
104 | waiter is sometimes used in reference to the task that is waiting | ||
105 | on a mutex. This is the same as waiter->task. | ||
106 | |||
107 | waiters - A list of processes that are blocked on a mutex. | ||
108 | |||
109 | top waiter - The highest priority process waiting on a specific mutex. | ||
110 | |||
111 | top pi waiter - The highest priority process waiting on one of the mutexes | ||
112 | that a specific process owns. | ||
113 | |||
114 | Note: task and process are used interchangeably in this document, mostly to | ||
115 | differentiate between two processes that are being described together. | ||
116 | |||
117 | |||
118 | PI chain | ||
119 | -------- | ||
120 | |||
121 | The PI chain is a list of processes and mutexes that may cause priority | ||
122 | inheritance to take place. Multiple chains may converge, but a chain | ||
123 | would never diverge, since a process can't be blocked on more than one | ||
124 | mutex at a time. | ||
125 | |||
126 | Example: | ||
127 | |||
128 | Process: A, B, C, D, E | ||
129 | Mutexes: L1, L2, L3, L4 | ||
130 | |||
131 | A owns: L1 | ||
132 | B blocked on L1 | ||
133 | B owns L2 | ||
134 | C blocked on L2 | ||
135 | C owns L3 | ||
136 | D blocked on L3 | ||
137 | D owns L4 | ||
138 | E blocked on L4 | ||
139 | |||
140 | The chain would be: | ||
141 | |||
142 | E->L4->D->L3->C->L2->B->L1->A | ||
143 | |||
144 | To show where two chains merge, we could add another process F and | ||
145 | another mutex L5 where B owns L5 and F is blocked on mutex L5. | ||
146 | |||
147 | The chain for F would be: | ||
148 | |||
149 | F->L5->B->L1->A | ||
150 | |||
151 | Since a process may own more than one mutex, but never be blocked on more than | ||
152 | one, the chains merge. | ||
153 | |||
154 | Here we show both chains: | ||
155 | |||
156 | E->L4->D->L3->C->L2-+ | ||
157 | | | ||
158 | +->B->L1->A | ||
159 | | | ||
160 | F->L5-+ | ||
161 | |||
162 | For PI to work, the processes at the right end of these chains (or we may | ||
163 | also call it the Top of the chain) must be equal to or higher in priority | ||
164 | than the processes to the left or below in the chain. | ||
165 | |||
166 | Also since a mutex may have more than one process blocked on it, we can | ||
167 | have multiple chains merge at mutexes. If we add another process G that is | ||
168 | blocked on mutex L2: | ||
169 | |||
170 | G->L2->B->L1->A | ||
171 | |||
172 | And once again, to show how this can grow I will show the merging chains | ||
173 | again. | ||
174 | |||
175 | E->L4->D->L3->C-+ | ||
176 | +->L2-+ | ||
177 | | | | ||
178 | G-+ +->B->L1->A | ||
179 | | | ||
180 | F->L5-+ | ||
181 | |||
182 | |||
183 | Plist | ||
184 | ----- | ||
185 | |||
186 | Before I go further and talk about how the PI chain is stored through lists | ||
187 | on both mutexes and processes, I'll explain the plist. This is similar to | ||
188 | the struct list_head functionality that is already in the kernel. | ||
189 | The implementation of plist is out of scope for this document, but it is | ||
190 | very important to understand what it does. | ||
191 | |||
192 | There are a few differences between plist and list, the most important one | ||
193 | being that plist is a priority sorted linked list. This means that the | ||
194 | priorities of the plist are sorted, such that it takes O(1) to retrieve the | ||
195 | highest priority item in the list. Obviously this is useful to store processes | ||
196 | based on their priorities. | ||
197 | |||
198 | Another difference, which is important for implementation, is that, unlike | ||
199 | list, the head of the list is a different element than the nodes of a list. | ||
200 | So the head of the list is declared as struct plist_head and nodes that will | ||
201 | be added to the list are declared as struct plist_node. | ||
202 | |||
203 | |||
204 | Mutex Waiter List | ||
205 | ----------------- | ||
206 | |||
207 | Every mutex keeps track of all the waiters that are blocked on itself. The mutex | ||
208 | has a plist to store these waiters by priority. This list is protected by | ||
209 | a spin lock that is located in the struct of the mutex. This lock is called | ||
210 | wait_lock. Since the modification of the waiter list is never done in | ||
211 | interrupt context, the wait_lock can be taken without disabling interrupts. | ||
212 | |||
213 | |||
214 | Task PI List | ||
215 | ------------ | ||
216 | |||
217 | To keep track of the PI chains, each process has its own PI list. This is | ||
218 | a list of all top waiters of the mutexes that are owned by the process. | ||
219 | Note that this list only holds the top waiters and not all waiters that are | ||
220 | blocked on mutexes owned by the process. | ||
221 | |||
222 | The top of the task's PI list is always the highest priority task that | ||
223 | is waiting on a mutex that is owned by the task. So if the task has | ||
224 | inherited a priority, it will always be the priority of the task that is | ||
225 | at the top of this list. | ||
226 | |||
227 | This list is stored in the task structure of a process as a plist called | ||
228 | pi_list. This list is protected by a spin lock also in the task structure, | ||
229 | called pi_lock. This lock may also be taken in interrupt context, so when | ||
230 | locking the pi_lock, interrupts must be disabled. | ||
231 | |||
232 | |||
233 | Depth of the PI Chain | ||
234 | --------------------- | ||
235 | |||
236 | The maximum depth of the PI chain is not dynamic, and could actually be | ||
237 | defined. But is very complex to figure it out, since it depends on all | ||
238 | the nesting of mutexes. Let's look at the example where we have 3 mutexes, | ||
239 | L1, L2, and L3, and four separate functions func1, func2, func3 and func4. | ||
240 | The following shows a locking order of L1->L2->L3, but may not actually | ||
241 | be directly nested that way. | ||
242 | |||
243 | void func1(void) | ||
244 | { | ||
245 | mutex_lock(L1); | ||
246 | |||
247 | /* do anything */ | ||
248 | |||
249 | mutex_unlock(L1); | ||
250 | } | ||
251 | |||
252 | void func2(void) | ||
253 | { | ||
254 | mutex_lock(L1); | ||
255 | mutex_lock(L2); | ||
256 | |||
257 | /* do something */ | ||
258 | |||
259 | mutex_unlock(L2); | ||
260 | mutex_unlock(L1); | ||
261 | } | ||
262 | |||
263 | void func3(void) | ||
264 | { | ||
265 | mutex_lock(L2); | ||
266 | mutex_lock(L3); | ||
267 | |||
268 | /* do something else */ | ||
269 | |||
270 | mutex_unlock(L3); | ||
271 | mutex_unlock(L2); | ||
272 | } | ||
273 | |||
274 | void func4(void) | ||
275 | { | ||
276 | mutex_lock(L3); | ||
277 | |||
278 | /* do something again */ | ||
279 | |||
280 | mutex_unlock(L3); | ||
281 | } | ||
282 | |||
283 | Now we add 4 processes that run each of these functions separately. | ||
284 | Processes A, B, C, and D which run functions func1, func2, func3 and func4 | ||
285 | respectively, and such that D runs first and A last. With D being preempted | ||
286 | in func4 in the "do something again" area, we have a locking that follows: | ||
287 | |||
288 | D owns L3 | ||
289 | C blocked on L3 | ||
290 | C owns L2 | ||
291 | B blocked on L2 | ||
292 | B owns L1 | ||
293 | A blocked on L1 | ||
294 | |||
295 | And thus we have the chain A->L1->B->L2->C->L3->D. | ||
296 | |||
297 | This gives us a PI depth of 4 (four processes), but looking at any of the | ||
298 | functions individually, it seems as though they only have at most a locking | ||
299 | depth of two. So, although the locking depth is defined at compile time, | ||
300 | it still is very difficult to find the possibilities of that depth. | ||
301 | |||
302 | Now since mutexes can be defined by user-land applications, we don't want a DOS | ||
303 | type of application that nests large amounts of mutexes to create a large | ||
304 | PI chain, and have the code holding spin locks while looking at a large | ||
305 | amount of data. So to prevent this, the implementation not only implements | ||
306 | a maximum lock depth, but also only holds at most two different locks at a | ||
307 | time, as it walks the PI chain. More about this below. | ||
308 | |||
309 | |||
310 | Mutex owner and flags | ||
311 | --------------------- | ||
312 | |||
313 | The mutex structure contains a pointer to the owner of the mutex. If the | ||
314 | mutex is not owned, this owner is set to NULL. Since all architectures | ||
315 | have the task structure on at least a four byte alignment (and if this is | ||
316 | not true, the rtmutex.c code will be broken!), this allows for the two | ||
317 | least significant bits to be used as flags. This part is also described | ||
318 | in Documentation/rt-mutex.txt, but will also be briefly described here. | ||
319 | |||
320 | Bit 0 is used as the "Pending Owner" flag. This is described later. | ||
321 | Bit 1 is used as the "Has Waiters" flags. This is also described later | ||
322 | in more detail, but is set whenever there are waiters on a mutex. | ||
323 | |||
324 | |||
325 | cmpxchg Tricks | ||
326 | -------------- | ||
327 | |||
328 | Some architectures implement an atomic cmpxchg (Compare and Exchange). This | ||
329 | is used (when applicable) to keep the fast path of grabbing and releasing | ||
330 | mutexes short. | ||
331 | |||
332 | cmpxchg is basically the following function performed atomically: | ||
333 | |||
334 | unsigned long _cmpxchg(unsigned long *A, unsigned long *B, unsigned long *C) | ||
335 | { | ||
336 | unsigned long T = *A; | ||
337 | if (*A == *B) { | ||
338 | *A = *C; | ||
339 | } | ||
340 | return T; | ||
341 | } | ||
342 | #define cmpxchg(a,b,c) _cmpxchg(&a,&b,&c) | ||
343 | |||
344 | This is really nice to have, since it allows you to only update a variable | ||
345 | if the variable is what you expect it to be. You know if it succeeded if | ||
346 | the return value (the old value of A) is equal to B. | ||
347 | |||
348 | The macro rt_mutex_cmpxchg is used to try to lock and unlock mutexes. If | ||
349 | the architecture does not support CMPXCHG, then this macro is simply set | ||
350 | to fail every time. But if CMPXCHG is supported, then this will | ||
351 | help out extremely to keep the fast path short. | ||
352 | |||
353 | The use of rt_mutex_cmpxchg with the flags in the owner field help optimize | ||
354 | the system for architectures that support it. This will also be explained | ||
355 | later in this document. | ||
356 | |||
357 | |||
358 | Priority adjustments | ||
359 | -------------------- | ||
360 | |||
361 | The implementation of the PI code in rtmutex.c has several places that a | ||
362 | process must adjust its priority. With the help of the pi_list of a | ||
363 | process this is rather easy to know what needs to be adjusted. | ||
364 | |||
365 | The functions implementing the task adjustments are rt_mutex_adjust_prio, | ||
366 | __rt_mutex_adjust_prio (same as the former, but expects the task pi_lock | ||
367 | to already be taken), rt_mutex_get_prio, and rt_mutex_setprio. | ||
368 | |||
369 | rt_mutex_getprio and rt_mutex_setprio are only used in __rt_mutex_adjust_prio. | ||
370 | |||
371 | rt_mutex_getprio returns the priority that the task should have. Either the | ||
372 | task's own normal priority, or if a process of a higher priority is waiting on | ||
373 | a mutex owned by the task, then that higher priority should be returned. | ||
374 | Since the pi_list of a task holds an order by priority list of all the top | ||
375 | waiters of all the mutexes that the task owns, rt_mutex_getprio simply needs | ||
376 | to compare the top pi waiter to its own normal priority, and return the higher | ||
377 | priority back. | ||
378 | |||
379 | (Note: if looking at the code, you will notice that the lower number of | ||
380 | prio is returned. This is because the prio field in the task structure | ||
381 | is an inverse order of the actual priority. So a "prio" of 5 is | ||
382 | of higher priority than a "prio" of 10.) | ||
383 | |||
384 | __rt_mutex_adjust_prio examines the result of rt_mutex_getprio, and if the | ||
385 | result does not equal the task's current priority, then rt_mutex_setprio | ||
386 | is called to adjust the priority of the task to the new priority. | ||
387 | Note that rt_mutex_setprio is defined in kernel/sched.c to implement the | ||
388 | actual change in priority. | ||
389 | |||
390 | It is interesting to note that __rt_mutex_adjust_prio can either increase | ||
391 | or decrease the priority of the task. In the case that a higher priority | ||
392 | process has just blocked on a mutex owned by the task, __rt_mutex_adjust_prio | ||
393 | would increase/boost the task's priority. But if a higher priority task | ||
394 | were for some reason to leave the mutex (timeout or signal), this same function | ||
395 | would decrease/unboost the priority of the task. That is because the pi_list | ||
396 | always contains the highest priority task that is waiting on a mutex owned | ||
397 | by the task, so we only need to compare the priority of that top pi waiter | ||
398 | to the normal priority of the given task. | ||
399 | |||
400 | |||
401 | High level overview of the PI chain walk | ||
402 | ---------------------------------------- | ||
403 | |||
404 | The PI chain walk is implemented by the function rt_mutex_adjust_prio_chain. | ||
405 | |||
406 | The implementation has gone through several iterations, and has ended up | ||
407 | with what we believe is the best. It walks the PI chain by only grabbing | ||
408 | at most two locks at a time, and is very efficient. | ||
409 | |||
410 | The rt_mutex_adjust_prio_chain can be used either to boost or lower process | ||
411 | priorities. | ||
412 | |||
413 | rt_mutex_adjust_prio_chain is called with a task to be checked for PI | ||
414 | (de)boosting (the owner of a mutex that a process is blocking on), a flag to | ||
415 | check for deadlocking, the mutex that the task owns, and a pointer to a waiter | ||
416 | that is the process's waiter struct that is blocked on the mutex (although this | ||
417 | parameter may be NULL for deboosting). | ||
418 | |||
419 | For this explanation, I will not mention deadlock detection. This explanation | ||
420 | will try to stay at a high level. | ||
421 | |||
422 | When this function is called, there are no locks held. That also means | ||
423 | that the state of the owner and lock can change when entered into this function. | ||
424 | |||
425 | Before this function is called, the task has already had rt_mutex_adjust_prio | ||
426 | performed on it. This means that the task is set to the priority that it | ||
427 | should be at, but the plist nodes of the task's waiter have not been updated | ||
428 | with the new priorities, and that this task may not be in the proper locations | ||
429 | in the pi_lists and wait_lists that the task is blocked on. This function | ||
430 | solves all that. | ||
431 | |||
432 | A loop is entered, where task is the owner to be checked for PI changes that | ||
433 | was passed by parameter (for the first iteration). The pi_lock of this task is | ||
434 | taken to prevent any more changes to the pi_list of the task. This also | ||
435 | prevents new tasks from completing the blocking on a mutex that is owned by this | ||
436 | task. | ||
437 | |||
438 | If the task is not blocked on a mutex then the loop is exited. We are at | ||
439 | the top of the PI chain. | ||
440 | |||
441 | A check is now done to see if the original waiter (the process that is blocked | ||
442 | on the current mutex) is the top pi waiter of the task. That is, is this | ||
443 | waiter on the top of the task's pi_list. If it is not, it either means that | ||
444 | there is another process higher in priority that is blocked on one of the | ||
445 | mutexes that the task owns, or that the waiter has just woken up via a signal | ||
446 | or timeout and has left the PI chain. In either case, the loop is exited, since | ||
447 | we don't need to do any more changes to the priority of the current task, or any | ||
448 | task that owns a mutex that this current task is waiting on. A priority chain | ||
449 | walk is only needed when a new top pi waiter is made to a task. | ||
450 | |||
451 | The next check sees if the task's waiter plist node has the priority equal to | ||
452 | the priority the task is set at. If they are equal, then we are done with | ||
453 | the loop. Remember that the function started with the priority of the | ||
454 | task adjusted, but the plist nodes that hold the task in other processes | ||
455 | pi_lists have not been adjusted. | ||
456 | |||
457 | Next, we look at the mutex that the task is blocked on. The mutex's wait_lock | ||
458 | is taken. This is done by a spin_trylock, because the locking order of the | ||
459 | pi_lock and wait_lock goes in the opposite direction. If we fail to grab the | ||
460 | lock, the pi_lock is released, and we restart the loop. | ||
461 | |||
462 | Now that we have both the pi_lock of the task as well as the wait_lock of | ||
463 | the mutex the task is blocked on, we update the task's waiter's plist node | ||
464 | that is located on the mutex's wait_list. | ||
465 | |||
466 | Now we release the pi_lock of the task. | ||
467 | |||
468 | Next the owner of the mutex has its pi_lock taken, so we can update the | ||
469 | task's entry in the owner's pi_list. If the task is the highest priority | ||
470 | process on the mutex's wait_list, then we remove the previous top waiter | ||
471 | from the owner's pi_list, and replace it with the task. | ||
472 | |||
473 | Note: It is possible that the task was the current top waiter on the mutex, | ||
474 | in which case the task is not yet on the pi_list of the waiter. This | ||
475 | is OK, since plist_del does nothing if the plist node is not on any | ||
476 | list. | ||
477 | |||
478 | If the task was not the top waiter of the mutex, but it was before we | ||
479 | did the priority updates, that means we are deboosting/lowering the | ||
480 | task. In this case, the task is removed from the pi_list of the owner, | ||
481 | and the new top waiter is added. | ||
482 | |||
483 | Lastly, we unlock both the pi_lock of the task, as well as the mutex's | ||
484 | wait_lock, and continue the loop again. On the next iteration of the | ||
485 | loop, the previous owner of the mutex will be the task that will be | ||
486 | processed. | ||
487 | |||
488 | Note: One might think that the owner of this mutex might have changed | ||
489 | since we just grab the mutex's wait_lock. And one could be right. | ||
490 | The important thing to remember is that the owner could not have | ||
491 | become the task that is being processed in the PI chain, since | ||
492 | we have taken that task's pi_lock at the beginning of the loop. | ||
493 | So as long as there is an owner of this mutex that is not the same | ||
494 | process as the tasked being worked on, we are OK. | ||
495 | |||
496 | Looking closely at the code, one might be confused. The check for the | ||
497 | end of the PI chain is when the task isn't blocked on anything or the | ||
498 | task's waiter structure "task" element is NULL. This check is | ||
499 | protected only by the task's pi_lock. But the code to unlock the mutex | ||
500 | sets the task's waiter structure "task" element to NULL with only | ||
501 | the protection of the mutex's wait_lock, which was not taken yet. | ||
502 | Isn't this a race condition if the task becomes the new owner? | ||
503 | |||
504 | The answer is No! The trick is the spin_trylock of the mutex's | ||
505 | wait_lock. If we fail that lock, we release the pi_lock of the | ||
506 | task and continue the loop, doing the end of PI chain check again. | ||
507 | |||
508 | In the code to release the lock, the wait_lock of the mutex is held | ||
509 | the entire time, and it is not let go when we grab the pi_lock of the | ||
510 | new owner of the mutex. So if the switch of a new owner were to happen | ||
511 | after the check for end of the PI chain and the grabbing of the | ||
512 | wait_lock, the unlocking code would spin on the new owner's pi_lock | ||
513 | but never give up the wait_lock. So the PI chain loop is guaranteed to | ||
514 | fail the spin_trylock on the wait_lock, release the pi_lock, and | ||
515 | try again. | ||
516 | |||
517 | If you don't quite understand the above, that's OK. You don't have to, | ||
518 | unless you really want to make a proof out of it ;) | ||
519 | |||
520 | |||
521 | Pending Owners and Lock stealing | ||
522 | -------------------------------- | ||
523 | |||
524 | One of the flags in the owner field of the mutex structure is "Pending Owner". | ||
525 | What this means is that an owner was chosen by the process releasing the | ||
526 | mutex, but that owner has yet to wake up and actually take the mutex. | ||
527 | |||
528 | Why is this important? Why can't we just give the mutex to another process | ||
529 | and be done with it? | ||
530 | |||
531 | The PI code is to help with real-time processes, and to let the highest | ||
532 | priority process run as long as possible with little latencies and delays. | ||
533 | If a high priority process owns a mutex that a lower priority process is | ||
534 | blocked on, when the mutex is released it would be given to the lower priority | ||
535 | process. What if the higher priority process wants to take that mutex again. | ||
536 | The high priority process would fail to take that mutex that it just gave up | ||
537 | and it would need to boost the lower priority process to run with full | ||
538 | latency of that critical section (since the low priority process just entered | ||
539 | it). | ||
540 | |||
541 | There's no reason a high priority process that gives up a mutex should be | ||
542 | penalized if it tries to take that mutex again. If the new owner of the | ||
543 | mutex has not woken up yet, there's no reason that the higher priority process | ||
544 | could not take that mutex away. | ||
545 | |||
546 | To solve this, we introduced Pending Ownership and Lock Stealing. When a | ||
547 | new process is given a mutex that it was blocked on, it is only given | ||
548 | pending ownership. This means that it's the new owner, unless a higher | ||
549 | priority process comes in and tries to grab that mutex. If a higher priority | ||
550 | process does come along and wants that mutex, we let the higher priority | ||
551 | process "steal" the mutex from the pending owner (only if it is still pending) | ||
552 | and continue with the mutex. | ||
553 | |||
554 | |||
555 | Taking of a mutex (The walk through) | ||
556 | ------------------------------------ | ||
557 | |||
558 | OK, now let's take a look at the detailed walk through of what happens when | ||
559 | taking a mutex. | ||
560 | |||
561 | The first thing that is tried is the fast taking of the mutex. This is | ||
562 | done when we have CMPXCHG enabled (otherwise the fast taking automatically | ||
563 | fails). Only when the owner field of the mutex is NULL can the lock be | ||
564 | taken with the CMPXCHG and nothing else needs to be done. | ||
565 | |||
566 | If there is contention on the lock, whether it is owned or pending owner | ||
567 | we go about the slow path (rt_mutex_slowlock). | ||
568 | |||
569 | The slow path function is where the task's waiter structure is created on | ||
570 | the stack. This is because the waiter structure is only needed for the | ||
571 | scope of this function. The waiter structure holds the nodes to store | ||
572 | the task on the wait_list of the mutex, and if need be, the pi_list of | ||
573 | the owner. | ||
574 | |||
575 | The wait_lock of the mutex is taken since the slow path of unlocking the | ||
576 | mutex also takes this lock. | ||
577 | |||
578 | We then call try_to_take_rt_mutex. This is where the architecture that | ||
579 | does not implement CMPXCHG would always grab the lock (if there's no | ||
580 | contention). | ||
581 | |||
582 | try_to_take_rt_mutex is used every time the task tries to grab a mutex in the | ||
583 | slow path. The first thing that is done here is an atomic setting of | ||
584 | the "Has Waiters" flag of the mutex's owner field. Yes, this could really | ||
585 | be false, because if the the mutex has no owner, there are no waiters and | ||
586 | the current task also won't have any waiters. But we don't have the lock | ||
587 | yet, so we assume we are going to be a waiter. The reason for this is to | ||
588 | play nice for those architectures that do have CMPXCHG. By setting this flag | ||
589 | now, the owner of the mutex can't release the mutex without going into the | ||
590 | slow unlock path, and it would then need to grab the wait_lock, which this | ||
591 | code currently holds. So setting the "Has Waiters" flag forces the owner | ||
592 | to synchronize with this code. | ||
593 | |||
594 | Now that we know that we can't have any races with the owner releasing the | ||
595 | mutex, we check to see if we can take the ownership. This is done if the | ||
596 | mutex doesn't have a owner, or if we can steal the mutex from a pending | ||
597 | owner. Let's look at the situations we have here. | ||
598 | |||
599 | 1) Has owner that is pending | ||
600 | ---------------------------- | ||
601 | |||
602 | The mutex has a owner, but it hasn't woken up and the mutex flag | ||
603 | "Pending Owner" is set. The first check is to see if the owner isn't the | ||
604 | current task. This is because this function is also used for the pending | ||
605 | owner to grab the mutex. When a pending owner wakes up, it checks to see | ||
606 | if it can take the mutex, and this is done if the owner is already set to | ||
607 | itself. If so, we succeed and leave the function, clearing the "Pending | ||
608 | Owner" bit. | ||
609 | |||
610 | If the pending owner is not current, we check to see if the current priority is | ||
611 | higher than the pending owner. If not, we fail the function and return. | ||
612 | |||
613 | There's also something special about a pending owner. That is a pending owner | ||
614 | is never blocked on a mutex. So there is no PI chain to worry about. It also | ||
615 | means that if the mutex doesn't have any waiters, there's no accounting needed | ||
616 | to update the pending owner's pi_list, since we only worry about processes | ||
617 | blocked on the current mutex. | ||
618 | |||
619 | If there are waiters on this mutex, and we just stole the ownership, we need | ||
620 | to take the top waiter, remove it from the pi_list of the pending owner, and | ||
621 | add it to the current pi_list. Note that at this moment, the pending owner | ||
622 | is no longer on the list of waiters. This is fine, since the pending owner | ||
623 | would add itself back when it realizes that it had the ownership stolen | ||
624 | from itself. When the pending owner tries to grab the mutex, it will fail | ||
625 | in try_to_take_rt_mutex if the owner field points to another process. | ||
626 | |||
627 | 2) No owner | ||
628 | ----------- | ||
629 | |||
630 | If there is no owner (or we successfully stole the lock), we set the owner | ||
631 | of the mutex to current, and set the flag of "Has Waiters" if the current | ||
632 | mutex actually has waiters, or we clear the flag if it doesn't. See, it was | ||
633 | OK that we set that flag early, since now it is cleared. | ||
634 | |||
635 | 3) Failed to grab ownership | ||
636 | --------------------------- | ||
637 | |||
638 | The most interesting case is when we fail to take ownership. This means that | ||
639 | there exists an owner, or there's a pending owner with equal or higher | ||
640 | priority than the current task. | ||
641 | |||
642 | We'll continue on the failed case. | ||
643 | |||
644 | If the mutex has a timeout, we set up a timer to go off to break us out | ||
645 | of this mutex if we failed to get it after a specified amount of time. | ||
646 | |||
647 | Now we enter a loop that will continue to try to take ownership of the mutex, or | ||
648 | fail from a timeout or signal. | ||
649 | |||
650 | Once again we try to take the mutex. This will usually fail the first time | ||
651 | in the loop, since it had just failed to get the mutex. But the second time | ||
652 | in the loop, this would likely succeed, since the task would likely be | ||
653 | the pending owner. | ||
654 | |||
655 | If the mutex is TASK_INTERRUPTIBLE a check for signals and timeout is done | ||
656 | here. | ||
657 | |||
658 | The waiter structure has a "task" field that points to the task that is blocked | ||
659 | on the mutex. This field can be NULL the first time it goes through the loop | ||
660 | or if the task is a pending owner and had it's mutex stolen. If the "task" | ||
661 | field is NULL then we need to set up the accounting for it. | ||
662 | |||
663 | Task blocks on mutex | ||
664 | -------------------- | ||
665 | |||
666 | The accounting of a mutex and process is done with the waiter structure of | ||
667 | the process. The "task" field is set to the process, and the "lock" field | ||
668 | to the mutex. The plist nodes are initialized to the processes current | ||
669 | priority. | ||
670 | |||
671 | Since the wait_lock was taken at the entry of the slow lock, we can safely | ||
672 | add the waiter to the wait_list. If the current process is the highest | ||
673 | priority process currently waiting on this mutex, then we remove the | ||
674 | previous top waiter process (if it exists) from the pi_list of the owner, | ||
675 | and add the current process to that list. Since the pi_list of the owner | ||
676 | has changed, we call rt_mutex_adjust_prio on the owner to see if the owner | ||
677 | should adjust its priority accordingly. | ||
678 | |||
679 | If the owner is also blocked on a lock, and had its pi_list changed | ||
680 | (or deadlock checking is on), we unlock the wait_lock of the mutex and go ahead | ||
681 | and run rt_mutex_adjust_prio_chain on the owner, as described earlier. | ||
682 | |||
683 | Now all locks are released, and if the current process is still blocked on a | ||
684 | mutex (waiter "task" field is not NULL), then we go to sleep (call schedule). | ||
685 | |||
686 | Waking up in the loop | ||
687 | --------------------- | ||
688 | |||
689 | The schedule can then wake up for a few reasons. | ||
690 | 1) we were given pending ownership of the mutex. | ||
691 | 2) we received a signal and was TASK_INTERRUPTIBLE | ||
692 | 3) we had a timeout and was TASK_INTERRUPTIBLE | ||
693 | |||
694 | In any of these cases, we continue the loop and once again try to grab the | ||
695 | ownership of the mutex. If we succeed, we exit the loop, otherwise we continue | ||
696 | and on signal and timeout, will exit the loop, or if we had the mutex stolen | ||
697 | we just simply add ourselves back on the lists and go back to sleep. | ||
698 | |||
699 | Note: For various reasons, because of timeout and signals, the steal mutex | ||
700 | algorithm needs to be careful. This is because the current process is | ||
701 | still on the wait_list. And because of dynamic changing of priorities, | ||
702 | especially on SCHED_OTHER tasks, the current process can be the | ||
703 | highest priority task on the wait_list. | ||
704 | |||
705 | Failed to get mutex on Timeout or Signal | ||
706 | ---------------------------------------- | ||
707 | |||
708 | If a timeout or signal occurred, the waiter's "task" field would not be | ||
709 | NULL and the task needs to be taken off the wait_list of the mutex and perhaps | ||
710 | pi_list of the owner. If this process was a high priority process, then | ||
711 | the rt_mutex_adjust_prio_chain needs to be executed again on the owner, | ||
712 | but this time it will be lowering the priorities. | ||
713 | |||
714 | |||
715 | Unlocking the Mutex | ||
716 | ------------------- | ||
717 | |||
718 | The unlocking of a mutex also has a fast path for those architectures with | ||
719 | CMPXCHG. Since the taking of a mutex on contention always sets the | ||
720 | "Has Waiters" flag of the mutex's owner, we use this to know if we need to | ||
721 | take the slow path when unlocking the mutex. If the mutex doesn't have any | ||
722 | waiters, the owner field of the mutex would equal the current process and | ||
723 | the mutex can be unlocked by just replacing the owner field with NULL. | ||
724 | |||
725 | If the owner field has the "Has Waiters" bit set (or CMPXCHG is not available), | ||
726 | the slow unlock path is taken. | ||
727 | |||
728 | The first thing done in the slow unlock path is to take the wait_lock of the | ||
729 | mutex. This synchronizes the locking and unlocking of the mutex. | ||
730 | |||
731 | A check is made to see if the mutex has waiters or not. On architectures that | ||
732 | do not have CMPXCHG, this is the location that the owner of the mutex will | ||
733 | determine if a waiter needs to be awoken or not. On architectures that | ||
734 | do have CMPXCHG, that check is done in the fast path, but it is still needed | ||
735 | in the slow path too. If a waiter of a mutex woke up because of a signal | ||
736 | or timeout between the time the owner failed the fast path CMPXCHG check and | ||
737 | the grabbing of the wait_lock, the mutex may not have any waiters, thus the | ||
738 | owner still needs to make this check. If there are no waiters than the mutex | ||
739 | owner field is set to NULL, the wait_lock is released and nothing more is | ||
740 | needed. | ||
741 | |||
742 | If there are waiters, then we need to wake one up and give that waiter | ||
743 | pending ownership. | ||
744 | |||
745 | On the wake up code, the pi_lock of the current owner is taken. The top | ||
746 | waiter of the lock is found and removed from the wait_list of the mutex | ||
747 | as well as the pi_list of the current owner. The task field of the new | ||
748 | pending owner's waiter structure is set to NULL, and the owner field of the | ||
749 | mutex is set to the new owner with the "Pending Owner" bit set, as well | ||
750 | as the "Has Waiters" bit if there still are other processes blocked on the | ||
751 | mutex. | ||
752 | |||
753 | The pi_lock of the previous owner is released, and the new pending owner's | ||
754 | pi_lock is taken. Remember that this is the trick to prevent the race | ||
755 | condition in rt_mutex_adjust_prio_chain from adding itself as a waiter | ||
756 | on the mutex. | ||
757 | |||
758 | We now clear the "pi_blocked_on" field of the new pending owner, and if | ||
759 | the mutex still has waiters pending, we add the new top waiter to the pi_list | ||
760 | of the pending owner. | ||
761 | |||
762 | Finally we unlock the pi_lock of the pending owner and wake it up. | ||
763 | |||
764 | |||
765 | Contact | ||
766 | ------- | ||
767 | |||
768 | For updates on this document, please email Steven Rostedt <rostedt@goodmis.org> | ||
769 | |||
770 | |||
771 | Credits | ||
772 | ------- | ||
773 | |||
774 | Author: Steven Rostedt <rostedt@goodmis.org> | ||
775 | |||
776 | Reviewers: Ingo Molnar, Thomas Gleixner, Thomas Duetsch, and Randy Dunlap | ||
777 | |||
778 | Updates | ||
779 | ------- | ||
780 | |||
781 | This document was originally written for 2.6.17-rc3-mm1 | ||
diff --git a/Documentation/rt-mutex.txt b/Documentation/rt-mutex.txt new file mode 100644 index 000000000000..243393d882ee --- /dev/null +++ b/Documentation/rt-mutex.txt | |||
@@ -0,0 +1,79 @@ | |||
1 | RT-mutex subsystem with PI support | ||
2 | ---------------------------------- | ||
3 | |||
4 | RT-mutexes with priority inheritance are used to support PI-futexes, | ||
5 | which enable pthread_mutex_t priority inheritance attributes | ||
6 | (PTHREAD_PRIO_INHERIT). [See Documentation/pi-futex.txt for more details | ||
7 | about PI-futexes.] | ||
8 | |||
9 | This technology was developed in the -rt tree and streamlined for | ||
10 | pthread_mutex support. | ||
11 | |||
12 | Basic principles: | ||
13 | ----------------- | ||
14 | |||
15 | RT-mutexes extend the semantics of simple mutexes by the priority | ||
16 | inheritance protocol. | ||
17 | |||
18 | A low priority owner of a rt-mutex inherits the priority of a higher | ||
19 | priority waiter until the rt-mutex is released. If the temporarily | ||
20 | boosted owner blocks on a rt-mutex itself it propagates the priority | ||
21 | boosting to the owner of the other rt_mutex it gets blocked on. The | ||
22 | priority boosting is immediately removed once the rt_mutex has been | ||
23 | unlocked. | ||
24 | |||
25 | This approach allows us to shorten the block of high-prio tasks on | ||
26 | mutexes which protect shared resources. Priority inheritance is not a | ||
27 | magic bullet for poorly designed applications, but it allows | ||
28 | well-designed applications to use userspace locks in critical parts of | ||
29 | an high priority thread, without losing determinism. | ||
30 | |||
31 | The enqueueing of the waiters into the rtmutex waiter list is done in | ||
32 | priority order. For same priorities FIFO order is chosen. For each | ||
33 | rtmutex, only the top priority waiter is enqueued into the owner's | ||
34 | priority waiters list. This list too queues in priority order. Whenever | ||
35 | the top priority waiter of a task changes (for example it timed out or | ||
36 | got a signal), the priority of the owner task is readjusted. [The | ||
37 | priority enqueueing is handled by "plists", see include/linux/plist.h | ||
38 | for more details.] | ||
39 | |||
40 | RT-mutexes are optimized for fastpath operations and have no internal | ||
41 | locking overhead when locking an uncontended mutex or unlocking a mutex | ||
42 | without waiters. The optimized fastpath operations require cmpxchg | ||
43 | support. [If that is not available then the rt-mutex internal spinlock | ||
44 | is used] | ||
45 | |||
46 | The state of the rt-mutex is tracked via the owner field of the rt-mutex | ||
47 | structure: | ||
48 | |||
49 | rt_mutex->owner holds the task_struct pointer of the owner. Bit 0 and 1 | ||
50 | are used to keep track of the "owner is pending" and "rtmutex has | ||
51 | waiters" state. | ||
52 | |||
53 | owner bit1 bit0 | ||
54 | NULL 0 0 mutex is free (fast acquire possible) | ||
55 | NULL 0 1 invalid state | ||
56 | NULL 1 0 Transitional state* | ||
57 | NULL 1 1 invalid state | ||
58 | taskpointer 0 0 mutex is held (fast release possible) | ||
59 | taskpointer 0 1 task is pending owner | ||
60 | taskpointer 1 0 mutex is held and has waiters | ||
61 | taskpointer 1 1 task is pending owner and mutex has waiters | ||
62 | |||
63 | Pending-ownership handling is a performance optimization: | ||
64 | pending-ownership is assigned to the first (highest priority) waiter of | ||
65 | the mutex, when the mutex is released. The thread is woken up and once | ||
66 | it starts executing it can acquire the mutex. Until the mutex is taken | ||
67 | by it (bit 0 is cleared) a competing higher priority thread can "steal" | ||
68 | the mutex which puts the woken up thread back on the waiters list. | ||
69 | |||
70 | The pending-ownership optimization is especially important for the | ||
71 | uninterrupted workflow of high-prio tasks which repeatedly | ||
72 | takes/releases locks that have lower-prio waiters. Without this | ||
73 | optimization the higher-prio thread would ping-pong to the lower-prio | ||
74 | task [because at unlock time we always assign a new owner]. | ||
75 | |||
76 | (*) The "mutex has waiters" bit gets set to take the lock. If the lock | ||
77 | doesn't already have an owner, this bit is quickly cleared if there are | ||
78 | no waiters. So this is a transitional state to synchronize with looking | ||
79 | at the owner field of the mutex and the mutex owner releasing the lock. | ||
diff --git a/Documentation/scsi/ppa.txt b/Documentation/scsi/ppa.txt index 0dac88d86d87..5d9223bc1bd5 100644 --- a/Documentation/scsi/ppa.txt +++ b/Documentation/scsi/ppa.txt | |||
@@ -12,5 +12,3 @@ http://www.torque.net/parport/ | |||
12 | Email list for Linux Parport | 12 | Email list for Linux Parport |
13 | linux-parport@torque.net | 13 | linux-parport@torque.net |
14 | 14 | ||
15 | Email for problems with ZIP or ZIP Plus drivers | ||
16 | campbell@torque.net | ||
diff --git a/Documentation/tty.txt b/Documentation/tty.txt index 8ff7bc2a0811..dab56604745d 100644 --- a/Documentation/tty.txt +++ b/Documentation/tty.txt | |||
@@ -80,13 +80,6 @@ receive_buf() - Hand buffers of bytes from the driver to the ldisc | |||
80 | for processing. Semantics currently rather | 80 | for processing. Semantics currently rather |
81 | mysterious 8( | 81 | mysterious 8( |
82 | 82 | ||
83 | receive_room() - Can be called by the driver layer at any time when | ||
84 | the ldisc is opened. The ldisc must be able to | ||
85 | handle the reported amount of data at that instant. | ||
86 | Synchronization between active receive_buf and | ||
87 | receive_room calls is down to the driver not the | ||
88 | ldisc. Must not sleep. | ||
89 | |||
90 | write_wakeup() - May be called at any point between open and close. | 83 | write_wakeup() - May be called at any point between open and close. |
91 | The TTY_DO_WRITE_WAKEUP flag indicates if a call | 84 | The TTY_DO_WRITE_WAKEUP flag indicates if a call |
92 | is needed but always races versus calls. Thus the | 85 | is needed but always races versus calls. Thus the |
diff --git a/Documentation/video4linux/README.pvrusb2 b/Documentation/video4linux/README.pvrusb2 new file mode 100644 index 000000000000..c73a32c34528 --- /dev/null +++ b/Documentation/video4linux/README.pvrusb2 | |||
@@ -0,0 +1,212 @@ | |||
1 | |||
2 | $Id$ | ||
3 | Mike Isely <isely@pobox.com> | ||
4 | |||
5 | pvrusb2 driver | ||
6 | |||
7 | Background: | ||
8 | |||
9 | This driver is intended for the "Hauppauge WinTV PVR USB 2.0", which | ||
10 | is a USB 2.0 hosted TV Tuner. This driver is a work in progress. | ||
11 | Its history started with the reverse-engineering effort by Björn | ||
12 | Danielsson <pvrusb2@dax.nu> whose web page can be found here: | ||
13 | |||
14 | http://pvrusb2.dax.nu/ | ||
15 | |||
16 | From there Aurelien Alleaume <slts@free.fr> began an effort to | ||
17 | create a video4linux compatible driver. I began with Aurelien's | ||
18 | last known snapshot and evolved the driver to the state it is in | ||
19 | here. | ||
20 | |||
21 | More information on this driver can be found at: | ||
22 | |||
23 | http://www.isely.net/pvrusb2.html | ||
24 | |||
25 | |||
26 | This driver has a strong separation of layers. They are very | ||
27 | roughly: | ||
28 | |||
29 | 1a. Low level wire-protocol implementation with the device. | ||
30 | |||
31 | 1b. I2C adaptor implementation and corresponding I2C client drivers | ||
32 | implemented elsewhere in V4L. | ||
33 | |||
34 | 1c. High level hardware driver implementation which coordinates all | ||
35 | activities that ensure correct operation of the device. | ||
36 | |||
37 | 2. A "context" layer which manages instancing of driver, setup, | ||
38 | tear-down, arbitration, and interaction with high level | ||
39 | interfaces appropriately as devices are hotplugged in the | ||
40 | system. | ||
41 | |||
42 | 3. High level interfaces which glue the driver to various published | ||
43 | Linux APIs (V4L, sysfs, maybe DVB in the future). | ||
44 | |||
45 | The most important shearing layer is between the top 2 layers. A | ||
46 | lot of work went into the driver to ensure that any kind of | ||
47 | conceivable API can be laid on top of the core driver. (Yes, the | ||
48 | driver internally leverages V4L to do its work but that really has | ||
49 | nothing to do with the API published by the driver to the outside | ||
50 | world.) The architecture allows for different APIs to | ||
51 | simultaneously access the driver. I have a strong sense of fairness | ||
52 | about APIs and also feel that it is a good design principle to keep | ||
53 | implementation and interface isolated from each other. Thus while | ||
54 | right now the V4L high level interface is the most complete, the | ||
55 | sysfs high level interface will work equally well for similar | ||
56 | functions, and there's no reason I see right now why it shouldn't be | ||
57 | possible to produce a DVB high level interface that can sit right | ||
58 | alongside V4L. | ||
59 | |||
60 | NOTE: Complete documentation on the pvrusb2 driver is contained in | ||
61 | the html files within the doc directory; these are exactly the same | ||
62 | as what is on the web site at the time. Browse those files | ||
63 | (especially the FAQ) before asking questions. | ||
64 | |||
65 | |||
66 | Building | ||
67 | |||
68 | To build these modules essentially amounts to just running "Make", | ||
69 | but you need the kernel source tree nearby and you will likely also | ||
70 | want to set a few controlling environment variables first in order | ||
71 | to link things up with that source tree. Please see the Makefile | ||
72 | here for comments that explain how to do that. | ||
73 | |||
74 | |||
75 | Source file list / functional overview: | ||
76 | |||
77 | (Note: The term "module" used below generally refers to loosely | ||
78 | defined functional units within the pvrusb2 driver and bears no | ||
79 | relation to the Linux kernel's concept of a loadable module.) | ||
80 | |||
81 | pvrusb2-audio.[ch] - This is glue logic that resides between this | ||
82 | driver and the msp3400.ko I2C client driver (which is found | ||
83 | elsewhere in V4L). | ||
84 | |||
85 | pvrusb2-context.[ch] - This module implements the context for an | ||
86 | instance of the driver. Everything else eventually ties back to | ||
87 | or is otherwise instanced within the data structures implemented | ||
88 | here. Hotplugging is ultimately coordinated here. All high level | ||
89 | interfaces tie into the driver through this module. This module | ||
90 | helps arbitrate each interface's access to the actual driver core, | ||
91 | and is designed to allow concurrent access through multiple | ||
92 | instances of multiple interfaces (thus you can for example change | ||
93 | the tuner's frequency through sysfs while simultaneously streaming | ||
94 | video through V4L out to an instance of mplayer). | ||
95 | |||
96 | pvrusb2-debug.h - This header defines a printk() wrapper and a mask | ||
97 | of debugging bit definitions for the various kinds of debug | ||
98 | messages that can be enabled within the driver. | ||
99 | |||
100 | pvrusb2-debugifc.[ch] - This module implements a crude command line | ||
101 | oriented debug interface into the driver. Aside from being part | ||
102 | of the process for implementing manual firmware extraction (see | ||
103 | the pvrusb2 web site mentioned earlier), probably I'm the only one | ||
104 | who has ever used this. It is mainly a debugging aid. | ||
105 | |||
106 | pvrusb2-eeprom.[ch] - This is glue logic that resides between this | ||
107 | driver the tveeprom.ko module, which is itself implemented | ||
108 | elsewhere in V4L. | ||
109 | |||
110 | pvrusb2-encoder.[ch] - This module implements all protocol needed to | ||
111 | interact with the Conexant mpeg2 encoder chip within the pvrusb2 | ||
112 | device. It is a crude echo of corresponding logic in ivtv, | ||
113 | however the design goals (strict isolation) and physical layer | ||
114 | (proxy through USB instead of PCI) are enough different that this | ||
115 | implementation had to be completely different. | ||
116 | |||
117 | pvrusb2-hdw-internal.h - This header defines the core data structure | ||
118 | in the driver used to track ALL internal state related to control | ||
119 | of the hardware. Nobody outside of the core hardware-handling | ||
120 | modules should have any business using this header. All external | ||
121 | access to the driver should be through one of the high level | ||
122 | interfaces (e.g. V4L, sysfs, etc), and in fact even those high | ||
123 | level interfaces are restricted to the API defined in | ||
124 | pvrusb2-hdw.h and NOT this header. | ||
125 | |||
126 | pvrusb2-hdw.h - This header defines the full internal API for | ||
127 | controlling the hardware. High level interfaces (e.g. V4L, sysfs) | ||
128 | will work through here. | ||
129 | |||
130 | pvrusb2-hdw.c - This module implements all the various bits of logic | ||
131 | that handle overall control of a specific pvrusb2 device. | ||
132 | (Policy, instantiation, and arbitration of pvrusb2 devices fall | ||
133 | within the jurisdiction of pvrusb-context not here). | ||
134 | |||
135 | pvrusb2-i2c-chips-*.c - These modules implement the glue logic to | ||
136 | tie together and configure various I2C modules as they attach to | ||
137 | the I2C bus. There are two versions of this file. The "v4l2" | ||
138 | version is intended to be used in-tree alongside V4L, where we | ||
139 | implement just the logic that makes sense for a pure V4L | ||
140 | environment. The "all" version is intended for use outside of | ||
141 | V4L, where we might encounter other possibly "challenging" modules | ||
142 | from ivtv or older kernel snapshots (or even the support modules | ||
143 | in the standalone snapshot). | ||
144 | |||
145 | pvrusb2-i2c-cmd-v4l1.[ch] - This module implements generic V4L1 | ||
146 | compatible commands to the I2C modules. It is here where state | ||
147 | changes inside the pvrusb2 driver are translated into V4L1 | ||
148 | commands that are in turn send to the various I2C modules. | ||
149 | |||
150 | pvrusb2-i2c-cmd-v4l2.[ch] - This module implements generic V4L2 | ||
151 | compatible commands to the I2C modules. It is here where state | ||
152 | changes inside the pvrusb2 driver are translated into V4L2 | ||
153 | commands that are in turn send to the various I2C modules. | ||
154 | |||
155 | pvrusb2-i2c-core.[ch] - This module provides an implementation of a | ||
156 | kernel-friendly I2C adaptor driver, through which other external | ||
157 | I2C client drivers (e.g. msp3400, tuner, lirc) may connect and | ||
158 | operate corresponding chips within the the pvrusb2 device. It is | ||
159 | through here that other V4L modules can reach into this driver to | ||
160 | operate specific pieces (and those modules are in turn driven by | ||
161 | glue logic which is coordinated by pvrusb2-hdw, doled out by | ||
162 | pvrusb2-context, and then ultimately made available to users | ||
163 | through one of the high level interfaces). | ||
164 | |||
165 | pvrusb2-io.[ch] - This module implements a very low level ring of | ||
166 | transfer buffers, required in order to stream data from the | ||
167 | device. This module is *very* low level. It only operates the | ||
168 | buffers and makes no attempt to define any policy or mechanism for | ||
169 | how such buffers might be used. | ||
170 | |||
171 | pvrusb2-ioread.[ch] - This module layers on top of pvrusb2-io.[ch] | ||
172 | to provide a streaming API usable by a read() system call style of | ||
173 | I/O. Right now this is the only layer on top of pvrusb2-io.[ch], | ||
174 | however the underlying architecture here was intended to allow for | ||
175 | other styles of I/O to be implemented with additonal modules, like | ||
176 | mmap()'ed buffers or something even more exotic. | ||
177 | |||
178 | pvrusb2-main.c - This is the top level of the driver. Module level | ||
179 | and USB core entry points are here. This is our "main". | ||
180 | |||
181 | pvrusb2-sysfs.[ch] - This is the high level interface which ties the | ||
182 | pvrusb2 driver into sysfs. Through this interface you can do | ||
183 | everything with the driver except actually stream data. | ||
184 | |||
185 | pvrusb2-tuner.[ch] - This is glue logic that resides between this | ||
186 | driver and the tuner.ko I2C client driver (which is found | ||
187 | elsewhere in V4L). | ||
188 | |||
189 | pvrusb2-util.h - This header defines some common macros used | ||
190 | throughout the driver. These macros are not really specific to | ||
191 | the driver, but they had to go somewhere. | ||
192 | |||
193 | pvrusb2-v4l2.[ch] - This is the high level interface which ties the | ||
194 | pvrusb2 driver into video4linux. It is through here that V4L | ||
195 | applications can open and operate the driver in the usual V4L | ||
196 | ways. Note that **ALL** V4L functionality is published only | ||
197 | through here and nowhere else. | ||
198 | |||
199 | pvrusb2-video-*.[ch] - This is glue logic that resides between this | ||
200 | driver and the saa711x.ko I2C client driver (which is found | ||
201 | elsewhere in V4L). Note that saa711x.ko used to be known as | ||
202 | saa7115.ko in ivtv. There are two versions of this; one is | ||
203 | selected depending on the particular saa711[5x].ko that is found. | ||
204 | |||
205 | pvrusb2.h - This header contains compile time tunable parameters | ||
206 | (and at the moment the driver has very little that needs to be | ||
207 | tuned). | ||
208 | |||
209 | |||
210 | -Mike Isely | ||
211 | isely@pobox.com | ||
212 | |||
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt index f2cd6ef53ff3..6887d44d2661 100644 --- a/Documentation/x86_64/boot-options.txt +++ b/Documentation/x86_64/boot-options.txt | |||
@@ -205,6 +205,27 @@ IOMMU | |||
205 | pages Prereserve that many 128K pages for the software IO bounce buffering. | 205 | pages Prereserve that many 128K pages for the software IO bounce buffering. |
206 | force Force all IO through the software TLB. | 206 | force Force all IO through the software TLB. |
207 | 207 | ||
208 | calgary=[64k,128k,256k,512k,1M,2M,4M,8M] | ||
209 | calgary=[translate_empty_slots] | ||
210 | calgary=[disable=<PCI bus number>] | ||
211 | |||
212 | 64k,...,8M - Set the size of each PCI slot's translation table | ||
213 | when using the Calgary IOMMU. This is the size of the translation | ||
214 | table itself in main memory. The smallest table, 64k, covers an IO | ||
215 | space of 32MB; the largest, 8MB table, can cover an IO space of | ||
216 | 4GB. Normally the kernel will make the right choice by itself. | ||
217 | |||
218 | translate_empty_slots - Enable translation even on slots that have | ||
219 | no devices attached to them, in case a device will be hotplugged | ||
220 | in the future. | ||
221 | |||
222 | disable=<PCI bus number> - Disable translation on a given PHB. For | ||
223 | example, the built-in graphics adapter resides on the first bridge | ||
224 | (PCI bus number 0); if translation (isolation) is enabled on this | ||
225 | bridge, X servers that access the hardware directly from user | ||
226 | space might stop working. Use this option if you have devices that | ||
227 | are accessed from userspace directly on some PCI host bridge. | ||
228 | |||
208 | Debugging | 229 | Debugging |
209 | 230 | ||
210 | oops=panic Always panic on oopses. Default is to just kill the process, | 231 | oops=panic Always panic on oopses. Default is to just kill the process, |