Messages in this thread | | | From | Linus Torvalds <> | Date | Sat, 30 Jul 2011 15:35:29 -1000 | Subject | Re: [PATCH 1/2] random: Add support for architectural random hooks |
| |
On Sat, Jul 30, 2011 at 3:02 PM, Bryan Donlan <bdonlan@gmail.com> wrote: > > The problem, as you can see here, is we need to test for the existence > of an architecture-specific HWRNG once for _every word processed_.
See the patch I sent out. Not only doesn't it check an architecture-specific flag on x86, IT COSTS NOTHING AT ALL on other architectures. Not per byte, not per call, not at all.
On x86, it does have the cost of:
- basically one conditional for the whole loop (branching out if there is no rdrand support at all). You cannot do much better than that, except of course if you statically say "compile for an x86 that doesn't have rdrand")
- a per-word cost of checking CF - which you are supposed to do anyway (ie the rdrand hardware will return with CF clear if the data isn't reliable).
So at least on x86, I think you can get pretty close to "optimal behavior" with my approach.
Linus
| |