<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 9:42 AM, Thomas Schatzl <span dir="ltr"><<a href="mailto:thomas.schatzl@oracle.com" target="_blank">thomas.schatzl@oracle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On Wed, 2016-09-07 at 09:01 -0400, Vitaly Davidovich wrote:<br>
> Hi Thomas,<br>
><br>
</span><span class="">> On Wed, Sep 7, 2016 at 8:50 AM, Thomas Schatzl <thomas.schatzl@oracle<br>
> .com> wrote:<br>
> > Hi Vitaly,<br>
> ><br>
> > On Wed, 2016-09-07 at 10:54 +0000, Vitaly Davidovich wrote:<br>
> > > Hi Thomas,<br>
> > ><br>
> > > Why does the G1PretouchTask use an atomic ptr add to advance the<br>
> > > touch address?<br>
> ><br>
> >   to make sure that a particular thread gets a unique page to<br>
> > touch. <br>
> ><br>
> > Otherwise multiple threads might get the same. While this is not a<br>
> > correctness issue, it's useless work. Also the OS will likely let<br>
> > all but the first thread wait until the page has been allocated and<br>
> > cleared until they can proceed. I.e. the threads will be serialized<br>
> > again.<br>
> Oh, I thought each pretouch task is assigned a range of memory to<br>
> pretouch when its constructed, but apparently they all just "compete"<br>
> to claim the next chunk.  Not a big deal, but is there a reason you<br>
> chose to do it that way instead of assigning disjoint ranges to the<br>
> workers before starting the pretouch? Is it to avoid work imbalance<br>
> or something? <br>
<br>
</span>  there is no particular reason, but imo it makes the code simpler by<br>
following existing patterns, and as you suggested automatically avoids<br>
imbalance.<br>
<br>
The synchronization required on the atomic add is (imo) negligible<br>
compared to pre-touching at least one GB of memory for every thread<br>
(i.e. the thread pre-clearing that memory on behalf of the OS).<br></blockquote><div>Right, was just curious.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
  Thomas<br>
<br></blockquote><div>Thanks </div></div><br></div></div>