This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [v3] libstdc++/24469


On 3/16/06, Paolo Carlini <pcarlini@suse.de> wrote:
> Richard Guenther wrote:
>
> >I see the v7 sources have diverged somewhat from the v6 ones, but
> >the patch doesn't look correct.  Either __thread_bin is per thread, in
> >which case you don't need any special locking against other threads,
> >or you are not closing the race window, as f.i.
> >
> >-          --__thread_bin->_M_free;
> >-          ++__thread_bin->_M_used;
> >+          __exchange_and_add(&__thread_bin->_M_free, -1);
> >+          __atomic_add(&__thread_bin->_M_used, 1);
> >
> >will have a window of inconsistent _M_free and _M_used,
> >
> I have also to study again this long standing issue vs the brancd new
> performance improvements contributed by Boreham and Bridges, but in
> fact, in the ""old"" code the issue was rather simple: _M_used, and only
> _M_used, could be changed simultaneously by different threads. Thus, a
> possible fix could involve using __exchange_and_add/__atomic_add on _M_used.

I do not see this concurrent updating of _M_used.  Also if this would
be the case
then there are a _lot_ of places that need protection against this concurrent
modification.  Also I really want to emphasize the comment on the use of the
volatile qualifier - it does no good, neither for optimization, nor for thread
synchronization.  It may contribute to hiding real bugs, so I suggest
to get rid of
all the volatile qualifiers immediately.

Richard.


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