[libvirt] [PATCH 0/6] Add virNodeGetMemoryStats() API

Daniel P. Berrange berrange at redhat.com
Fri May 27 13:39:03 UTC 2011


On Wed, May 25, 2011 at 05:53:02PM +0900, Minoru Usui wrote:
> Hi, everyone.
> 
> I wrote new API called virNodeGetMemoryStats().
> It returns total/free/buffer/cached memory of the node from /proc/meminfo.
> The user I/F is like virNodeGetCPUStats().
> 
> Previous discussion is here.
> (See about virNodeGetFreeMemory() part.)
> 
>   http://www.mail-archive.com/libvir-list@redhat.com/msg32553.html
> 
> This patch series based on latest git tree.
> If my virNodeGetCPUStats() patch series applied, I'll rebase on it.

As with your patches for CPUStats, I think the code in this
series looks good, but have a question about the API design.
I think we should add a parameter to the API to allow a query
of memory data for individual NUMA cells

 int                     virNodeGetMemoryStats(virConnectPtr conn,
                                               int cellNum,
                                               virMemoryStatsPtr params,
                                               int *nparams,
                                               unsigned int flags);

And a constant to use if wanting cummulative data for all cells

   #define  VIR_NODE_MEMORY_STATS_ALL_CELLS -1

So to get memory stats for each NUMA cell

   virNodeGetMemoryStats(conn, 0, params, nparams, flags);
   virNodeGetMemoryStats(conn, 1, params, nparams, flags);
   virNodeGetMemoryStats(conn, 2, params, nparams, flags);
   virNodeGetMemoryStats(conn, 3, params, nparams, flags);

Or to get memory statas for the whole host

   virNodeGetMemoryStats(conn, VIR_NODE_MEMORY_STATS_ALL_CELLS, params, nparams, flags);

You currently use /proc/meminfo to get the host memory
stats. The per-NUMA node data is available in similar
format at the files:

  /sys/devices/system/node/*/meminfo

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list