This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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


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.

Paolo.


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