Linux getrandom() vDSO Patch Updated For ~15x Speedup
Over the summer Jason Donenfeld of WireGuard fame proposed adding getrandom() to the vDSO for better performance to enjoy by user-space developers. This past week he sent out the latest version of this proposed kernel patch where he's seeing around a ~15x speed-up with this change.
Supporting getrandom() in the vDSO is designed to address two problems faced by user-space developers:
Following discussions around implementing getrandom() in the vDSO, Donenfeld revised the patch to incorporate feedback to avoid behavior changes and make vgetrandom_alloc a system call. Plus there are some other smaller fixes/changes.
Jason ended the v3 post with:
Readers may also be interested in a talk by Jason at LPC 2022 around the work he's been doing on the Linux random number generator. The video is below and there is also the slide deck.
Supporting getrandom() in the vDSO is designed to address two problems faced by user-space developers:
1) Userspace wants faster cryptographically secure random numbers of arbitrary size, big or small.
2) Userspace is currently unable to safely roll its own RNG with the same security profile as getrandom().
Following discussions around implementing getrandom() in the vDSO, Donenfeld revised the patch to incorporate feedback to avoid behavior changes and make vgetrandom_alloc a system call. Plus there are some other smaller fixes/changes.
Jason ended the v3 post with:
So far in my test results, performance is pretty stellar (around 15x for uint32_t generation), and it seems to be working. There are a couple TODO bits with the actual random.c lifetime integration, but as an early patchset, this at least introduces the intended interface.
Readers may also be interested in a talk by Jason at LPC 2022 around the work he's been doing on the Linux random number generator. The video is below and there is also the slide deck.
11 Comments