<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
    <cache><br>
      <bank type="l3" size="56320" units="KiB" cpus="0,2,3,6,7,8"/><br>
      <bank type="l3" size="56320" units="KiB" cpus="3,4,5,9,10,11"/><br></blockquote><div><br></div><div>yes, I like this too, it could tell the the resource sharing logic by cpus.</div><div><br></div><div>Another thinking is that if kernel enable CDP, it will split l3 cache to code / data type</div><div>    <cache><br>      <bank type="l3code" size="28160" units="KiB" cpus="0,2,3,6,7,8"/><br>      <bank type="l3data" size="28160" units="KiB" cpus="3,4,5,9,10,11"/><br></div><div><br></div><div>So these information should not only from /sys/devices/system/cpu/cpu0/cache/index3/size , also depend on if linux resctrl under /sys/fs/resctrl/</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
      <bank type="l2" size="256" units="KiB" cpus="0"/><br></blockquote><div> </div><div>I think on your system you don't enable SMT, so if on a system which enabled SMT.</div><div><br></div><div>we will have: </div><div>      <bank type="l2" size="256" units="KiB" cpus="0, 44"/><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
      <bank type="l2" size="256" units="KiB" cpus="1"/><br>
      <bank type="l2" size="256" units="KiB" cpus="2"/><br>
      <bank type="l2" size="256" units="KiB" cpus="3"/><br>
      <bank type="l2" size="256" units="KiB" cpus="4"/><br>
      <bank type="l2" size="256" units="KiB" cpus="5"/><br>
      <bank type="l2" size="256" units="KiB" cpus="6"/><br>
      <bank type="l2" size="256" units="KiB" cpus="7"/><br>
      <bank type="l2" size="256" units="KiB" cpus="8"/><br>
      <bank type="l2" size="256" units="KiB" cpus="9"/><br>
      <bank type="l2" size="256" units="KiB" cpus="10"/><br>
      <bank type="l2" size="256" units="KiB" cpus="11"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="0"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="1"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="2"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="3"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="4"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="5"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="6"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="7"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="8"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="9"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="10"/><br>
      <bank type="l1i" size="256" units="KiB" cpus="11"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="0"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="1"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="2"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="3"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="4"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="5"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="6"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="7"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="8"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="9"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="10"/><br>
      <bank type="l1d" size="256" units="KiB" cpus="11"/><br>
    </cache><br>
<br></blockquote><div><br></div><div><br></div><div>hmm... l2 and l1 cache are per core, I am not sure if we really need to tune the l2 and l1 cache at all, that's too low level.......</div><div><br></div><div>Per my understanding, if we expose this kinds of capabilities, we should support to manage it, just wonder if we are too early to</div><div>expose it since low level (linux kernel) have not support it yet.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
which shows each socket has its own dedicated L3 cache, and each<br>
core has its own L2 & L1 cache.<br>
<span class="gmail-"><br>
> 2. Extend capabilities outputs.<br>
><br>
> virsh capabilities | grep resctrl<br>
>     <cpu><br>
>     ...<br>
>       <resctrl name='L3' unit='KiB' cache_size='56320' cache_unit='2816'/><br>
>     </cpu><br>
><br>
>     This will tell that the host have enabled resctrl(which you can find it in /sys/fs/resctrl),<br>
> And it supports to allocate 'L3' type cache, total 'L3' cache size is 56320 KiB, and the minimum unit size of 'L3' cache is 2816 KiB.<br>
>   P.S. L3 cache size unit is the minum l3 cache unit can be allocated. It's hardware related and can not be changed.<br>
<br>
</span>If we're already reported cache in the capabilities from step<br>
one, then it ought to be extendable to cover this reporting.<br>
<br>
    <cache><br>
      <bank type="l3" size="56320" units="KiB" cpus="0,2,3,6,7,8"><br>
          <control unit="KiB" min="2816"/><br>
      </bank><br>
      <bank type="l3" size="56320" units="KiB" cpus="3,4,5,9,10,11"><br>
          <control unit="KiB" min="2816"/><br>
      </bank><br>
    </cache><br>
