Best regards 
- Eli

天涯无处不重逢
a leaf duckweed belongs to the sea, where not to meet in life 

2017-03-03 10:24 GMT+08:00 Marcelo Tosatti <mtosatti@redhat.com>:
On Mon, Feb 27, 2017 at 03:22:56PM +0800, Eli Qiao wrote:
> Add new virsh command line `nodecachestats` to expose the cache usage
> on a node.

Testing:

Setup: one guest with 3072 bytes reserved for it.

hi Marcelo

Thanks for the testing. 

I improved default schemata calculating from V10, and V10 is on the top of master branch.


Test-1: start libvirt with free cache.
resctrlfs default: L3:0=fffff;1=fffff

# LD_LIBRARY_PATH=/root/git/libvirt/src/.libs/ ./virshnodegetcachestats
ret=0 nparams=10
L3.0: 13824
L3.1: 13824

Result: correct.

Test-2: start libvirt with a manual reservation in place
(sharing space with default reservation, which is a
valid scenario).

./schemata: L3:0=fffff;1=fffff
./manualres/schemata: L3:0=f;1=f

How many bytes free there are to allocate?
Mask 0xffff0 is free. Bytes = 12288.

After start libvirt daemon:
Value of resctrlfs files:
./schemata: L3:0=fffff;1=fffff
./manualres/schemata: L3:0=f;1=f

Run cmd:
# LD_LIBRARY_PATH=/root/git/libvirt/src/.libs/ /root/git/virshnodegetcachestats
ret=0 nparams=10
L3.0: 0
L3.1: 0

./schemata: L3:0=3;1=3
./manualres/schemata: L3:0=f;1=f1

Result: incorrect.

Test-3: start libvirt with a manual reservation in place
(not sharing space with default reservation):

./schemata: L3:0=ffff0;1=ffff0
./manualres/schemata: L3:0=f;1=f

How many bytes free there are to allocate?
Mask 0xffff0 is free. Bytes = 12288.

./schemata: L3:0=ffff0;1=ffff0
./manualres/schemata: L3:0=f;1=f

# LD_LIBRARY_PATH=/root/git/libvirt/src/.libs/ /root/git/virshnodegetcachestats
ret=0 nparams=10
L3.0: 0
L3.1: 0

So the interface is very buggy, please fix it (and execute the tests
above to make sure it is fixed).