This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove cached PID/TID in clone


* 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]