On Wed, Mar 28, 2018 at 11:04 PM, Geert Uytterhoeven <ge...@linux-m68k.org> wrote: > On Thu, Mar 29, 2018 at 12:35 AM, Richard Weinberger <rich...@nod.at> wrote: >> Am Donnerstag, 29. März 2018, 00:19:39 CEST schrieb Joel Fernandes: >>> On Wed, Mar 28, 2018 at 6:19 AM, Richard Weinberger <rich...@nod.at> wrote: >>> > Am Mittwoch, 28. März 2018, 15:11:29 CEST schrieb Geert Uytterhoeven: >>> >> On Wed, Mar 28, 2018 at 12:28 PM, Joel Fernandes <agnel.j...@gmail.com> >>> > wrote: >>> >> > while(release_now == 0); >>> >> >>> >> while (release_now == 0) >>> >> cpu_relax(); >>> > >>> > Not sure whether a cpu_relax() fixes the problem. >>> > I guess the root of the problem is that UML is UP and non-preemptive. >>> > Therefore the loop is never interrupted. >>> > To verify I asked for the full source. >>> > >>> >>> cpu_relax actually worked! >> >> Interesting. >> >>> Any thoughts on why it helps? Even if its non-preemptive, I did >>> receive the timer interrupt, so I expected the variable to be set. >> >> Timers trigger also with preempt off, I forgot... >> I think the cpu_relax() issues internally a barrier such that the >> release_now variable is read again. >> Can you try barrier() instead of cpu_relax()? I bet it works too. >> Same if you mark release_now as volatile. > > Without cpu_relax()/barrier()/volatile, the compiler can assume release_now > never changes, and thus may "optimize" the loop to an infinite loop. >
Thanks a lot! I am wondering why the same compiler works when running the test for a regular image. Maybe different compiler flags. Anyway good to learn this. Also one more slightly OT question, why is UML only doing UP ? Is it extremely hard to do SMP for UML? I also happen to notice Qemu has one thread per emulated core... thanks, - Joel ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel