RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread Steven Reddie
esult in loosing the optimisation) to make it generally safe. Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Hurt Sent: Saturday, 9 April 2005 6:07 AM To: openssl-dev@openssl.org Cc: [EMAIL PROTECTED] Subject: RE: OpenSSL use of DCLP may not be

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread Brian Hurt
On Fri, 8 Apr 2005, David Schwartz wrote: Right, and the standard doesn’t require them to. Nor does it require them to perform the operations in order as seen by another processor. OK- my apologies. I was misreading what you were saying. We're on the same page. Right, and I’m arguing

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread David Schwartz
> On Fri, 8 Apr 2005, David Schwartz wrote: > > No. The C standard is not telling the compiler what to do. > > It is saying > > what the system must do when it runs the particular source code. If the > > compiler cannot generate code that makes the system as a whole > > comply with > > the standa

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread Brian Hurt
On Fri, 8 Apr 2005, David Schwartz wrote: No. The C standard is not telling the compiler what to do. It is saying what the system must do when it runs the particular source code. If the compiler cannot generate code that makes the system as a whole comply with the standard, then the compil

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread David Schwartz
> On Thursday 07 April 2005 19:09, David Schwartz wrote: > > > Translation: The compiler can't make assumptions about the state of a > > > variable marked "volatile", and MUST generate code that writes > > > every result > > > stored there as well as code that reads the variable EVERY > > > SING

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread Steven Reddie
and the restrictions imposed on it in relation to accesses to the same memory address. Regards, Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Schneider Sent: Saturday, 9 April 2005 12:08 AM To: openssl-dev@openssl.org Subject: Re: OpenSSL us

Re: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-08 Thread Jim Schneider
I appologize if this gets posted twice - we've recently changed email addresses company-wide, and my old address is the one that's subscribed to openssl-dev. On Thursday 07 April 2005 19:09, David Schwartz wrote: > > Translation: The compiler can't make assumptions about the state of a > > vari

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-07 Thread Steven Reddie
odern MP systems that is rarely the case. Regards, Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Schneider Sent: Friday, 8 April 2005 7:35 AM To: openssl-dev@openssl.org Subject: Re: OpenSSL use of DCLP may not be thread-safe on multiple pro

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-07 Thread David Schwartz
> On Thursday 07 April 2005 16:39, David Schwartz wrote: > A bit off-topic, but... > > If you mean 'volatile', no, that doesn't do anything. Specifically, > > 'volatile' has no special semantics for multi-processors. There may be > > specific compilers where it has such semantics, but the st

Re: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-07 Thread Jim Schneider
On Thursday 07 April 2005 16:39, David Schwartz wrote: A bit off-topic, but... > If you mean 'volatile', no, that doesn't do anything. Specifically, > 'volatile' has no special semantics for multi-processors. There may be > specific compilers where it has such semantics, but the standard doe

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-07 Thread David Schwartz
> It strikes me that the H/W designers have played a bit "fast and > loose" with > the cache consistency issue here For the vast majority of cases, this is a pure speed boost. For the tiny number of cases where it causes a problem, you use mutexes. > - I believe I understand the C/C++ >

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-07 Thread Steven Reddie
ssage- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David C. Partridge Sent: Thursday, 7 April 2005 6:17 PM To: openssl-dev@openssl.org Subject: RE: OpenSSL use of DCLP may not be thread-safe on multiple processors Thanks all. It strikes me that the H/W designers have played a bit

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-07 Thread David C. Partridge
Thanks all. It strikes me that the H/W designers have played a bit "fast and loose" with the cache consistency issue here - I believe I understand the C/C++ optimisation issues, and these CAN be worked around (IMHO) within the rules of the standard by using bool in some cases. However I've notifi

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread David Schwartz
> Since aquiring the mutex is already on the 'slow' track, > couldn't you > just aquire a second (pointless) mutex inside the first around only the > 'initialized=1;' assignment? If mutexes resolve the initial situation > then they must be implemented with a memory fence (in the itanium > model),

Re: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread Andrew Mann
David Schwartz wrote: I mean that if the order of memory write visibility between processors can't be g'teed, than a whole lot MORE than just DCLP crashes and burns ... How in that case can anyone write safe MP code? D. The only correct and safe way to do it is with mutexes or their equ

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread David Schwartz
> I mean that if the order of memory write visibility between > processors can't > be g'teed, than a whole lot MORE than just DCLP crashes and burns ... How > in that case can anyone write safe MP code? > > D. The only correct and safe way to do it is with mutexes or their equivalent. D

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread Steven Reddie
use locks can be thread-unsafe it can be even more thread-unsafe when reordering is involved. Regards, Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David C. Partridge Sent: Thursday, 7 April 2005 12:56 AM To: openssl-dev@openssl.org Subject: RE: Open

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread David C. Partridge
ARGH! Are you absolutely sure that this is the case - that's scary - I thought that the whole issue of SMP cache coherency and write order was solved years ago. I mean that if the order of memory write visibility between processors can't be g'teed, than a whole lot MORE than just DCLP cra

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread Steven Reddie
whether I've got this right ... Dave Partridge -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Reddie Sent: 06 April 2005 10:02 To: openssl-dev@openssl.org Subject: OpenSSL use of DCLP may not be thread-safe on multiple processors Hi All, OpenSSL m

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread David C. Partridge
] Subject: RE: OpenSSL use of DCLP may not be thread-safe on multiple processors I've just read the paper, and I believe that the following variation on the code would work and would avoid the MP unsafe issues raised because bool is defined to be a single byte. Further-more, I'm pretty certa

RE: OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread David C. Partridge
artridge -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven Reddie Sent: 06 April 2005 10:02 To: openssl-dev@openssl.org Subject: OpenSSL use of DCLP may not be thread-safe on multiple processors Hi All, OpenSSL makes use of the DCLP (double-checked locking p

OpenSSL use of DCLP may not be thread-safe on multiple processors

2005-04-06 Thread Steven Reddie
Hi All, OpenSSL makes use of the DCLP (double-checked locking pattern) in a number of places (rsa_eay.c and at least one engine; I haven't done an exhaustive search), with code that usually looks like this: if (x == NULL) { CRYPTO_w_lock(CRYPTO_LOCK_XXX); /* Avoid a race