]> granicus.if.org Git - openssl/commit
bignum: allow concurrent BN_MONT_CTX_set_locked()
authorGeoff Thorpe <geoff@openssl.org>
Sun, 4 May 2014 20:19:22 +0000 (16:19 -0400)
committerGeoff Thorpe <geoff@openssl.org>
Tue, 6 May 2014 22:01:59 +0000 (18:01 -0400)
commitbf43446835bfd3f9abf1898a99ae20f2285320f3
tree46fa8db63805224711b6dd672efa10cc10fee56e
parent7169e56d6b8972cdefff911a4402823c71cbf836
bignum: allow concurrent BN_MONT_CTX_set_locked()

The lazy-initialisation of BN_MONT_CTX was serialising all threads, as
noted by Daniel Sands and co at Sandia. This was to handle the case that
2 or more threads race to lazy-init the same context, but stunted all
scalability in the case where 2 or more threads are doing unrelated
things! We favour the latter case by punishing the former. The init work
gets done by each thread that finds the context to be uninitialised, and
we then lock the "set" logic after that work is done - the winning
thread's work gets used, the losing threads throw away what they've done.

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
crypto/bn/bn_mont.c