Skip to content

Commit 9c40365

Browse files
thejhKAGA-KOKO
authored andcommitted
threads: Update PID limit comment according to futex UAPI change
The futex UAPI changed back in commit 76b81e2 ("[PATCH] lightweight robust futexes updates 2"), which landed in v2.6.17: FUTEX_TID_MASK is now 0x3fffffff instead of 0x1fffffff. Update the corresponding comment in include/linux/threads.h. Documentation mentions that only the lower 29 bits are available for TID storage, but as the UAPI header released the bit already via FUTEX_TID_MASK, this is moot as well. Fix it up. [ tglx: Fixed up documentation ] Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 6c8116c commit 9c40365

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Documentation/robust-futex-ABI.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ setup that list.
6161
address of the associated 'lock entry', plus or minus, of what will
6262
be called the 'lock word', from that 'lock entry'. The 'lock word'
6363
is always a 32 bit word, unlike the other words above. The 'lock
64-
word' holds 3 flag bits in the upper 3 bits, and the thread id (TID)
65-
of the thread holding the lock in the bottom 29 bits. See further
64+
word' holds 2 flag bits in the upper 2 bits, and the thread id (TID)
65+
of the thread holding the lock in the bottom 30 bits. See further
6666
below for a description of the flag bits.
6767

6868
The third word, called 'list_op_pending', contains transient copy of
@@ -128,7 +128,7 @@ that thread's robust_futex linked lock list a given time.
128128
A given futex lock structure in a user shared memory region may be held
129129
at different times by any of the threads with access to that region. The
130130
thread currently holding such a lock, if any, is marked with the threads
131-
TID in the lower 29 bits of the 'lock word'.
131+
TID in the lower 30 bits of the 'lock word'.
132132

133133
When adding or removing a lock from its list of held locks, in order for
134134
the kernel to correctly handle lock cleanup regardless of when the task
@@ -141,7 +141,7 @@ On insertion:
141141
1) set the 'list_op_pending' word to the address of the 'lock entry'
142142
to be inserted,
143143
2) acquire the futex lock,
144-
3) add the lock entry, with its thread id (TID) in the bottom 29 bits
144+
3) add the lock entry, with its thread id (TID) in the bottom 30 bits
145145
of the 'lock word', to the linked list starting at 'head', and
146146
4) clear the 'list_op_pending' word.
147147

@@ -155,7 +155,7 @@ On removal:
155155

156156
On exit, the kernel will consider the address stored in
157157
'list_op_pending' and the address of each 'lock word' found by walking
158-
the list starting at 'head'. For each such address, if the bottom 29
158+
the list starting at 'head'. For each such address, if the bottom 30
159159
bits of the 'lock word' at offset 'offset' from that address equals the
160160
exiting threads TID, then the kernel will do two things:
161161

@@ -180,7 +180,5 @@ any point:
180180
future kernel configuration changes) elements.
181181

182182
When the kernel sees a list entry whose 'lock word' doesn't have the
183-
current threads TID in the lower 29 bits, it does nothing with that
183+
current threads TID in the lower 30 bits, it does nothing with that
184184
entry, and goes on to the next entry.
185-
186-
Bit 29 (0x20000000) of the 'lock word' is reserved for future use.

include/linux/threads.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
/*
3131
* A maximum of 4 million PIDs should be enough for a while.
32-
* [NOTE: PID/TIDs are limited to 2^29 ~= 500+ million, see futex.h.]
32+
* [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.]
3333
*/
3434
#define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
3535
(sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))

0 commit comments

Comments
 (0)