[PATCH] Set -fprofile-update=atomic when -pthread is present

Jeff Law law@redhat.com
Wed Oct 5 17:54:00 GMT 2016


On 10/04/2016 06:05 AM, Martin Liška wrote:
> On 10/03/2016 02:26 PM, Nathan Sidwell wrote:
>> > On 10/03/16 08:13, Martin Liška wrote:
>>> >> On 08/18/2016 05:53 PM, Jeff Law wrote:
>>>> >>> On 08/18/2016 09:51 AM, Andi Kleen wrote:
>>>>>> >>>>> I'd prefer to make updates atomic in multi-threaded applications.
>>>>>> >>>>> The best proxy we have for that is -pthread.
>>>>>> >>>>>
>>>>>> >>>>> Is it slower, most definitely, but odds are we're giving folks
>>>>>> >>>>> garbage data otherwise, which in many ways is even worse.
>>>>> >>>>
>>>>> >>>> It will likely be catastrophically slower in some cases.
>>>>> >>>>
>>>>> >>>> Catastrophically as in too slow to be usable.
>>>>> >>>>
>>>>> >>>> An atomic instruction is a lot more expensive than a single increment. Also
>>>>> >>>> they sometimes are really slow depending on the state of the machine.
>>>> >>> And for those cases there's a way to override.
>>>> >>>
>>>> >>> The default should be set for correctness.
>>>> >>>
>>>> >>> jeff
>>> >>
>>> >> I would to somehow resolve the discussion related to default value selection.
>>> >> Is the prevailing consensus that we should set -fprofile-update=atomic when
>>> >> -pthread is set? If so, I'll prepare a patch. I tend to do it this way.
>> >
>> > This is my preference.
>> >
>> > nathan
> Ok, this is final version of patch which implements both the warning and appending -fprofile-update
> to a command line options.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?
> Martin
>
>
> 0001-Add-fprofile-update-option-juggling.patch
>
>
> From 343d64a3c6b515053459a8ece6f9b0ad6ce86273 Mon Sep 17 00:00:00 2001
> From: marxin <mliska@suse.cz>
> Date: Tue, 4 Oct 2016 10:46:48 +0200
> Subject: [PATCH] Add -fprofile-update option juggling
>
> gcc/ChangeLog:
>
> 2016-10-04  Martin Liska  <mliska@suse.cz>
>
> 	* gcc.c: Set -fprofile-update=atomic when profiling is
> 	enabled and -pthread is set.  Warn when one combines
> 	-pthread and -fprofile-update=single for an app using
> 	profiling code.
OK.
jeff



More information about the Gcc-patches mailing list