<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ldrex/sdrex failures on cortex?</title><link>https://community.arm.com/developer/tools-software/tools/f/armds-forum/396/ldrex-sdrex-failures-on-cortex</link><description> Note: This was originally posted on 20th November 2009 at http://forums.arm.com Hi. I&amp;#39;m trying to implementing an atomic compare-and-swap.&amp;#160; I&amp;#39;ve been working on this for the last month or so and basically non-stop for the last half week or so in an effort</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: ldrex/sdrex failures on cortex?</title><link>https://community.arm.com/thread/641?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:53:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:30289a94-8e20-49f8-b19b-128b4cee6f7d</guid><dc:creator>TobyDouglass TobyDouglass</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 25th November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;After some discussion in the ARM Linux kernel mailing list, the code error has become apparent; the code I&amp;#39;m using in fact permits ABA.&amp;#160; The exchange pointer is loaded prior to the LDREX on destination and so CAS can occur due to ABA which swaps in the wrong exchange pointer.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ldrex/sdrex failures on cortex?</title><link>https://community.arm.com/thread/640?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:53:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:538633b4-5dfb-4f40-a796-72c6f04dd131</guid><dc:creator>TobyDouglass TobyDouglass</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 21st November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I suspect this code fragment is wrong (although fixing it hasn&amp;#39;t fixed the test);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;#160;&amp;#160;&amp;#160; do&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; __asm__ __volatile__&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;ldrex %1, [%2];&amp;quot;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;mov %0, #1;&amp;quot;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;teq %1, %3;&amp;quot;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;strexeq %0, %4, [%2];&amp;quot;&lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // output&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : &amp;quot;=&amp;amp;r&amp;quot; (stored_flag), &amp;quot;=&amp;amp;r&amp;quot; (original_destination)&lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // input&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : &amp;quot;r&amp;quot; (destination), &amp;quot;r&amp;quot; (compare), &amp;quot;r&amp;quot; (exchange)&lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // clobbered&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : &amp;quot;memory&amp;quot;, &amp;quot;cc&amp;quot;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; );&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; while( stored_flag == 1 );&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;The problem is that it permits ABA.&amp;#160; I think the code should in fact return, with &amp;quot;no swap occurred&amp;quot;, in the event that strexeq failed because someone else touched the memory (rather than the compare failing).&amp;#160; (E.g. no while() loop and the prototype needs to indicate to the user the compare failed).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I&amp;#39;ve made that change, but it doesn&amp;#39;t fix things and I&amp;#39;m failing in apparently the exact same way.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ldrex/sdrex failures on cortex?</title><link>https://community.arm.com/thread/639?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:53:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ba728edc-a719-4f7f-8f55-bd642d27bf67</guid><dc:creator>TobyDouglass TobyDouglass</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 21st November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Bit more info;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;With two, three, four, eight, twelve or sixteen threads, the test detects a loop between about 70,000 and 1,200,000 pops.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;However, with two threads, the test passes fairly often.&amp;#160; I&amp;#39;ve never seen a test pass with three or more threads (almost all of my testing has been done with four threads, which is one per core).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;With one thread of course the test always passes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I&amp;#39;ve removed the second dmb (after the ldrex/sdrex); I think it&amp;#39;s not necessary.&amp;#160; I&amp;#39;ve also removed the __sync_sychronized() calls.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>