mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
conf: Refactor cache bank capability structure
Move all cache banks into one data structure, this allows us to add other cache component, such as cache monitor. Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
12093f1fea
commit
58fcee6f3a
@ -241,9 +241,9 @@ virCapsDispose(void *object)
|
|||||||
virCapabilitiesClearSecModel(&caps->host.secModels[i]);
|
virCapabilitiesClearSecModel(&caps->host.secModels[i]);
|
||||||
VIR_FREE(caps->host.secModels);
|
VIR_FREE(caps->host.secModels);
|
||||||
|
|
||||||
for (i = 0; i < caps->host.ncaches; i++)
|
for (i = 0; i < caps->host.cache.nbanks; i++)
|
||||||
virCapsHostCacheBankFree(caps->host.caches[i]);
|
virCapsHostCacheBankFree(caps->host.cache.banks[i]);
|
||||||
VIR_FREE(caps->host.caches);
|
VIR_FREE(caps->host.cache.banks);
|
||||||
|
|
||||||
for (i = 0; i < caps->host.nnodes; i++)
|
for (i = 0; i < caps->host.nnodes; i++)
|
||||||
virCapsHostMemBWNodeFree(caps->host.nodes[i]);
|
virCapsHostMemBWNodeFree(caps->host.nodes[i]);
|
||||||
@ -864,21 +864,20 @@ virCapabilitiesFormatNUMATopology(virBufferPtr buf,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virCapabilitiesFormatCaches(virBufferPtr buf,
|
virCapabilitiesFormatCaches(virBufferPtr buf,
|
||||||
size_t ncaches,
|
virCapsHostCachePtr cache)
|
||||||
virCapsHostCacheBankPtr *caches)
|
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
|
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (!ncaches)
|
if (!cache->nbanks)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
virBufferAddLit(buf, "<cache>\n");
|
virBufferAddLit(buf, "<cache>\n");
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
||||||
for (i = 0; i < ncaches; i++) {
|
for (i = 0; i < cache->nbanks; i++) {
|
||||||
virCapsHostCacheBankPtr bank = caches[i];
|
virCapsHostCacheBankPtr bank = cache->banks[i];
|
||||||
char *cpus_str = virBitmapFormat(bank->cpus);
|
char *cpus_str = virBitmapFormat(bank->cpus);
|
||||||
const char *unit = NULL;
|
const char *unit = NULL;
|
||||||
unsigned long long short_size = virFormatIntPretty(bank->size, &unit);
|
unsigned long long short_size = virFormatIntPretty(bank->size, &unit);
|
||||||
@ -1107,8 +1106,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
|
|||||||
caps->host.numaCell) < 0)
|
caps->host.numaCell) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (virCapabilitiesFormatCaches(&buf, caps->host.ncaches,
|
if (virCapabilitiesFormatCaches(&buf, &caps->host.cache) < 0)
|
||||||
caps->host.caches) < 0)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (virCapabilitiesFormatMemoryBandwidth(&buf, caps->host.nnodes,
|
if (virCapabilitiesFormatMemoryBandwidth(&buf, caps->host.nnodes,
|
||||||
@ -1664,8 +1662,8 @@ virCapabilitiesInitResctrlMemory(virCapsPtr caps)
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
for (i = 0; i < caps->host.ncaches; i++) {
|
for (i = 0; i < caps->host.cache.nbanks; i++) {
|
||||||
virCapsHostCacheBankPtr bank = caps->host.caches[i];
|
virCapsHostCacheBankPtr bank = caps->host.cache.banks[i];
|
||||||
if (VIR_ALLOC(node) < 0)
|
if (VIR_ALLOC(node) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -1787,11 +1785,11 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
bank->type = kernel_type;
|
bank->type = kernel_type;
|
||||||
VIR_FREE(type);
|
VIR_FREE(type);
|
||||||
|
|
||||||
for (i = 0; i < caps->host.ncaches; i++) {
|
for (i = 0; i < caps->host.cache.nbanks; i++) {
|
||||||
if (virCapsHostCacheBankEquals(bank, caps->host.caches[i]))
|
if (virCapsHostCacheBankEquals(bank, caps->host.cache.banks[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == caps->host.ncaches) {
|
if (i == caps->host.cache.nbanks) {
|
||||||
/* If it is a new cache, then update its resctrl information. */
|
/* If it is a new cache, then update its resctrl information. */
|
||||||
if (virResctrlInfoGetCache(caps->host.resctrl,
|
if (virResctrlInfoGetCache(caps->host.resctrl,
|
||||||
bank->level,
|
bank->level,
|
||||||
@ -1800,8 +1798,8 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
&bank->controls) < 0)
|
&bank->controls) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_APPEND_ELEMENT(caps->host.caches,
|
if (VIR_APPEND_ELEMENT(caps->host.cache.banks,
|
||||||
caps->host.ncaches,
|
caps->host.cache.nbanks,
|
||||||
bank) < 0) {
|
bank) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1817,8 +1815,8 @@ virCapabilitiesInitCaches(virCapsPtr caps)
|
|||||||
/* Sort the array in order for the tests to be predictable. This way we can
|
/* Sort the array in order for the tests to be predictable. This way we can
|
||||||
* still traverse the directory instead of guessing names (in case there is
|
* still traverse the directory instead of guessing names (in case there is
|
||||||
* 'index1' and 'index3' but no 'index2'). */
|
* 'index1' and 'index3' but no 'index2'). */
|
||||||
qsort(caps->host.caches, caps->host.ncaches,
|
qsort(caps->host.cache.banks, caps->host.cache.nbanks,
|
||||||
sizeof(*caps->host.caches), virCapsHostCacheBankSorter);
|
sizeof(*caps->host.cache.banks), virCapsHostCacheBankSorter);
|
||||||
|
|
||||||
if (virCapabilitiesInitResctrlMemory(caps) < 0)
|
if (virCapabilitiesInitResctrlMemory(caps) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -151,6 +151,13 @@ struct _virCapsHostCacheBank {
|
|||||||
virResctrlInfoPerCachePtr *controls;
|
virResctrlInfoPerCachePtr *controls;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _virCapsHostCache virCapsHostCache;
|
||||||
|
typedef virCapsHostCache *virCapsHostCachePtr;
|
||||||
|
struct _virCapsHostCache {
|
||||||
|
size_t nbanks;
|
||||||
|
virCapsHostCacheBankPtr *banks;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _virCapsHostMemBWNode virCapsHostMemBWNode;
|
typedef struct _virCapsHostMemBWNode virCapsHostMemBWNode;
|
||||||
typedef virCapsHostMemBWNode *virCapsHostMemBWNodePtr;
|
typedef virCapsHostMemBWNode *virCapsHostMemBWNodePtr;
|
||||||
struct _virCapsHostMemBWNode {
|
struct _virCapsHostMemBWNode {
|
||||||
@ -180,8 +187,7 @@ struct _virCapsHost {
|
|||||||
|
|
||||||
virResctrlInfoPtr resctrl;
|
virResctrlInfoPtr resctrl;
|
||||||
|
|
||||||
size_t ncaches;
|
virCapsHostCache cache;
|
||||||
virCapsHostCacheBankPtr *caches;
|
|
||||||
|
|
||||||
size_t nnodes;
|
size_t nnodes;
|
||||||
virCapsHostMemBWNodePtr *nodes;
|
virCapsHostMemBWNodePtr *nodes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user