Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

futex-requeue-pi.txt: standardize document format

Each text file under Documentation follows a different
format. Some doesn't even have titles!

Change its representation to follow the adopted standard,
using ReST markups for it to be parseable by Sphinx:

- promote level for the document title;
- mark literal blocks.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
db4df481 af7175bc

+42 -41
+42 -41
Documentation/futex-requeue-pi.txt
··· 1 + ================ 1 2 Futex Requeue PI 2 - ---------------- 3 + ================ 3 4 4 5 Requeueing of tasks from a non-PI futex to a PI futex requires 5 6 special handling in order to ensure the underlying rt_mutex is never ··· 21 20 rest to the natural wakeup inherent in unlocking the mutex 22 21 associated with the condvar. 23 22 24 - Consider the simplified glibc calls: 23 + Consider the simplified glibc calls:: 25 24 26 - /* caller must lock mutex */ 27 - pthread_cond_wait(cond, mutex) 28 - { 29 - lock(cond->__data.__lock); 30 - unlock(mutex); 31 - do { 32 - unlock(cond->__data.__lock); 33 - futex_wait(cond->__data.__futex); 34 - lock(cond->__data.__lock); 35 - } while(...) 36 - unlock(cond->__data.__lock); 37 - lock(mutex); 38 - } 25 + /* caller must lock mutex */ 26 + pthread_cond_wait(cond, mutex) 27 + { 28 + lock(cond->__data.__lock); 29 + unlock(mutex); 30 + do { 31 + unlock(cond->__data.__lock); 32 + futex_wait(cond->__data.__futex); 33 + lock(cond->__data.__lock); 34 + } while(...) 35 + unlock(cond->__data.__lock); 36 + lock(mutex); 37 + } 39 38 40 - pthread_cond_broadcast(cond) 41 - { 42 - lock(cond->__data.__lock); 43 - unlock(cond->__data.__lock); 44 - futex_requeue(cond->data.__futex, cond->mutex); 45 - } 39 + pthread_cond_broadcast(cond) 40 + { 41 + lock(cond->__data.__lock); 42 + unlock(cond->__data.__lock); 43 + futex_requeue(cond->data.__futex, cond->mutex); 44 + } 46 45 47 46 Once pthread_cond_broadcast() requeues the tasks, the cond->mutex 48 47 has waiters. Note that pthread_cond_wait() attempts to lock the ··· 54 53 be able to requeue tasks to PI futexes. This support implies that 55 54 upon a successful futex_wait system call, the caller would return to 56 55 user space already holding the PI futex. The glibc implementation 57 - would be modified as follows: 56 + would be modified as follows:: 58 57 59 58 60 - /* caller must lock mutex */ 61 - pthread_cond_wait_pi(cond, mutex) 62 - { 63 - lock(cond->__data.__lock); 64 - unlock(mutex); 65 - do { 66 - unlock(cond->__data.__lock); 67 - futex_wait_requeue_pi(cond->__data.__futex); 68 - lock(cond->__data.__lock); 69 - } while(...) 70 - unlock(cond->__data.__lock); 71 - /* the kernel acquired the mutex for us */ 72 - } 59 + /* caller must lock mutex */ 60 + pthread_cond_wait_pi(cond, mutex) 61 + { 62 + lock(cond->__data.__lock); 63 + unlock(mutex); 64 + do { 65 + unlock(cond->__data.__lock); 66 + futex_wait_requeue_pi(cond->__data.__futex); 67 + lock(cond->__data.__lock); 68 + } while(...) 69 + unlock(cond->__data.__lock); 70 + /* the kernel acquired the mutex for us */ 71 + } 73 72 74 - pthread_cond_broadcast_pi(cond) 75 - { 76 - lock(cond->__data.__lock); 77 - unlock(cond->__data.__lock); 78 - futex_requeue_pi(cond->data.__futex, cond->mutex); 79 - } 73 + pthread_cond_broadcast_pi(cond) 74 + { 75 + lock(cond->__data.__lock); 76 + unlock(cond->__data.__lock); 77 + futex_requeue_pi(cond->data.__futex, cond->mutex); 78 + } 80 79 81 80 The actual glibc implementation will likely test for PI and make the 82 81 necessary changes inside the existing calls rather than creating new