<br></blockquote><div><br></div><div>Looks good to me.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
note how we report the control info for both l3 caches, since they<br>
come from separate sockets and thus could conceivably report different<br>
info if different CPUs were in each socket.<br>
<span class="gmail-"><br>
> 3. Add new virsh command 'nodecachestats':<br>
> This API is to expose vary cache resouce left on each hardware (cpu socket).<br>
><br>
> It will be formated as:<br>
><br>
> <resource_type>.<resource_id>: left size KiB<br>
><br>
> for example I have a 2 socket cpus host, and I'v enabled cat_l3 feature only<br>
><br>
> root@s2600wt:~/linux# virsh nodecachestats<br>
> L3.0 : 56320 KiB<br>
> L3.1 : 56320 KiB<br>
><br>
>   P.S. resource_type can be L3, L3DATA, L3CODE, L2 for now.<br>
<br>
</span>This feels like something we should have in the capabilities XML too<br>
rather than a new command<br>
<br>
    <cache><br>
      <bank type="l3" size="56320" units="KiB" cpus="0,2,3,6,7,8"><br>
          <control unit="KiB" min="2816" avail="56320/><br>
      </bank><br>
      <bank type="l3" size="56320" units="KiB" cpus="3,4,5,9,10,11"><br>
          <control unit="KiB" min="2816" avail="56320"/><br>
      </bank><br>
    </cache><br>
<span class="gmail-"><br>
> 4. Add new interface to manage how many cache can be allociated for a domain<br>
><br>
> root@s2600wt:~/linux# virsh cachetune kvm02 --l3.count 2<br>
><br>
> root@s2600wt:~/linux# virsh cachetune kvm02<br>
> l3.count       : 2<br>
><br>
> This will allocate 2 units(2816 * 2) l3 cache for domain kvm02<br>
><br>
> ## Domain XML changes<br>
><br>
> Cache Tuneing<br>
><br>
> <domain><br>
>   ...<br>
>   <cachetune><br>
>     <l3_cache_count>2</l3_cache_<wbr>count><br>
>   </cachetune><br>
>   ...<br>
> </domain><br>
<br>
</span>IIUC, the kernel lets us associate individual PIDs<br>
with each cache. Since each vCPU is a PID, this means<br>
we are able to allocate different cache size to<br>
different CPUs. So we need to be able to represent<br>
that in the XML. I think we should also represent<br>
the allocation in a normal size (ie KiB), not in<br>
count of min unit.<br>
<br></blockquote><div><br></div><div>ok</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
So eg this shows allocating two cache banks and giving<br>
one to the first 4 cpus, and one to the second 4 cpus<br>
<br>
   <cachetune><br>
      <bank type="l3" size="5632" unit="KiB" cpus="0,1,2,3"/><br>
      <bank type="l3" size="5632" unit="KiB" cpus="4,5,6,7"/><br></blockquote><div><br></div><div>oh, that depend what the CPUs topology, so I don't like here to ad cpus = "0, 1, 2 , 3", we can not guarantee VM can running though CPU 0 1 2 3, so they  may not benefit the cache bank. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
   </cachetune><br>
<br>
<br>
Regards,<br>
Daniel<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
|: <a href="http://berrange.com" rel="noreferrer" target="_blank">http://berrange.com</a>      -o-    <a href="http://www.flickr.com/photos/dberrange/" rel="noreferrer" target="_blank">http://www.flickr.com/photos/<wbr>dberrange/</a> :|<br>
|: <a href="http://libvirt.org" rel="noreferrer" target="_blank">http://libvirt.org</a>              -o-             <a href="http://virt-manager.org" rel="noreferrer" target="_blank">http://virt-manager.org</a> :|<br>
|: <a href="http://entangle-photo.org" rel="noreferrer" target="_blank">http://entangle-photo.org</a>       -o-    <a href="http://search.cpan.org/~danberr/" rel="noreferrer" target="_blank">http://search.cpan.org/~<wbr>danberr/</a> :|<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Best regards </div><div>- Eli</div><div><br></div><div>天涯无处不重逢</div><div><span style="color:rgb(0,0,0);font-family:"microsoft yahei",verdana,arial,sans-serif">a leaf duckweed belongs to the sea , where not to meet in life </span><br></div></div></div></div></div>
</div></div>