[PATCH] Remove cached PID/TID in clone
Florian Weimer
fw@deneb.enyo.de
Tue Nov 8 20:11:00 GMT 2016
* Adhemerval Zanella:
>> It's a hotspot for incorrect/broken fork detection.
>
> If you mean the assert on fork.c, I review the code and it seems
> unnecessary to remove the assert on child creation:
No, something else entirely. OpenSSL mixes the current PID into the
randomness pool, in an attempt to make sure that the streams generated
by parent and child are different:
pid_t curr_pid = getpid();
…
if (curr_pid) { /* just in the first iteration to save time */
if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof curr_pid))
goto err;
curr_pid = 0;
}
<https://github.com/openssl/openssl/blob/master/crypto/rand/md_rand.c#L283>
This happens at every invocation of RAND_bytes. It may show up in
profiles if all the other system calls (time, gettimeofday etc.) are
handled by the vDSO.
But I suggest that this shouldn't block your change. It's just
something we should be aware of. If the kernel provides a more
efficient way to get the PID, we can change glibc to use it.
More comments about your revised patch tomorrow.
More information about the Libc-alpha
mailing list