lkml.org 
[lkml]   [2023]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] threads: Update PID limit comment according to futex UAPI change
Date
On Thu, May 11 2023 at 14:47, Thomas Gleixner wrote:
>> #define FUTEX_TID_MASK 0x3fffffff
>
> That futex mask is irrelevant because there is another limitiation for
> the PID space namely posix CPU timers:
>
> static inline clockid_t make_process_cpuclock(const unsigned int pid,
> const clockid_t clock)
> {
> return ((~pid) << 3) | clock;
> }
>
> That existed even before we fiddled with robust futexes and puts a hard
> limit of 29 bits on the PID space.

Actually it's worse than this. The limit is 28 bits because posix CPU
timers rely on this:

static const struct k_clock *clockid_to_kclock(const clockid_t id)
{
clockid_t idx = id;

if (id < 0) {
return (id & CLOCKFD_MASK) == CLOCKFD ?
&clock_posix_dynamic : &clock_posix_cpu;
}
....

So TID must be smaller than 2^28 because if bit 28 would be set, then
the resulting clock would be positive after shift.

Sigh...

\
 
 \ /
  Last update: 2023-05-11 15:28    [W:0.145 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site