diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index e5cbfa362e..071090c2d9 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -273,9 +273,14 @@ - + + + + + + diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 3becc7e18c..0f99f30962 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -31,6 +31,7 @@ #include #include "capabilities.h" +#include "c-ctype.h" #include "count-one-bits.h" #include "cpu_conf.h" #include "domain_conf.h" @@ -906,11 +907,24 @@ virCapabilitiesFormatCaches(virBufferPtr buf, virBufferAdjustIndent(&controlBuf, indent + 4); for (j = 0; j < bank->ncontrols; j++) { - bool min_kilos = !(bank->controls[j]->min % 1024); + bool min_kilos = !(bank->controls[j]->granularity % 1024); + + /* Only use KiB if both values are divisible */ + if (bank->controls[j]->min) + min_kilos = min_kilos && !(bank->controls[j]->min % 1024); + virBufferAsprintf(&controlBuf, - "\n", - bank->controls[j]->min >> (min_kilos * 10), + "controls[j]->granularity >> (min_kilos * 10)); + + if (bank->controls[j]->min) { + virBufferAsprintf(&controlBuf, + " min='%llu'", + bank->controls[j]->min >> (min_kilos * 10)); + } + + virBufferAsprintf(&controlBuf, + " unit='%s' type='%s' maxAllocs='%u'/>\n", min_kilos ? "KiB" : "B", virCacheTypeToString(bank->controls[j]->scope), bank->controls[j]->max_allocation); @@ -1598,9 +1612,11 @@ virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank, virCacheType scope) { int ret = -1; + char *tmp = NULL; char *path = NULL; char *cbm_mask = NULL; char *type_upper = NULL; + unsigned int bits = 0; unsigned int min_cbm_bits = 0; virCapsHostCacheControlPtr control; @@ -1632,8 +1648,14 @@ virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank, virStringTrimOptionalNewline(cbm_mask); - /* cbm_mask: cache bit mask, it's in hex, eg: fffff */ - control->min = min_cbm_bits * bank->size / (strlen(cbm_mask) * 4); + for (tmp = cbm_mask; *tmp != '\0'; tmp++) { + if (c_isxdigit(*tmp)) + bits += count_one_bits(virHexToBin(*tmp)); + } + + control->granularity = bank->size / bits; + if (min_cbm_bits != 1) + control->min = min_cbm_bits * control->granularity; control->scope = scope; diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index ee87d598ef..39a9bc6892 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -151,9 +151,14 @@ VIR_ENUM_DECL(virCache); typedef struct _virCapsHostCacheControl virCapsHostCacheControl; typedef virCapsHostCacheControl *virCapsHostCacheControlPtr; struct _virCapsHostCacheControl { - unsigned long long min; /* minimum cache control size in B */ - virCacheType scope; /* data, code or both */ - unsigned int max_allocation; /* max number of supported allocations */ + /* Smallest possible increase of the allocation size in bytes */ + unsigned long long granularity; + /* Minimal allocatable size in bytes (if different from granularity) */ + unsigned long long min; + /* Type of the allocation */ + virCacheType scope; + /* Maximum number of simultaneous allocations */ + unsigned int max_allocation; }; typedef struct _virCapsHostCacheBank virCapsHostCacheBank; diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask new file mode 100644 index 0000000000..d482bbb269 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask @@ -0,0 +1 @@ +7ff diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids new file mode 100644 index 0000000000..b6a7d89c68 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids @@ -0,0 +1 @@ +16 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata new file mode 100644 index 0000000000..4a49137353 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata @@ -0,0 +1 @@ +L3:0=7ff;1=7ff diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level new file mode 100644 index 0000000000..00750edc07 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map new file mode 100644 index 0000000000..5325a8dff7 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map @@ -0,0 +1 @@ +001 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size new file mode 100644 index 0000000000..d23da60c12 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size @@ -0,0 +1 @@ +33M diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type new file mode 100644 index 0000000000..e4fd9dccda --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type @@ -0,0 +1 @@ +Unified diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings new file mode 100644 index 0000000000..5325a8dff7 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings @@ -0,0 +1 @@ +001 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings new file mode 100644 index 0000000000..5325a8dff7 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings @@ -0,0 +1 @@ +001 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0 b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0 new file mode 120000 index 0000000000..c841bea28b --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0 @@ -0,0 +1 @@ +../../cpu/cpu0 \ No newline at end of file diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap new file mode 100644 index 0000000000..5325a8dff7 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap @@ -0,0 +1 @@ +001 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance @@ -0,0 +1 @@ +10 diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/online b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/online new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/online @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml index 49aa0b98ca..7361537bfb 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml @@ -42,12 +42,12 @@ - - + + - - + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml new file mode 100644 index 0000000000..4e91c87de3 --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml @@ -0,0 +1,31 @@ + + + + + x86_64 + + + + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml index cb78b4ab78..eb02ad3322 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml @@ -42,10 +42,10 @@ - + - + diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index ae1cd52111..c0a67858fe 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -120,6 +120,7 @@ mymain(void) DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true, true); DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true, true); + DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true, true); return ret; }