This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Profile mode maintenance patch
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: FranÃois Dumont <frs dot dumont at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 23 Sep 2014 23:45:47 +0100
- Subject: Re: Profile mode maintenance patch
- Authentication-results: sourceware.org; auth=none
- References: <541F4331 dot 1070701 at gmail dot com> <20140923112712 dot GN2669 at redhat dot com> <5421E3FB dot 20003 at gmail dot com>
On 23 September 2014 22:19, FranÃois Dumont wrote:
> On 23/09/2014 13:27, Jonathan Wakely wrote:
>>
>> On 21/09/14 23:29 +0200, FranÃois Dumont wrote:
>>>
>>> With all those modifications I have been able to run all testsuite in
>>> profile mode with success.
>>
>>
>> I've looked over the patch and it looks fine.
>>
>> I don't know the details of the Profile Mode, so if you're happy that
>> these changes are an improvement and all tests pass then that's good
>> enough for me.
>>
>>> Ok to commit ?
>>
>>
>> Yes, OK for trunk - thanks very much.
>>
>>
>
> Ok but could you just let me know what you think of this method:
>
> template<typename __object_info, typename __stack_info>
> __object_info*
> __trace_base<__object_info, __stack_info>::
> __add_object(const __object_info& __info)
> {
> if (__max_mem() != 0 && __objects_byte_size >= __max_mem())
> {
> delete __info.__stack();
> return 0;
> }
>
> __object_info* __ret = new(std::nothrow) __object_info(__info);
> if (!__ret)
> {
> delete __info.__stack();
> return 0;
> }
>
> __gnu_cxx::__atomic_add(&__objects_byte_size, sizeof(__object_info));
> return __ret;
> }
>
> This method can be called from several threads. I check condition accessing
> __object_byte_size and then update it with an atomic operation to make sure
> it stays consistent. Does it look ok to you too ?
It can result in a data race if the non-atomic access happens
concurrently with the atomic update.
The read should be an atomic load to solve that, but we don't have a
dispatch function in <ext/atomicity.h> for atomic loads.