[libvirt] [PATCH 9/9] conf: Add memory bandwidth allocation capability of host
From: Bing Niu Add new XML section to report host's memory bandwidth allocation capability. The format as below example: . granularity granularity of memory bandwidth, unit percentage. min minimum memory bandwidth allowed, unit percentage. maxAllocs maximum memory bandwidth allocation group supported. Signed-off-by: Bing Niu --- docs/schemas/capability.rng| 33 +++ src/conf/capabilities.c| 108 + src/conf/capabilities.h| 11 +++ src/util/virresctrl.c | 20 src/util/virresctrl.h | 15 +++ .../linux-resctrl/resctrl/info/MB/bandwidth_gran | 1 + .../linux-resctrl/resctrl/info/MB/min_bandwidth| 1 + .../linux-resctrl/resctrl/info/MB/num_closids | 1 + tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 8 ++ tests/virresctrldata/resctrl.schemata | 1 + 10 files changed, 199 insertions(+) create mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/bandwidth_gran create mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/min_bandwidth create mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/num_closids diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index 52164d5..d61515c 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -51,6 +51,9 @@ + + + @@ -326,6 +329,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 7a810ef..3f52296 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -198,6 +198,16 @@ virCapabilitiesFreeNUMAInfo(virCapsPtr caps) } static void +virCapsHostMemBWNodeFree(virCapsHostMemBWNodePtr ptr) +{ +if (!ptr) +return; + +virBitmapFree(ptr->cpus); +VIR_FREE(ptr); +} + +static void virCapabilitiesClearSecModel(virCapsHostSecModelPtr secmodel) { size_t i; @@ -239,6 +249,11 @@ virCapsDispose(void *object) virCapsHostCacheBankFree(caps->host.caches[i]); VIR_FREE(caps->host.caches); +for (i = 0; i < caps->host.nnodes; i++) +virCapsHostMemBWNodeFree(caps->host.nodes[i]); +VIR_FREE(caps->host.nodes); + + VIR_FREE(caps->host.netprefix); VIR_FREE(caps->host.pagesSize); virCPUDefFree(caps->host.cpu); @@ -957,6 +972,58 @@ virCapabilitiesFormatCaches(virBufferPtr buf, return 0; } +static int +virCapabilitiesFormatMemoryBandwidth(virBufferPtr buf, + size_t nnodes, + virCapsHostMemBWNodePtr *nodes) +{ +size_t i = 0; +virBuffer controlBuf = VIR_BUFFER_INITIALIZER; + +if (!nnodes) +return 0; + +virBufferAddLit(buf, "\n"); +virBufferAdjustIndent(buf, 2); + +for (i = 0; i < nnodes; i++) { +virCapsHostMemBWNodePtr node = nodes[i]; +virResctrlInfoMemBWPerNodePtr control = &node->control; +char *cpus_str = virBitmapFormat(node->cpus); + +if (!cpus_str) +return -1; + +virBufferAsprintf(buf, + "id, cpus_str); +VIR_FREE(cpus_str); + +virBufferSetChildIndent(&controlBuf, buf); +virBufferAsprintf(&controlBuf, + "\n", + control->granularity, control->min, + control->max_allocation); + +if (virBufferCheckError(&controlBuf) < 0) +return -1; + +if (virBufferUse(&controlBuf)) { +virBufferAddLit(buf, ">\n"); +virBufferAddBuffer(buf, &controlBuf); +virBufferAddLit(buf, "\n"); +} else { +virBufferAddLit(buf, "/>\n"); +} +} + +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, "\n"); + +return 0; +} + /** * virCapabilitiesFormatXML: * @caps: capabilities to format @@ -1060,6 +1127,10 @@ virCapabilitiesFormatXML(virCapsPtr caps) caps->host.caches) < 0) goto error; +if (virCapabilitiesFormatMemoryBandwidth(&buf, caps->host.nnodes, + caps->host.nodes) < 0) +goto error; + for (i = 0; i < caps->host.nsecModels; i++) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -1602,6 +1673,40 @@ virCapabilitiesInitResctrl(virCapsPtr caps) } +static int +virCapabilitiesInitR
Re: [libvirt] [PATCH 9/9] conf: Add memory bandwidth allocation capability of host
On 07/18/2018 03:57 AM, bing@intel.com wrote: > From: Bing Niu > > Add new XML section to report host's memory bandwidth allocation > capability. The format as below example: > > > . > > > > > > > > granularity granularity of memory bandwidth, unit percentage. > min minimum memory bandwidth allowed, unit percentage. > maxAllocs maximum memory bandwidth allocation group supported. > > Signed-off-by: Bing Niu > --- > docs/schemas/capability.rng| 33 +++ > src/conf/capabilities.c| 108 > + > src/conf/capabilities.h| 11 +++ > src/util/virresctrl.c | 20 > src/util/virresctrl.h | 15 +++ > .../linux-resctrl/resctrl/info/MB/bandwidth_gran | 1 + > .../linux-resctrl/resctrl/info/MB/min_bandwidth| 1 + > .../linux-resctrl/resctrl/info/MB/num_closids | 1 + > tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 8 ++ > tests/virresctrldata/resctrl.schemata | 1 + > 10 files changed, 199 insertions(+) > create mode 100644 > tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/bandwidth_gran > create mode 100644 > tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/min_bandwidth > create mode 100644 > tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/num_closids > What about virsh available views? And similar to the RDT series what about domstats? I think you can get some good ideas from the RDT CMT RFC that's posted. Not even sure if it's already done internally - but pointing it out... It doesn't have to be done as part of the series, but eventually it may be nice. I'll give the following a cursory look as I have other tasks needing some attention. I'll leave it in the back of my mind that I have to be more thorough on the next pass once I get here. > diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng > index 52164d5..d61515c 100644 > --- a/docs/schemas/capability.rng > +++ b/docs/schemas/capability.rng > @@ -51,6 +51,9 @@ > > > > + > + > + > > > > @@ -326,6 +329,36 @@ > > > > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > > > > diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c > index 7a810ef..3f52296 100644 > --- a/src/conf/capabilities.c > +++ b/src/conf/capabilities.c > @@ -198,6 +198,16 @@ virCapabilitiesFreeNUMAInfo(virCapsPtr caps) > } > > static void > +virCapsHostMemBWNodeFree(virCapsHostMemBWNodePtr ptr) > +{ > +if (!ptr) > +return; > + > +virBitmapFree(ptr->cpus); > +VIR_FREE(ptr); > +} > + > +static void > virCapabilitiesClearSecModel(virCapsHostSecModelPtr secmodel) > { > size_t i; > @@ -239,6 +249,11 @@ virCapsDispose(void *object) > virCapsHostCacheBankFree(caps->host.caches[i]); > VIR_FREE(caps->host.caches); > > +for (i = 0; i < caps->host.nnodes; i++) > +virCapsHostMemBWNodeFree(caps->host.nodes[i]); > +VIR_FREE(caps->host.nodes); > + > + Remove one of the blank lines. This was the only issue I saw in my quick glance - rest seemed OK. John > VIR_FREE(caps->host.netprefix); > VIR_FREE(caps->host.pagesSize); > virCPUDefFree(caps->host.cpu); > @@ -957,6 +972,58 @@ virCapabilitiesFormatCaches(virBufferPtr buf, > return 0; > } > > +static int > +virCapabilitiesFormatMemoryBandwidth(virBufferPtr buf, > + size_t nnodes, > + virCapsHostMemBWNodePtr *nodes) > +{ > +size_t i = 0; > +virBuffer controlBuf = VIR_BUFFER_INITIALIZER; > + > +if (!nnodes) > +return 0; > + > +virBufferAddLit(buf, "\n"); > +virBufferAdjustIndent(buf, 2); > + > +for (i = 0; i < nnodes; i++) { > +virCapsHostMemBWNodePtr node = nodes[i]; > +virResctrlInfoMemBWPerNodePtr control = &node->control; > +char *cpus_str = virBitmapFormat(node->cpus); > + > +if (!cpus_str) > +return -1; > + > +virBufferAsprintf(buf, > + " + node->id, cpus_str); > +VIR_FREE(cpus_str); > + > +virBufferSetChildIndent(&controlBuf, buf); > +virBufferAsprintf(&controlBuf, > + " + "maxAllocs='%u'/>\n", > + control->granularity, control->min, > + control->max
Re: [libvirt] [PATCH 9/9] conf: Add memory bandwidth allocation capability of host
On 2018年07月27日 05:04, John Ferlan wrote: On 07/18/2018 03:57 AM, bing@intel.com wrote: From: Bing Niu Add new XML section to report host's memory bandwidth allocation capability. The format as below example: . granularity granularity of memory bandwidth, unit percentage. min minimum memory bandwidth allowed, unit percentage. maxAllocs maximum memory bandwidth allocation group supported. Signed-off-by: Bing Niu --- docs/schemas/capability.rng| 33 +++ src/conf/capabilities.c| 108 + src/conf/capabilities.h| 11 +++ src/util/virresctrl.c | 20 src/util/virresctrl.h | 15 +++ .../linux-resctrl/resctrl/info/MB/bandwidth_gran | 1 + .../linux-resctrl/resctrl/info/MB/min_bandwidth| 1 + .../linux-resctrl/resctrl/info/MB/num_closids | 1 + tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 8 ++ tests/virresctrldata/resctrl.schemata | 1 + 10 files changed, 199 insertions(+) create mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/bandwidth_gran create mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/min_bandwidth create mode 100644 tests/vircaps2xmldata/linux-resctrl/resctrl/info/MB/num_closids What about virsh available views? And similar to the RDT series what about domstats? I think you can get some good ideas from the RDT CMT RFC that's posted. Not even sure if it's already done internally - but pointing it out... It doesn't have to be done as part of the series, but eventually it may be nice. Yes. RDT CMT will follow this memory_bandwidth host capability XML. Huaqiang will handle that. I'll give the following a cursory look as I have other tasks needing some attention. I'll leave it in the back of my mind that I have to be more thorough on the next pass once I get here. diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index 52164d5..d61515c 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -51,6 +51,9 @@ + + + @@ -326,6 +329,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 7a810ef..3f52296 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -198,6 +198,16 @@ virCapabilitiesFreeNUMAInfo(virCapsPtr caps) } static void +virCapsHostMemBWNodeFree(virCapsHostMemBWNodePtr ptr) +{ +if (!ptr) +return; + +virBitmapFree(ptr->cpus); +VIR_FREE(ptr); +} + +static void virCapabilitiesClearSecModel(virCapsHostSecModelPtr secmodel) { size_t i; @@ -239,6 +249,11 @@ virCapsDispose(void *object) virCapsHostCacheBankFree(caps->host.caches[i]); VIR_FREE(caps->host.caches); +for (i = 0; i < caps->host.nnodes; i++) +virCapsHostMemBWNodeFree(caps->host.nodes[i]); +VIR_FREE(caps->host.nodes); + + Remove one of the blank lines. OK. Thanks a lot~ This was the only issue I saw in my quick glance - rest seemed OK. John [.] -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list