Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-06 Thread Florian Weimer
On 06/03/2016 02:26 PM, Torvald Riegel wrote: On Fri, 2016-06-03 at 12:03 +0200, Jakub Jelinek wrote: I guess it is a tough decision. If you don't have HW instruction to read say double word aligned integer atomically, if you don't implement atomic load on it through compare and swap (which ind

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Richard Henderson
On 06/03/2016 05:32 AM, Jakub Jelinek wrote: A change from wide CAS to locking would be an ABI change I suppose, but it could also be considered a necessary bugfix if we don't want to write to read-only memory. Does this affect anything but i686? Also x86_64 (for 128-bit atomics), clearly also

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Torvald Riegel
On Fri, 2016-06-03 at 13:46 +0100, Kyrill Tkachov wrote: > Hi Jakub, Torvald, > > On 03/06/16 13:32, Jakub Jelinek wrote: > > On Fri, Jun 03, 2016 at 02:26:09PM +0200, Torvald Riegel wrote: > >> And that would be fine, IMO. If you can't even load atomically, doing > >> something useful with this

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Torvald Riegel
On Fri, 2016-06-03 at 14:32 +0200, Jakub Jelinek wrote: > On Fri, Jun 03, 2016 at 02:26:09PM +0200, Torvald Riegel wrote: > > And that would be fine, IMO. If you can't even load atomically, doing > > something useful with this type will be hard except in special cases. > > Also, doing a CAS (compa

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Kyrill Tkachov
Hi Jakub, Torvald, On 03/06/16 13:32, Jakub Jelinek wrote: On Fri, Jun 03, 2016 at 02:26:09PM +0200, Torvald Riegel wrote: And that would be fine, IMO. If you can't even load atomically, doing something useful with this type will be hard except in special cases. Also, doing a CAS (compare-and-

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Jakub Jelinek
On Fri, Jun 03, 2016 at 02:26:09PM +0200, Torvald Riegel wrote: > And that would be fine, IMO. If you can't even load atomically, doing > something useful with this type will be hard except in special cases. > Also, doing a CAS (compare-and-swap) and thus potentially bringing in > the cache line i

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Torvald Riegel
On Fri, 2016-06-03 at 12:03 +0200, Jakub Jelinek wrote: > On Fri, Jun 03, 2016 at 10:34:15AM +0100, Kyrill Tkachov wrote: > > expand_atomic_load in optabs.c tries to expand a wide atomic load using an > > atomic_compare_and_swap > > with the comment saying that sometimes a redundant harmless store

Re: Implementing atomic load as compare-and-swap for read-only memory

2016-06-03 Thread Jakub Jelinek
On Fri, Jun 03, 2016 at 10:34:15AM +0100, Kyrill Tkachov wrote: > expand_atomic_load in optabs.c tries to expand a wide atomic load using an > atomic_compare_and_swap > with the comment saying that sometimes a redundant harmless store may be > performed. > Is the store really valid if the memory