[libvirt] [PATCH 00/16] Expose host cache information in capabilities

I think thanks to previous patches regarding sysfs, this should be very easy to review. The XML snippet that shows how the capablity XML looks like can be seen in the second to last patch which adds test for it. Again, first few patches are trivial because I couldn't be bothered to split the branch in two and writing two cover letters and moreover those are patches for trivialities I stumbled upon during the work on this series. Also, this series is based upon Peter's news.xml validation against RNG schema: https://www.redhat.com/archives/libvir-list/2017-March/msg01478.html Previous discussion threads on the XML design and patches touching this topic can be found here (not meant to be a complete list): https://www.redhat.com/archives/libvir-list/2017-January/msg00354.html https://www.redhat.com/archives/libvir-list/2017-January/msg00512.html https://www.redhat.com/archives/libvir-list/2017-January/msg00633.html https://www.redhat.com/archives/libvir-list/2017-February/msg00777.html https://www.redhat.com/archives/libvir-list/2017-March/msg00197.html Martin Kletzander (16): conf: Fix possible memleak in capabilities util: Fix virDirRead() description virsysfs: Add comments to separate logical blocks of functions util: Add virStringTrimOptionalNewline util: Add virFileReadValueScaledInt util: Add virSysfsDirOpen util: Add virSysfsCpuDirOpen util: Use virStringTrimOptionalNewline in virFileRead* util: Unify behaviour of the functions in sysfs.c util: Add virSysfsGetCPUCache* functions tests: Test capability XMLs in vircaps2xmldata Add RNG schema for host cache information in capabilities Add host cache information into capabilities tests: Add missing cache data for vircaps2xmltest tests: Add tests for caches into vircaps2xmltest Init host cache info in drivers docs/schemas/capability.rng | 34 +++++ src/conf/capabilities.c | 162 ++++++++++++++++++++- src/conf/capabilities.h | 29 ++++ src/libvirt_private.syms | 9 ++ src/lxc/lxc_conf.c | 3 + src/openvz/openvz_conf.c | 3 + src/phyp/phyp_driver.c | 3 + src/qemu/qemu_capabilities.c | 3 + src/uml/uml_conf.c | 3 + src/util/virfile.c | 50 +++++-- src/util/virfile.h | 1 + src/util/virhostcpu.c | 4 +- src/util/virstring.h | 8 + src/util/virsysfs.c | 162 +++++++++++++++++++-- src/util/virsysfs.h | 56 +++++++ src/vbox/vbox_common.c | 3 + src/vmware/vmware_conf.c | 3 + src/vz/vz_driver.c | 2 + .../linux-caches/cpu/cpu0/cache/index0/id | 1 + .../cpu/cpu0/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu0/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu0/cache/index1/id | 1 + .../cpu/cpu0/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu0/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu0/cache/index2/id | 1 + .../cpu/cpu0/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu0/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu0/cache/index3/id | 1 + .../linux-caches/cpu/cpu1/cache/index0/id | 1 + .../cpu/cpu1/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu1/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu1/cache/index1/id | 1 + .../cpu/cpu1/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu1/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu1/cache/index2/id | 1 + .../cpu/cpu1/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu1/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu1/cache/index3/id | 1 + .../linux-caches/cpu/cpu2/cache/index0/id | 1 + .../cpu/cpu2/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu2/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu2/cache/index1/id | 1 + .../cpu/cpu2/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu2/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu2/cache/index2/id | 1 + .../cpu/cpu2/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu2/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu2/cache/index3/id | 1 + .../linux-caches/cpu/cpu3/cache/index0/id | 1 + .../cpu/cpu3/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu3/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu3/cache/index1/id | 1 + .../cpu/cpu3/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu3/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu3/cache/index2/id | 1 + .../cpu/cpu3/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu3/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu3/cache/index3/id | 1 + .../linux-caches/cpu/cpu4/cache/index0/id | 1 + .../cpu/cpu4/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu4/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu4/cache/index1/id | 1 + .../cpu/cpu4/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu4/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu4/cache/index2/id | 1 + .../cpu/cpu4/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu4/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu4/cache/index3/id | 1 + .../linux-caches/cpu/cpu5/cache/index0/id | 1 + .../cpu/cpu5/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu5/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu5/cache/index1/id | 1 + .../cpu/cpu5/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu5/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu5/cache/index2/id | 1 + .../cpu/cpu5/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu5/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu5/cache/index3/id | 1 + .../linux-caches/cpu/cpu6/cache/index0/id | 1 + .../cpu/cpu6/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu6/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu6/cache/index1/id | 1 + .../cpu/cpu6/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu6/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu6/cache/index2/id | 1 + .../cpu/cpu6/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu6/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu6/cache/index3/id | 1 + .../linux-caches/cpu/cpu7/cache/index0/id | 1 + .../cpu/cpu7/cache/index0/shared_cpu_list | 2 +- .../cpu/cpu7/cache/index0/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu7/cache/index1/id | 1 + .../cpu/cpu7/cache/index1/shared_cpu_list | 2 +- .../cpu/cpu7/cache/index1/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu7/cache/index2/id | 1 + .../cpu/cpu7/cache/index2/shared_cpu_list | 2 +- .../cpu/cpu7/cache/index2/shared_cpu_map | 2 +- .../linux-caches/cpu/cpu7/cache/index3/id | 1 + tests/vircaps2xmldata/vircaps-x86_64-caches.xml | 15 ++ tests/vircaps2xmltest.c | 3 +- tests/virschematest.c | 3 +- 101 files changed, 608 insertions(+), 79 deletions(-) create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id -- 2.12.2

If formatting NUMA topology fails, the function returns immediatelly, but the buffer structure allocated on the stack references lot of heap-allocated memory and that would get lost in such case. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/conf/capabilities.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 08907aced1b9..be95c50cfb67 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -955,7 +955,7 @@ virCapabilitiesFormatXML(virCapsPtr caps) if (caps->host.nnumaCell && virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell, caps->host.numaCell) < 0) - return NULL; + goto error; for (i = 0; i < caps->host.nsecModels; i++) { virBufferAddLit(&buf, "<secmodel>\n"); @@ -1072,6 +1072,10 @@ virCapabilitiesFormatXML(virCapsPtr caps) return NULL; return virBufferContentAndReset(&buf); + + error: + virBufferFreeAndReset(&buf); + return NULL; } /* get the maximum ID of cpus in the host */ -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index a91c2c349501..c0f448d3437d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2861,11 +2861,11 @@ virDirOpenQuiet(DIR **dirp, const char *name) /** * virDirRead: * @dirp: directory to read - * @end: output one entry + * @ent: output one entry * @name: if non-NULL, the name related to @dirp for use in error reporting * * Wrapper around readdir. Typical usage: - * struct dirent ent; + * struct dirent *ent; * int rc; * DIR *dir; * if (virDirOpen(&dir, name) < 0) -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virsysfs.c | 15 +++++++++++++-- src/util/virsysfs.h | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 7a98b488e0ff..c482e188a301 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -40,6 +40,9 @@ VIR_LOG_INIT("util.sysfs"); static const char *sysfs_system_path = SYSFS_SYSTEM_PATH; +/* + * Private function that should only be called from tests + */ void virSysfsSetSystemPath(const char *path) { if (path) @@ -49,6 +52,9 @@ void virSysfsSetSystemPath(const char *path) } +/* + * Generic getters + */ const char * virSysfsGetSystemPath(void) { @@ -110,6 +116,9 @@ virSysfsGetValueBitmap(const char *file, return ret; } +/* + * Per-CPU getters + */ int virSysfsGetCpuValueInt(unsigned int cpu, const char *file, @@ -127,7 +136,6 @@ virSysfsGetCpuValueInt(unsigned int cpu, return ret; } - int virSysfsGetCpuValueUint(unsigned int cpu, const char *file, @@ -145,7 +153,6 @@ virSysfsGetCpuValueUint(unsigned int cpu, return ret; } - int virSysfsGetCpuValueString(unsigned int cpu, const char *file, @@ -187,6 +194,10 @@ virSysfsGetCpuValueBitmap(unsigned int cpu, return ret; } + +/* + * Per-NUMA node getters + */ int virSysfsGetNodeValueString(unsigned int node, const char *file, diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index cd871ff11dd1..1b24fc193a16 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -24,6 +24,9 @@ # include "internal.h" # include "virbitmap.h" +/* + * Generic getters + */ const char * virSysfsGetSystemPath(void); int @@ -38,6 +41,10 @@ int virSysfsGetValueBitmap(const char *file, virBitmapPtr *value); + +/* + * Per-CPU getters + */ int virSysfsGetCpuValueInt(unsigned int cpu, const char *file, @@ -57,6 +64,10 @@ virSysfsGetCpuValueBitmap(unsigned int cpu, const char *file, virBitmapPtr *value); + +/* + * Per-NUMA node getters + */ int virSysfsGetNodeValueString(unsigned int node, const char *file, -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virstring.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/virstring.h b/src/util/virstring.h index a5550e30d2e2..603650aa1588 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -288,4 +288,12 @@ bool virStringBufferIsPrintable(const uint8_t *buf, size_t buflen); char *virStringEncodeBase64(const uint8_t *buf, size_t buflen); +static inline void +virStringTrimOptionalNewline(char *str) +{ + char *tmp = str + strlen(str) - 1; + if (*tmp == '\n') + *tmp = '\0'; +} + #endif /* __VIR_STRING_H__ */ -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virfile.c | 28 ++++++++++++++++++++++++++++ src/util/virfile.h | 1 + 3 files changed, 30 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b551cb86a68e..9e61accda3fc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1631,6 +1631,7 @@ virFileReadLimFD; virFileReadLink; virFileReadValueBitmap; virFileReadValueInt; +virFileReadValueScaledInt; virFileReadValueUint; virFileRelLinkPointsTo; virFileRemove; diff --git a/src/util/virfile.c b/src/util/virfile.c index c0f448d3437d..93fc81f2cfab 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3880,6 +3880,34 @@ virFileReadValueUint(const char *path, unsigned int *value) * fine. */ int +virFileReadValueScaledInt(const char *path, unsigned long long *value) +{ + char *str = NULL; + char *endp = NULL; + int ret = -1; + + if (!virFileExists(path)) + return -2; + + if (virFileReadAll(path, INT_STRLEN_BOUND(*value), &str) < 0) + return -1; + + virStringTrimOptionalNewline(str); + + if (virStrToLong_ullp(str, &endp, 10, value) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid unsigned scaled integer value '%s' in file '%s'"), + str, path); + goto cleanup; + } + + ret = virScaleInteger(value, endp, 1024, ULLONG_MAX); + cleanup: + VIR_FREE(str); + return ret; +} + +int virFileReadValueBitmap(const char *path, int maxlen, virBitmapPtr *value) diff --git a/src/util/virfile.h b/src/util/virfile.h index ba1c57c06a8e..406569bdb7e9 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -338,6 +338,7 @@ int virFileComparePaths(const char *p1, const char *p2); int virFileReadValueInt(const char *path, int *value); int virFileReadValueUint(const char *path, unsigned int *value); +int virFileReadValueScaledInt(const char *path, unsigned long long *value); int virFileReadValueBitmap(const char *path, int maxlen, virBitmapPtr *value); #endif /* __VIR_FILE_H */ -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virsysfs.c | 17 ++++++++++++++++- src/util/virsysfs.h | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9e61accda3fc..3965ef3f89c9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2621,6 +2621,7 @@ virVasprintfInternal; # util/virsysfs.h +virSysfsDirOpen; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index c482e188a301..6686d8ddbfcb 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -25,7 +25,6 @@ #include "virsysfspriv.h" #include "viralloc.h" -#include "virfile.h" #include "virlog.h" #include "virstring.h" @@ -120,6 +119,22 @@ virSysfsGetValueBitmap(const char *file, * Per-CPU getters */ int +virSysfsDirOpen(const char *file, + DIR **dirp) +{ + char *path = NULL; + + if (virAsprintf(&path, "%s/%s", sysfs_system_path, file) < 0) + return -1; + + if (!virFileIsDir(path)) + return -2; + + return virDirOpen(dirp, path); +} + + +int virSysfsGetCpuValueInt(unsigned int cpu, const char *file, int *value) diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index 1b24fc193a16..ff5012d62747 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -23,6 +23,8 @@ # include "internal.h" # include "virbitmap.h" +# include "virfile.h" + /* * Generic getters @@ -41,6 +43,10 @@ int virSysfsGetValueBitmap(const char *file, virBitmapPtr *value); +int +virSysfsDirOpen(const char *file, + DIR **dirp); + /* * Per-CPU getters -- 2.12.2

On Thursday, 30 March 2017 at 10:03 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com (mailto:mkletzan@redhat.com)> --- src/libvirt_private.syms | 1 + src/util/virsysfs.c | 17 ++++++++++++++++- src/util/virsysfs.h | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9e61accda3fc..3965ef3f89c9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2621,6 +2621,7 @@ virVasprintfInternal;
# util/virsysfs.h +virSysfsDirOpen; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index c482e188a301..6686d8ddbfcb 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -25,7 +25,6 @@ #include "virsysfspriv.h"
#include "viralloc.h" -#include "virfile.h" #include "virlog.h" #include "virstring.h"
@@ -120,6 +119,22 @@ virSysfsGetValueBitmap(const char *file, * Per-CPU getters */ int +virSysfsDirOpen(const char *file, + DIR **dirp) +{ + char *path = NULL; + + if (virAsprintf(&path, "%s/%s", sysfs_system_path, file) < 0) + return -1; + + if (!virFileIsDir(path)) + return -2; + + return virDirOpen(dirp, path); +} +
what if I need another util function like: virSysfsDirResctrlOpen(const char *file, DIR **dirp) do another copy and just modify path as: if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0) is that okay for you to duplicated code like this? This is not so common a way to adding utils functions. If I need another `sysfs_system_path`, for /sys/fs/resctrl I need to add a new variable sysfs_resctrl_path, then do a copy of this function with some modification. Eli.
+ DIR **dirp)
+ +int virSysfsGetCpuValueInt(unsigned int cpu, const char *file, int *value) diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index 1b24fc193a16..ff5012d62747 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -23,6 +23,8 @@
# include "internal.h" # include "virbitmap.h" +# include "virfile.h" +
/* * Generic getters @@ -41,6 +43,10 @@ int virSysfsGetValueBitmap(const char *file, virBitmapPtr *value);
+int +virSysfsDirOpen(const char *file, + DIR **dirp); +
/* * Per-CPU getters -- 2.12.2
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Mar 31, 2017 at 09:32:06AM +0800, Eli Qiao wrote:
On Thursday, 30 March 2017 at 10:03 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com (mailto:mkletzan@redhat.com)> --- src/libvirt_private.syms | 1 + src/util/virsysfs.c | 17 ++++++++++++++++- src/util/virsysfs.h | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9e61accda3fc..3965ef3f89c9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2621,6 +2621,7 @@ virVasprintfInternal;
# util/virsysfs.h +virSysfsDirOpen; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index c482e188a301..6686d8ddbfcb 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -25,7 +25,6 @@ #include "virsysfspriv.h"
#include "viralloc.h" -#include "virfile.h" #include "virlog.h" #include "virstring.h"
@@ -120,6 +119,22 @@ virSysfsGetValueBitmap(const char *file, * Per-CPU getters */ int +virSysfsDirOpen(const char *file, + DIR **dirp) +{ + char *path = NULL; + + if (virAsprintf(&path, "%s/%s", sysfs_system_path, file) < 0) + return -1; + + if (!virFileIsDir(path)) + return -2; + + return virDirOpen(dirp, path); +} +
what if I need another util function like: virSysfsDirResctrlOpen(const char *file, DIR **dirp)
do another copy and just modify path as:
if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0)
is that okay for you to duplicated code like this?
This is not so common a way to adding utils functions.
If I need another `sysfs_system_path`, for /sys/fs/resctrl I need to add a new variable sysfs_resctrl_path, then do a copy of this function with some modification.
Yeah, well, it's not nice to duplicate that much stuff. But for now I can't think of any better way. Anyway, Erik started the discussion in another thread, so we can think of something there. Do you have a better idea? Martin

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virsysfs.c | 14 ++++++++++++++ src/util/virsysfs.h | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3965ef3f89c9..bcd2506ef7c9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2621,6 +2621,7 @@ virVasprintfInternal; # util/virsysfs.h +virSysfsCpuDirOpen; virSysfsDirOpen; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 6686d8ddbfcb..7403ae20ba17 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -214,6 +214,20 @@ virSysfsGetCpuValueBitmap(unsigned int cpu, * Per-NUMA node getters */ int +virSysfsCpuDirOpen(unsigned int cpu, + const char *file, + DIR **dirp) +{ + char *path = NULL; + + if (virAsprintf(&path, "cpu/cpu%u/%s", cpu, file) < 0) + return -1; + + return virSysfsDirOpen(path, dirp); +} + + +int virSysfsGetNodeValueString(unsigned int node, const char *file, char **value) diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index ff5012d62747..25bd100ea9cb 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -70,6 +70,11 @@ virSysfsGetCpuValueBitmap(unsigned int cpu, const char *file, virBitmapPtr *value); +int +virSysfsCpuDirOpen(unsigned int cpu, + const char *file, + DIR **dirp); + /* * Per-NUMA node getters -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virfile.c | 18 +++++++----------- src/util/virhostcpu.c | 4 ++-- src/util/virsysfs.c | 2 ++ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 93fc81f2cfab..001ea9b37b2d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3811,7 +3811,6 @@ int virFileReadValueInt(const char *path, int *value) { char *str = NULL; - char *endp = NULL; if (!virFileExists(path)) return -2; @@ -3819,8 +3818,9 @@ virFileReadValueInt(const char *path, int *value) if (virFileReadAll(path, INT_STRLEN_BOUND(*value), &str) < 0) return -1; - if (virStrToLong_i(str, &endp, 10, value) < 0 || - (endp && !c_isspace(*endp))) { + virStringTrimOptionalNewline(str); + + if (virStrToLong_i(str, NULL, 10, value) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid integer value '%s' in file '%s'"), str, path); @@ -3847,7 +3847,6 @@ int virFileReadValueUint(const char *path, unsigned int *value) { char *str = NULL; - char *endp = NULL; if (!virFileExists(path)) return -2; @@ -3855,8 +3854,9 @@ virFileReadValueUint(const char *path, unsigned int *value) if (virFileReadAll(path, INT_STRLEN_BOUND(*value), &str) < 0) return -1; - if (virStrToLong_uip(str, &endp, 10, value) < 0 || - (endp && !c_isspace(*endp))) { + virStringTrimOptionalNewline(str); + + if (virStrToLong_uip(str, NULL, 10, value)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid unsigned integer value '%s' in file '%s'"), str, path); @@ -3914,7 +3914,6 @@ virFileReadValueBitmap(const char *path, { char *buf = NULL; int ret = -1; - char *tmp = NULL; if (!virFileExists(path)) return -2; @@ -3922,10 +3921,7 @@ virFileReadValueBitmap(const char *path, if (virFileReadAll(path, maxlen, &buf) < 0) goto cleanup; - /* trim optinoal newline at the end */ - tmp = buf + strlen(buf) - 1; - if (*tmp == '\n') - *tmp = '\0'; + virStringTrimOptionalNewline(buf); *value = virBitmapParseUnlimited(buf); if (!*value) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 02b9fc8eb94f..a660e3f4dbe5 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -847,13 +847,13 @@ virHostCPUParseCountLinux(void) tmp = str; do { if (virStrToLong_i(tmp, &tmp, 10, &ret) < 0 || - !strchr(",-\n", *tmp)) { + !strchr(",-", *tmp)) { virReportError(VIR_ERR_NO_SUPPORT, _("failed to parse %s"), str); ret = -1; goto cleanup; } - } while (*tmp++ != '\n'); + } while (*tmp++ && *tmp); ret++; cleanup: diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 7403ae20ba17..8d3665377e8c 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -94,6 +94,8 @@ virSysfsGetValueString(const char *file, if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0) goto cleanup; + virStringTrimOptionalNewline(*value); + ret = 0; cleanup: VIR_FREE(path); -- 2.12.2

Make virSysfsGet*ValueString() functions use virSysfsGetValueString() then we have one more allocation, but the code is cleaner and it's easier to make sure the behaviour (e.g. return -2 on missing file) isn't changed by mistake. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virsysfs.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 8d3665377e8c..a8550bbfbc26 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -178,19 +178,11 @@ virSysfsGetCpuValueString(unsigned int cpu, char *path = NULL; int ret = -1; - if (virAsprintf(&path, "%s/cpu/cpu%u/%s", sysfs_system_path, cpu, file) < 0) + if (virAsprintf(&path, "cpu/cpu%u/%s", cpu, file) < 0) return -1; - if (!virFileExists(path)) { - ret = -2; - goto cleanup; - } + ret = virSysfsGetValueString(path, value); - if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0) - goto cleanup; - - ret = 0; - cleanup: VIR_FREE(path); return ret; } -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/libvirt_private.syms | 5 +++ src/util/virsysfs.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virsysfs.h | 34 ++++++++++++++++ 3 files changed, 141 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bcd2506ef7c9..0b3b41516fe6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2623,6 +2623,11 @@ virVasprintfInternal; # util/virsysfs.h virSysfsCpuDirOpen; virSysfsDirOpen; +virSysfsGetCpuCacheValueBitmap; +virSysfsGetCpuCacheValueInt; +virSysfsGetCpuCacheValueScaledInt; +virSysfsGetCpuCacheValueString; +virSysfsGetCpuCacheValueUint; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index a8550bbfbc26..2a64be4f5f73 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -221,6 +221,108 @@ virSysfsCpuDirOpen(unsigned int cpu, } +/* + * Per-CPU/cache getters + */ +int +virSysfsGetCpuCacheValueInt(unsigned int cpu, + const char *cache, + const char *file, + int *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueInt(path, value); + + VIR_FREE(path); + return ret; +} + + +int +virSysfsGetCpuCacheValueUint(unsigned int cpu, + const char *cache, + const char *file, + unsigned int *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueUint(path, value); + + VIR_FREE(path); + return ret; +} + +int +virSysfsGetCpuCacheValueScaledInt(unsigned int cpu, + const char *cache, + const char *file, + unsigned long long *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueScaledInt(path, value); + + VIR_FREE(path); + return ret; +} + + +int +virSysfsGetCpuCacheValueString(unsigned int cpu, + const char *cache, + const char *file, + char **value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "cpu/cpu%u/cache/%s/%s", cpu, cache, file) < 0) + return -1; + + ret = virSysfsGetValueString(path, value); + + VIR_FREE(path); + return ret; +} + +int +virSysfsGetCpuCacheValueBitmap(unsigned int cpu, + const char *cache, + const char *file, + virBitmapPtr *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueBitmap(path, VIR_SYSFS_VALUE_MAXLEN, value); + VIR_FREE(path); + return ret; +} + + +/* + * Per-NUMA node getters + */ int virSysfsGetNodeValueString(unsigned int node, const char *file, diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index 25bd100ea9cb..92f9111b069f 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -77,6 +77,40 @@ virSysfsCpuDirOpen(unsigned int cpu, /* + * Per-CPU/cache getters + */ +int +virSysfsGetCpuCacheValueInt(unsigned int cpu, + const char *cache, + const char *file, + int *value); + +int +virSysfsGetCpuCacheValueUint(unsigned int cpu, + const char *cache, + const char *file, + unsigned int *value); + +int +virSysfsGetCpuCacheValueScaledInt(unsigned int cpu, + const char *cache, + const char *file, + unsigned long long *value); + +int +virSysfsGetCpuCacheValueString(unsigned int cpu, + const char *cache, + const char *file, + char **value); + +int +virSysfsGetCpuCacheValueBitmap(unsigned int cpu, + const char *cache, + const char *file, + virBitmapPtr *value); + + +/* * Per-NUMA node getters */ int -- 2.12.2

On Thursday, 30 March 2017 at 10:03 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com (mailto:mkletzan@redhat.com)> --- src/libvirt_private.syms | 5 +++ src/util/virsysfs.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virsysfs.h | 34 ++++++++++++++++ 3 files changed, 141 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bcd2506ef7c9..0b3b41516fe6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2623,6 +2623,11 @@ virVasprintfInternal; # util/virsysfs.h virSysfsCpuDirOpen; virSysfsDirOpen; +virSysfsGetCpuCacheValueBitmap; +virSysfsGetCpuCacheValueInt; +virSysfsGetCpuCacheValueScaledInt; +virSysfsGetCpuCacheValueString; +virSysfsGetCpuCacheValueUint; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index a8550bbfbc26..2a64be4f5f73 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -221,6 +221,108 @@ virSysfsCpuDirOpen(unsigned int cpu, }
+/* + * Per-CPU/cache getters + */ +int +virSysfsGetCpuCacheValueInt(unsigned int cpu, + const char *cache, + const char *file, + int *value)
It will be helpful that we describe what cache, file looks like even it’s straight enough to reading code.
+{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s",
cpu/cpu0/cache/index3/size
+ sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueInt(path, value); + + VIR_FREE(path); + return ret; +} + + +int +virSysfsGetCpuCacheValueUint(unsigned int cpu, + const char *cache, + const char *file, + unsigned int *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueUint(path, value); + + VIR_FREE(path); + return ret; +} + +int +virSysfsGetCpuCacheValueScaledInt(unsigned int cpu, + const char *cache, + const char *file, + unsigned long long *value)
Can we add notes here to tell the value is in unite KiB ?
+{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueScaledInt(path, value); + + VIR_FREE(path); + return ret; +} + + +int +virSysfsGetCpuCacheValueString(unsigned int cpu, + const char *cache, + const char *file, + char **value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "cpu/cpu%u/cache/%s/%s", cpu, cache, file) < 0) + return -1; + + ret = virSysfsGetValueString(path, value); + + VIR_FREE(path); + return ret; +} + +int +virSysfsGetCpuCacheValueBitmap(unsigned int cpu, + const char *cache, + const char *file, + virBitmapPtr *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueBitmap(path, VIR_SYSFS_VALUE_MAXLEN, value); + VIR_FREE(path); + return ret; +} + + +/* + * Per-NUMA node getters + */ int virSysfsGetNodeValueString(unsigned int node, const char *file, diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index 25bd100ea9cb..92f9111b069f 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -77,6 +77,40 @@ virSysfsCpuDirOpen(unsigned int cpu,
/* + * Per-CPU/cache getters + */ +int +virSysfsGetCpuCacheValueInt(unsigned int cpu, + const char *cache, + const char *file, + int *value); + +int +virSysfsGetCpuCacheValueUint(unsigned int cpu, + const char *cache, + const char *file, + unsigned int *value); + +int +virSysfsGetCpuCacheValueScaledInt(unsigned int cpu, + const char *cache, + const char *file, + unsigned long long *value); + +int +virSysfsGetCpuCacheValueString(unsigned int cpu, + const char *cache, + const char *file, + char **value); + +int +virSysfsGetCpuCacheValueBitmap(unsigned int cpu, + const char *cache, + const char *file, + virBitmapPtr *value); + + +/* * Per-NUMA node getters */ int -- 2.12.2
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Mar 31, 2017 at 05:32:16PM +0800, Eli Qiao wrote:
On Thursday, 30 March 2017 at 10:03 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com (mailto:mkletzan@redhat.com)> --- src/libvirt_private.syms | 5 +++ src/util/virsysfs.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virsysfs.h | 34 ++++++++++++++++ 3 files changed, 141 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bcd2506ef7c9..0b3b41516fe6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2623,6 +2623,11 @@ virVasprintfInternal; # util/virsysfs.h virSysfsCpuDirOpen; virSysfsDirOpen; +virSysfsGetCpuCacheValueBitmap; +virSysfsGetCpuCacheValueInt; +virSysfsGetCpuCacheValueScaledInt; +virSysfsGetCpuCacheValueString; +virSysfsGetCpuCacheValueUint; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index a8550bbfbc26..2a64be4f5f73 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -221,6 +221,108 @@ virSysfsCpuDirOpen(unsigned int cpu, }
+/* + * Per-CPU/cache getters + */ +int +virSysfsGetCpuCacheValueInt(unsigned int cpu, + const char *cache, + const char *file, + int *value)
It will be helpful that we describe what cache, file looks like even it’s straight enough to reading code.
What do you mean? The files look just like they look in the system. It's a copy of what actually is under /sys/devices/system. The description is in the kernel.
+{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s",
cpu/cpu0/cache/index3/size
???
+ sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueInt(path, value); + + VIR_FREE(path); + return ret; +} + + +int +virSysfsGetCpuCacheValueUint(unsigned int cpu, + const char *cache, + const char *file, + unsigned int *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueUint(path, value); + + VIR_FREE(path); + return ret; +} + +int +virSysfsGetCpuCacheValueScaledInt(unsigned int cpu, + const char *cache, + const char *file, + unsigned long long *value)
Can we add notes here to tell the value is in unite KiB ?
Well what if you want to use this for another file in the future? This function will be able to read it even if the file has "1M" in it. Or did you mean something else?

On Friday, 31 March 2017 at 7:39 PM, Martin Kletzander wrote:
On Fri, Mar 31, 2017 at 05:32:16PM +0800, Eli Qiao wrote:
On Thursday, 30 March 2017 at 10:03 PM, Martin Kletzander wrote:
Signed-off-by: Martin Kletzander <mkletzan@redhat.com (mailto:mkletzan@redhat.com)> --- src/libvirt_private.syms | 5 +++ src/util/virsysfs.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virsysfs.h | 34 ++++++++++++++++ 3 files changed, 141 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bcd2506ef7c9..0b3b41516fe6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2623,6 +2623,11 @@ virVasprintfInternal; # util/virsysfs.h virSysfsCpuDirOpen; virSysfsDirOpen; +virSysfsGetCpuCacheValueBitmap; +virSysfsGetCpuCacheValueInt; +virSysfsGetCpuCacheValueScaledInt; +virSysfsGetCpuCacheValueString; +virSysfsGetCpuCacheValueUint; virSysfsGetCpuValueBitmap; virSysfsGetCpuValueInt; virSysfsGetCpuValueString; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index a8550bbfbc26..2a64be4f5f73 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -221,6 +221,108 @@ virSysfsCpuDirOpen(unsigned int cpu, }
+/* + * Per-CPU/cache getters + */ +int +virSysfsGetCpuCacheValueInt(unsigned int cpu, + const char *cache, + const char *file, + int *value)
It will be helpful that we describe what cache, file looks like even it’s straight enough to reading code.
What do you mean? The files look just like they look in the system. It's a copy of what actually is under /sys/devices/system. The description is in the kernel.
Okay, never mind.
+{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s",
cpu/cpu0/cache/index3/size
???
ignore this.
+ sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueInt(path, value); + + VIR_FREE(path); + return ret; +} + + +int +virSysfsGetCpuCacheValueUint(unsigned int cpu, + const char *cache, + const char *file, + unsigned int *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/cpu/cpu%u/cache/%s/%s", + sysfs_system_path, cpu, cache, file) < 0) + return -1; + + ret = virFileReadValueUint(path, value); + + VIR_FREE(path); + return ret; +} + +int +virSysfsGetCpuCacheValueScaledInt(unsigned int cpu, + const char *cache, + const char *file, + unsigned long long *value)
Can we add notes here to tell the value is in unite KiB ?
Well what if you want to use this for another file in the future? This function will be able to read it even if the file has "1M" in it. Or did you mean something else?
My mistake, it’s should B (not KiB), It’s okay.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/virschematest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virschematest.c b/tests/virschematest.c index 4f194804afb3..c98625d412e2 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -215,7 +215,8 @@ mymain(void) } \ } while (0) - DO_TEST_DIR("capability.rng", "capabilityschemadata", "xencapsdata"); + DO_TEST_DIR("capability.rng", "capabilityschemadata", "xencapsdata", + "vircaps2xmldata"); DO_TEST_DIR("domain.rng", "domainschemadata", "qemuargv2xmldata", "qemuxml2argvdata", "sexpr2xmldata", "xmconfigdata", "xml2sexprdata", "qemuxml2xmloutdata", "lxcxml2xmldata", -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/schemas/capability.rng | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index 88e08d299ac9..208095302a63 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -45,6 +45,9 @@ <optional> <ref name='topology'/> </optional> + <optional> + <ref name='cache'/> + </optional> <zeroOrMore> <ref name='secmodel'/> </zeroOrMore> @@ -248,6 +251,37 @@ </element> </define> + <define name='cache'> + <element name='cache'> + <oneOrMore> + <element name='bank'> + <attribute name='id'> + <ref name='unsignedInt'/> + </attribute> + <attribute name='level'> + <ref name='unsignedInt'/> + </attribute> + <attribute name='type'> + <choice> + <value>unified</value> + <value>instruction</value> + <value>data</value> + </choice> + </attribute> + <attribute name='size'> + <ref name='unsignedInt'/> + </attribute> + <attribute name='unit'> + <ref name='unit'/> + </attribute> + <attribute name='cpus'> + <ref name='cpuset'/> + </attribute> + </element> + </oneOrMore> + </element> + </define> + <define name='guestcaps'> <element name='guest'> <ref name='ostype'/> -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/conf/capabilities.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++ src/conf/capabilities.h | 29 +++++++++ src/libvirt_private.syms | 1 + 3 files changed, 186 insertions(+) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index be95c50cfb67..c07c64e7d73c 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -31,6 +31,7 @@ #include <unistd.h> #include "capabilities.h" +#include "c-ctype.h" #include "count-one-bits.h" #include "cpu_conf.h" #include "domain_conf.h" @@ -238,6 +239,10 @@ virCapabilitiesDispose(void *object) virCapabilitiesClearSecModel(&caps->host.secModels[i]); VIR_FREE(caps->host.secModels); + for (i = 0; i < caps->host.ncaches; i++) + virCapsHostCacheBankFree(caps->host.caches[i]); + VIR_FREE(caps->host.caches); + VIR_FREE(caps->host.netprefix); VIR_FREE(caps->host.pagesSize); virCPUDefFree(caps->host.cpu); @@ -861,6 +866,49 @@ virCapabilitiesFormatNUMATopology(virBufferPtr buf, return 0; } +static int +virCapabilitiesFormatCaches(virBufferPtr buf, + size_t ncaches, + virCapsHostCacheBankPtr *caches) +{ + size_t i = 0; + + if (!ncaches) + return 0; + + virBufferAddLit(buf, "<cache>\n"); + virBufferAdjustIndent(buf, 2); + + for (i = 0; i < ncaches; i++) { + virCapsHostCacheBankPtr bank = caches[i]; + char *cpus_str = virBitmapFormat(bank->cpus); + bool kilos = !(bank->size % 1024); + + if (!cpus_str) + return -1; + + /* + * Let's just *hope* the size is aligned to KiBs so that it does not + * bite is back in the future + */ + virBufferAsprintf(buf, + "<bank id='%u' level='%u' type='%s' " + "size='%llu' unit='%s' cpus='%s'/>\n", + bank->id, bank->level, + virCacheTypeToString(bank->type), + bank->size >> (kilos * 10), + kilos ? "KiB" : "B", + cpus_str); + + VIR_FREE(cpus_str); + } + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</cache>\n"); + + return 0; +} + /** * virCapabilitiesFormatXML: * @caps: capabilities to format @@ -957,6 +1005,10 @@ virCapabilitiesFormatXML(virCapsPtr caps) caps->host.numaCell) < 0) goto error; + if (virCapabilitiesFormatCaches(&buf, caps->host.ncaches, + caps->host.caches) < 0) + goto error; + for (i = 0; i < caps->host.nsecModels; i++) { virBufferAddLit(&buf, "<secmodel>\n"); virBufferAdjustIndent(&buf, 2); @@ -1439,3 +1491,107 @@ virCapabilitiesInitPages(virCapsPtr caps) VIR_FREE(pages_size); return ret; } + + +VIR_ENUM_IMPL(virCache, VIR_CACHE_TYPE_LAST, + "unified", + "instruction", + "data") + +bool +virCapsHostCacheBankEquals(virCapsHostCacheBankPtr a, + virCapsHostCacheBankPtr b) +{ + return (a->id == b->id && + a->level == b->level && + a->type == b->type && + a->size == b->size && + virBitmapEqual(a->cpus, b->cpus)); +} + +void +virCapsHostCacheBankFree(virCapsHostCacheBankPtr ptr) +{ + if (!ptr) + return; + + virBitmapFree(ptr->cpus); + VIR_FREE(ptr); +} + +int +virCapabilitiesInitCaches(virCapsPtr caps) +{ + size_t i = 0; + virBitmapPtr cpus = NULL; + ssize_t pos = -1; + DIR *dirp = NULL; + int ret = -1; + char *type = NULL; + struct dirent *ent = NULL; + virCapsHostCacheBankPtr bank = NULL; + + /* offline CPUs don't provide cache info */ + if (virSysfsGetValueBitmap("cpu/online", &cpus) < 0) + return -1; + + while ((pos = virBitmapNextSetBit(cpus, pos)) >= 0) { + int rv = virSysfsCpuDirOpen(pos, "cache/", &dirp); + + if (rv == -2) + continue; + + while ((rv = virDirRead(dirp, &ent, "cache/")) > 0) { + int tmp_i; + char *tmp_c; + + if (!STRPREFIX(ent->d_name, "index")) + continue; + + if (VIR_ALLOC(bank) < 0) + goto cleanup; + + if (virSysfsGetCpuCacheValueUint(pos, ent->d_name, "id", &bank->id) < 0 || + virSysfsGetCpuCacheValueUint(pos, ent->d_name, "level", &bank->level) < 0 || + virSysfsGetCpuCacheValueString(pos, ent->d_name, "type", &type) < 0 || + virSysfsGetCpuCacheValueScaledInt(pos, ent->d_name, "size", &bank->size) < 0 || + virSysfsGetCpuCacheValueBitmap(pos, ent->d_name, "shared_cpu_list", &bank->cpus) < 0) + goto cleanup; + + for (tmp_c = type; tmp_c != '\0'; tmp_c++) + *tmp_c = c_tolower(*tmp_c); + + tmp_i = virCacheTypeFromString(type); + if (tmp_i < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown cache type '%s'"), type); + VIR_FREE(type); + goto cleanup; + } + bank->type = tmp_i; + + for (i = 0; i < caps->host.ncaches; i++) { + if (virCapsHostCacheBankEquals(bank, caps->host.caches[i])) + break; + } + if (i == caps->host.ncaches) { + if (VIR_APPEND_ELEMENT(caps->host.caches, + caps->host.ncaches, + bank) < 0) { + goto cleanup; + } + bank = NULL; + continue; + } + + } + if (rv < 0) + goto cleanup; + } + + ret = 0; + cleanup: + virDirClose(&dirp); + virCapsHostCacheBankFree(bank); + return ret; +} diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index d10eef3afdea..e099cccf6d39 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -138,6 +138,26 @@ struct _virCapsHostSecModel { virCapsHostSecModelLabelPtr labels; }; +typedef enum { + VIR_CACHE_TYPE_DATA, + VIR_CACHE_TYPE_INSTRUCTION, + VIR_CACHE_TYPE_UNIFIED, + + VIR_CACHE_TYPE_LAST +} virCacheType; + +VIR_ENUM_DECL(virCache); + +typedef struct _virCapsHostCacheBank virCapsHostCacheBank; +typedef virCapsHostCacheBank *virCapsHostCacheBankPtr; +struct _virCapsHostCacheBank { + unsigned int id; + unsigned int level; /* 1=L1, 2=L2, 3=L3, etc. */ + unsigned long long size; /* B */ + virCacheType type; /* Data, Instruction or Unified */ + virBitmapPtr cpus; /* All CPUs that share this bank */ +}; + typedef struct _virCapsHost virCapsHost; typedef virCapsHost *virCapsHostPtr; struct _virCapsHost { @@ -157,6 +177,9 @@ struct _virCapsHost { size_t nnumaCell_max; virCapsHostNUMACellPtr *numaCell; + size_t ncaches; + virCapsHostCacheBankPtr *caches; + size_t nsecModels; virCapsHostSecModelPtr secModels; @@ -303,4 +326,10 @@ int virCapabilitiesInitPages(virCapsPtr caps); int virCapabilitiesInitNUMA(virCapsPtr caps); +bool virCapsHostCacheBankEquals(virCapsHostCacheBankPtr a, + virCapsHostCacheBankPtr b); +void virCapsHostCacheBankFree(virCapsHostCacheBankPtr ptr); + +int virCapabilitiesInitCaches(virCapsPtr caps); + #endif /* __VIR_CAPABILITIES_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0b3b41516fe6..5eb8c1ae962b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -59,6 +59,7 @@ virCapabilitiesFreeNUMAInfo; virCapabilitiesGetCpusForNodemask; virCapabilitiesGetNodeInfo; virCapabilitiesHostSecModelAddBaseLabel; +virCapabilitiesInitCaches; virCapabilitiesInitNUMA; virCapabilitiesInitPages; virCapabilitiesNew; -- 2.12.2

Commit a0fdd2f6f9a0cc77ae285c289e2c16d314b6a907 added some data from the system but forgot 3 files for each cache. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id | 1 + .../vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_list | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_map | 2 +- tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id | 1 + 80 files changed, 80 insertions(+), 48 deletions(-) create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_list index d41d18ba0096..8b0fab869c1d 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_list @@ -1 +1 @@ -0,4 +0-1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_map index b4de39476753..75016ea36252 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/shared_cpu_map @@ -1 +1 @@ -11 +03 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_list index d41d18ba0096..8b0fab869c1d 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_list @@ -1 +1 @@ -0,4 +0-1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_map index b4de39476753..75016ea36252 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/shared_cpu_map @@ -1 +1 @@ -11 +03 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_list index d41d18ba0096..8b0fab869c1d 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_list @@ -1 +1 @@ -0,4 +0-1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_map index b4de39476753..75016ea36252 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/shared_cpu_map @@ -1 +1 @@ -11 +03 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_list index cf141eb99931..8b0fab869c1d 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_list @@ -1 +1 @@ -1,5 +0-1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_map index 2bd5a0a98a36..75016ea36252 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/shared_cpu_map @@ -1 +1 @@ -22 +03 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_list index cf141eb99931..8b0fab869c1d 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_list @@ -1 +1 @@ -1,5 +0-1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_map index 2bd5a0a98a36..75016ea36252 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/shared_cpu_map @@ -1 +1 @@ -22 +03 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_list index cf141eb99931..8b0fab869c1d 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_list @@ -1 +1 @@ -1,5 +0-1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_map index 2bd5a0a98a36..75016ea36252 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/shared_cpu_map @@ -1 +1 @@ -22 +03 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_list index 62188ed84ff3..7a9857542a65 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_list @@ -1 +1 @@ -2,6 +2-3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_map index c739b42c4d2c..8ac4b4ca54c5 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/shared_cpu_map @@ -1 +1 @@ -44 +0c diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_list index 62188ed84ff3..7a9857542a65 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_list @@ -1 +1 @@ -2,6 +2-3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_map index c739b42c4d2c..8ac4b4ca54c5 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/shared_cpu_map @@ -1 +1 @@ -44 +0c diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_list index 62188ed84ff3..7a9857542a65 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_list @@ -1 +1 @@ -2,6 +2-3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_map index c739b42c4d2c..8ac4b4ca54c5 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/shared_cpu_map @@ -1 +1 @@ -44 +0c diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_list index 62dcd5976571..7a9857542a65 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_list @@ -1 +1 @@ -3,7 +2-3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_map index d22307c427b8..8ac4b4ca54c5 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/shared_cpu_map @@ -1 +1 @@ -88 +0c diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_list index 62dcd5976571..7a9857542a65 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_list @@ -1 +1 @@ -3,7 +2-3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_map index d22307c427b8..8ac4b4ca54c5 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/shared_cpu_map @@ -1 +1 @@ -88 +0c diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_list index 62dcd5976571..7a9857542a65 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_list @@ -1 +1 @@ -3,7 +2-3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_map index d22307c427b8..8ac4b4ca54c5 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/shared_cpu_map @@ -1 +1 @@ -88 +0c diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id new file mode 100644 index 000000000000..0cfbf08886fc --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_list index d41d18ba0096..e66d883ade72 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_list @@ -1 +1 @@ -0,4 +4-5 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_map index b4de39476753..64bb6b746dce 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/shared_cpu_map @@ -1 +1 @@ -11 +30 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id new file mode 100644 index 000000000000..0cfbf08886fc --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_list index d41d18ba0096..e66d883ade72 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_list @@ -1 +1 @@ -0,4 +4-5 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_map index b4de39476753..64bb6b746dce 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/shared_cpu_map @@ -1 +1 @@ -11 +30 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id new file mode 100644 index 000000000000..0cfbf08886fc --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_list index d41d18ba0096..e66d883ade72 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_list @@ -1 +1 @@ -0,4 +4-5 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_map index b4de39476753..64bb6b746dce 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/shared_cpu_map @@ -1 +1 @@ -11 +30 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id new file mode 100644 index 000000000000..0cfbf08886fc --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_list index cf141eb99931..e66d883ade72 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_list @@ -1 +1 @@ -1,5 +4-5 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_map index 2bd5a0a98a36..64bb6b746dce 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/shared_cpu_map @@ -1 +1 @@ -22 +30 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id new file mode 100644 index 000000000000..0cfbf08886fc --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_list index cf141eb99931..e66d883ade72 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_list @@ -1 +1 @@ -1,5 +4-5 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_map index 2bd5a0a98a36..64bb6b746dce 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/shared_cpu_map @@ -1 +1 @@ -22 +30 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id new file mode 100644 index 000000000000..0cfbf08886fc --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_list index cf141eb99931..e66d883ade72 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_list @@ -1 +1 @@ -1,5 +4-5 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_map index 2bd5a0a98a36..64bb6b746dce 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/shared_cpu_map @@ -1 +1 @@ -22 +30 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id new file mode 100644 index 000000000000..00750edc07d6 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_list index 62188ed84ff3..fdd9f375177b 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_list @@ -1 +1 @@ -2,6 +6-7 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_map index c739b42c4d2c..caecf05cdbb0 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/shared_cpu_map @@ -1 +1 @@ -44 +c0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id new file mode 100644 index 000000000000..00750edc07d6 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_list index 62188ed84ff3..fdd9f375177b 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_list @@ -1 +1 @@ -2,6 +6-7 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_map index c739b42c4d2c..caecf05cdbb0 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/shared_cpu_map @@ -1 +1 @@ -44 +c0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id new file mode 100644 index 000000000000..00750edc07d6 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_list index 62188ed84ff3..fdd9f375177b 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_list @@ -1 +1 @@ -2,6 +6-7 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_map index c739b42c4d2c..caecf05cdbb0 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/shared_cpu_map @@ -1 +1 @@ -44 +c0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id new file mode 100644 index 000000000000..00750edc07d6 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_list index 62dcd5976571..fdd9f375177b 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_list @@ -1 +1 @@ -3,7 +6-7 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_map index d22307c427b8..caecf05cdbb0 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/shared_cpu_map @@ -1 +1 @@ -88 +c0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id new file mode 100644 index 000000000000..00750edc07d6 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_list index 62dcd5976571..fdd9f375177b 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_list @@ -1 +1 @@ -3,7 +6-7 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_map index d22307c427b8..caecf05cdbb0 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/shared_cpu_map @@ -1 +1 @@ -88 +c0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id new file mode 100644 index 000000000000..00750edc07d6 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_list b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_list index 62dcd5976571..fdd9f375177b 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_list +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_list @@ -1 +1 @@ -3,7 +6-7 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_map b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_map index d22307c427b8..caecf05cdbb0 100644 --- a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_map +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/shared_cpu_map @@ -1 +1 @@ -88 +c0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id @@ -0,0 +1 @@ +0 -- 2.12.2

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/conf/capabilities.c | 2 +- tests/vircaps2xmldata/vircaps-x86_64-caches.xml | 15 +++++++++++++++ tests/vircaps2xmltest.c | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index c07c64e7d73c..73431ee14237 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1558,7 +1558,7 @@ virCapabilitiesInitCaches(virCapsPtr caps) virSysfsGetCpuCacheValueBitmap(pos, ent->d_name, "shared_cpu_list", &bank->cpus) < 0) goto cleanup; - for (tmp_c = type; tmp_c != '\0'; tmp_c++) + for (tmp_c = type; *tmp_c != '\0'; tmp_c++) *tmp_c = c_tolower(*tmp_c); tmp_i = virCacheTypeFromString(type); diff --git a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml index 88f2ec62277e..c3defd686418 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml @@ -28,6 +28,21 @@ </cell> </cells> </topology> + <cache> + <bank id='0' level='3' type='unified' size='8192' unit='KiB' cpus='0-7'/> + <bank id='0' level='2' type='unified' size='256' unit='KiB' cpus='0-1'/> + <bank id='0' level='1' type='instruction' size='32' unit='KiB' cpus='0-1'/> + <bank id='0' level='1' type='data' size='32' unit='KiB' cpus='0-1'/> + <bank id='1' level='2' type='unified' size='256' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='instruction' size='32' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='data' size='32' unit='KiB' cpus='2-3'/> + <bank id='2' level='2' type='unified' size='256' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='instruction' size='32' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='data' size='32' unit='KiB' cpus='4-5'/> + <bank id='3' level='2' type='unified' size='256' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='instruction' size='32' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='data' size='32' unit='KiB' cpus='6-7'/> + </cache> </host> </capabilities> diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index ffbe9a783811..dda0757766a8 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -58,7 +58,8 @@ test_virCapabilities(const void *opaque) if (!caps) goto cleanup; - if (virCapabilitiesInitNUMA(caps) < 0) + if (virCapabilitiesInitNUMA(caps) < 0 || + virCapabilitiesInitCaches(caps) < 0) goto cleanup; virSysfsSetSystemPath(NULL); -- 2.12.2

</cells> Okay, cool, this comes better than my patches and have some differences. I am open with this as long as that it can meet cache allocation requires and everyone will be happy.
I am ++ for this. But I am not sure expose all of cache information in the capabilities XML.
</topology> + <cache> + <bank id='0' level='3' type='unified' size='8192' unit='KiB' cpus='0-7'/>
eg: if enabled CDP feature on the host, what the type of level=3 cache should be like?
+ <bank id='0' level='2' type='unified' size='256' unit='KiB' cpus='0-1'/> for the bank id, it’s per cache level unique right (data/instruction shares same id)? + <bank id='0' level='1' type='instruction' size='32' unit='KiB' cpus='0-1'/> + <bank id='0' level='1' type='data' size='32' unit='KiB' cpus='0-1'/> + <bank id='1' level='2' type='unified' size='256' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='instruction' size='32' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='data' size='32' unit='KiB' cpus='2-3'/> + <bank id='2' level='2' type='unified' size='256' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='instruction' size='32' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='data' size='32' unit='KiB' cpus='4-5'/> + <bank id='3' level='2' type='unified' size='256' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='instruction' size='32' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='data' size='32' unit='KiB' cpus='6-7'/> + </cache>
This’s really good that you have work this out by expose all these out to capabilities, and it will be much easy to let resctrl keep focus on cache allocation. So if util/virresctrl.c would like to access some cache abilities, it will first get virCapsPtr.host.caches, right? but I am not sure if that’s be okay to expose all cache information which we can not do the allocation yet. How can a user/admin to know from capabilities?
</host>
</capabilities> diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index ffbe9a783811..dda0757766a8 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -58,7 +58,8 @@ test_virCapabilities(const void *opaque) if (!caps) goto cleanup;
- if (virCapabilitiesInitNUMA(caps) < 0) + if (virCapabilitiesInitNUMA(caps) < 0 || + virCapabilitiesInitCaches(caps) < 0) goto cleanup;
virSysfsSetSystemPath(NULL); -- 2.12.2
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Mar 31, 2017 at 09:56:32AM +0800, Eli Qiao wrote:
</cells> Okay, cool, this comes better than my patches and have some differences. I am open with this as long as that it can meet cache allocation requires and everyone will be happy.
I am ++ for this.
But I am not sure expose all of cache information in the capabilities XML.
??? Are you not sure we "should expose" all of cache information? Or are you afraid we're not exposing enough information?
</topology> + <cache> + <bank id='0' level='3' type='unified' size='8192' unit='KiB' cpus='0-7'/>
eg: if enabled CDP feature on the host, what the type of level=3 cache should be like?
This has nothing to do with resctrl yet. I'm just exposing the caches that exist on the host.
+ <bank id='0' level='2' type='unified' size='256' unit='KiB' cpus='0-1'/> for the bank id, it’s per cache level unique right (data/instruction shares same id)?
It looks like it's per cache level/type unique. But it's precisely just what the kernel exposes to us. I'm not doing anything on top of that.
+ <bank id='0' level='1' type='instruction' size='32' unit='KiB' cpus='0-1'/> + <bank id='0' level='1' type='data' size='32' unit='KiB' cpus='0-1'/> + <bank id='1' level='2' type='unified' size='256' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='instruction' size='32' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='data' size='32' unit='KiB' cpus='2-3'/> + <bank id='2' level='2' type='unified' size='256' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='instruction' size='32' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='data' size='32' unit='KiB' cpus='4-5'/> + <bank id='3' level='2' type='unified' size='256' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='instruction' size='32' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='data' size='32' unit='KiB' cpus='6-7'/> + </cache>
This’s really good that you have work this out by expose all these out to capabilities, and it will be much easy to let resctrl keep focus on cache allocation.
So if util/virresctrl.c would like to access some cache abilities, it will first get virCapsPtr.host.caches, right?
Well yeah, it'll probably extend the CacheBank struct.
but I am not sure if that’s be okay to expose all cache information which we can not do the allocation yet.
What's the harm?
How can a user/admin to know from capabilities?
Easily. The XML you see above just says what cache is on the host. If any of the banks are allocatable, then it will have a sub-element. Is there any problem with that?
</host>
</capabilities> diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index ffbe9a783811..dda0757766a8 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -58,7 +58,8 @@ test_virCapabilities(const void *opaque) if (!caps) goto cleanup;
- if (virCapabilitiesInitNUMA(caps) < 0) + if (virCapabilitiesInitNUMA(caps) < 0 || + virCapabilitiesInitCaches(caps) < 0) goto cleanup;
virSysfsSetSystemPath(NULL); -- 2.12.2
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list

On Friday, 31 March 2017 at 7:19 PM, Martin Kletzander wrote:
On Fri, Mar 31, 2017 at 09:56:32AM +0800, Eli Qiao wrote:
</cells> Okay, cool, this comes better than my patches and have some differences. I am open with this as long as that it can meet cache allocation requires and everyone will be happy.
I am ++ for this.
But I am not sure expose all of cache information in the capabilities XML.
??? Are you not sure we "should expose" all of cache information? Or are you afraid we're not exposing enough information?
Well, I was saying not to expose all of the information, but after your reply, it's okay for me.
</topology> + <cache> + <bank id='0' level='3' type='unified' size='8192' unit='KiB' cpus='0-7'/>
eg: if enabled CDP feature on the host, what the type of level=3 cache should be like?
This has nothing to do with resctrl yet. I'm just exposing the caches that exist on the host.
+ <bank id='0' level='2' type='unified' size='256' unit='KiB' cpus='0-1'/> for the bank id, it’s per cache level unique right (data/instruction shares same id)?
It looks like it's per cache level/type unique. But it's precisely just what the kernel exposes to us. I'm not doing anything on top of that.
+ <bank id='0' level='1' type='instruction' size='32' unit='KiB' cpus='0-1'/> + <bank id='0' level='1' type='data' size='32' unit='KiB' cpus='0-1'/> + <bank id='1' level='2' type='unified' size='256' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='instruction' size='32' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='data' size='32' unit='KiB' cpus='2-3'/> + <bank id='2' level='2' type='unified' size='256' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='instruction' size='32' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='data' size='32' unit='KiB' cpus='4-5'/> + <bank id='3' level='2' type='unified' size='256' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='instruction' size='32' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='data' size='32' unit='KiB' cpus='6-7'/> + </cache>
This’s really good that you have work this out by expose all these out to capabilities, and it will be much easy to let resctrl keep focus on cache allocation.
So if util/virresctrl.c would like to access some cache abilities, it will first get virCapsPtr.host.caches, right?
Well yeah, it'll probably extend the CacheBank struct.
+1
but I am not sure if that’s be okay to expose all cache information which we can not do the allocation yet.
What's the harm?
think about I have a host has 2 Socket 22 core and 2 thread per core, I will have 88 cpus so the cache bank will be a large list 2 for l3 , 44 for l2, 44 for l1d and 44 for l1c, not all of them are useful to users, and the capabilities XML are boring. Even though I am Okay to expose all of them. I remember that Daniel has some comments for this in the RFC to not expose all caches of the host if no cache allocation support yet. Any way, no harm.
How can a user/admin to know from capabilities?
Easily. The XML you see above just says what cache is on the host. If any of the banks are allocatable, then it will have a sub-element. Is there any problem with that?
No problem, +1 to extend a sub-element . Any suggestions for what’s it should be? How about for l3: <control min="2816" avail=“56320” cbm_len=“20” scope=‘both’ reserved=“2816"/>
</host>
</capabilities> diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index ffbe9a783811..dda0757766a8 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -58,7 +58,8 @@ test_virCapabilities(const void *opaque) if (!caps) goto cleanup;
- if (virCapabilitiesInitNUMA(caps) < 0) + if (virCapabilitiesInitNUMA(caps) < 0 || + virCapabilitiesInitCaches(caps) < 0) goto cleanup;
virSysfsSetSystemPath(NULL); -- 2.12.2
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Mar 31, 2017 at 08:33:12PM +0800, Eli Qiao wrote:
On Friday, 31 March 2017 at 7:19 PM, Martin Kletzander wrote:
On Fri, Mar 31, 2017 at 09:56:32AM +0800, Eli Qiao wrote:
</cells> Okay, cool, this comes better than my patches and have some differences. I am open with this as long as that it can meet cache allocation requires and everyone will be happy.
I am ++ for this.
But I am not sure expose all of cache information in the capabilities XML.
??? Are you not sure we "should expose" all of cache information? Or are you afraid we're not exposing enough information?
Well, I was saying not to expose all of the information, but after your reply, it's okay for me.
</topology> + <cache> + <bank id='0' level='3' type='unified' size='8192' unit='KiB' cpus='0-7'/>
eg: if enabled CDP feature on the host, what the type of level=3 cache should be like?
This has nothing to do with resctrl yet. I'm just exposing the caches that exist on the host.
+ <bank id='0' level='2' type='unified' size='256' unit='KiB' cpus='0-1'/> for the bank id, it’s per cache level unique right (data/instruction shares same id)?
It looks like it's per cache level/type unique. But it's precisely just what the kernel exposes to us. I'm not doing anything on top of that.
+ <bank id='0' level='1' type='instruction' size='32' unit='KiB' cpus='0-1'/> + <bank id='0' level='1' type='data' size='32' unit='KiB' cpus='0-1'/> + <bank id='1' level='2' type='unified' size='256' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='instruction' size='32' unit='KiB' cpus='2-3'/> + <bank id='1' level='1' type='data' size='32' unit='KiB' cpus='2-3'/> + <bank id='2' level='2' type='unified' size='256' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='instruction' size='32' unit='KiB' cpus='4-5'/> + <bank id='2' level='1' type='data' size='32' unit='KiB' cpus='4-5'/> + <bank id='3' level='2' type='unified' size='256' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='instruction' size='32' unit='KiB' cpus='6-7'/> + <bank id='3' level='1' type='data' size='32' unit='KiB' cpus='6-7'/> + </cache>
This’s really good that you have work this out by expose all these out to capabilities, and it will be much easy to let resctrl keep focus on cache allocation.
So if util/virresctrl.c would like to access some cache abilities, it will first get virCapsPtr.host.caches, right?
Well yeah, it'll probably extend the CacheBank struct.
+1
but I am not sure if that’s be okay to expose all cache information which we can not do the allocation yet.
What's the harm?
think about I have a host has 2 Socket 22 core and 2 thread per core, I will have 88 cpus
so the cache bank will be a large list
2 for l3 , 44 for l2, 44 for l1d and 44 for l1c, not all of them are useful to users, and the capabilities XML are boring.
You will have as many <bank/> elements as you have different caches. So probably 1 for l3, 44 for l2 and 44 for each l1 (88). Anyway, you are right, that's still 133 lines of stuff not everyone cares about. And the capability XML is already pretty long.
Even though I am Okay to expose all of them.
I remember that Daniel has some comments for this in the RFC to not expose all caches of the host if no cache allocation support yet.
I remember him saying that it's not necessary to expose all of it, but for it to be able to be extendable, and in the future, able to expose more caches. So now we see how the XML looks like, I'll change it in next version to just report l3 in a way that we can switch it later on by changing no more than one line of code.
Any way, no harm.
Yeah, there's no *real* harm, but you have a very good point that on bigger systems the capability XML will be ridiculously gross to read =)
How can a user/admin to know from capabilities?
Easily. The XML you see above just says what cache is on the host. If any of the banks are allocatable, then it will have a sub-element. Is there any problem with that?
No problem, +1 to extend a sub-element .
Any suggestions for what’s it should be?
How about for l3: <control min="2816" avail=“56320” cbm_len=“20” scope=‘both’ reserved=“2816"/>
Well, yes, kind of what you had in your patches. Wasn't it without the 'cbm_len' and 'avail'? The 'cbm_len' is avail/min, so it's redundant and avail is the same as the size of the whole cache, right? Also 'reserved' should not be there as that would have to be refreshed every time the info is gathered and that's not what capabilities are for. Also, if we say 'unified' instead of 'both', it sounds little more consistent. So basically, I'm thinking we were somewhere along the lines of: <control min='2816' unit='B' scope=‘unified’/> Or do I remember it wrong?

How about for l3: <control min="2816" avail=“56320” cbm_len=“20” scope=‘both’ reserved=“2816"/>
Well, yes, kind of what you had in your patches. Wasn't it without the 'cbm_len' and 'avail'? The 'cbm_len' is avail/min, so it's redundant and avail is the same as the size of the whole cache, right? Also 'reserved' should not be there as that would have to be refreshed every time the info is gathered and that's not what capabilities are for. Also, if we say 'unified' instead of 'both', it sounds little more consistent.
So basically, I'm thinking we were somewhere along the lines of:
<control min='2816' unit='B' scope=‘unified’/>
Or do I remember it wrong? oh yeah, right!
for scope, it’s okay to use 'unified' to instead of ‘both’ for CDP enabled case would it be ? 1) <control min='2816' unit='B' scope=‘data’/> <control min='2816' unit='B' scope=‘instruction’/> or 2) <control min='2816' unit='B' scope=‘data+instruction’/> or 3) <control min='2816' unit='B' scope=‘cdp’/> ? A correction, that would be <control min=‘2816 * 1024' unit='B' scope=‘unified’/> the unit B is kinds of small for l3 cache. Thx Eli.

On Fri, Mar 31, 2017 at 09:23:39PM +0800, Eli Qiao wrote:
How about for l3: <control min="2816" avail=“56320” cbm_len=“20” scope=‘both’ reserved=“2816"/>
Well, yes, kind of what you had in your patches. Wasn't it without the 'cbm_len' and 'avail'? The 'cbm_len' is avail/min, so it's redundant and avail is the same as the size of the whole cache, right? Also 'reserved' should not be there as that would have to be refreshed every time the info is gathered and that's not what capabilities are for. Also, if we say 'unified' instead of 'both', it sounds little more consistent.
So basically, I'm thinking we were somewhere along the lines of:
<control min='2816' unit='B' scope=‘unified’/>
Or do I remember it wrong? oh yeah, right!
for scope, it’s okay to use 'unified' to instead of ‘both’ for CDP enabled case would it be ?
1) <control min='2816' unit='B' scope=‘data’/> <control min='2816' unit='B' scope=‘instruction’/>
I like this ^^.
or
2)
<control min='2816' unit='B' scope=‘data+instruction’/>
or 3)
<control min='2816' unit='B' scope=‘cdp’/>
?
A correction, that would be <control min=‘2816 * 1024' unit='B' scope=‘unified’/>
the unit B is kinds of small for l3 cache.
Well, in that case just use unit='KiB' in case it's divisible.
Thx Eli.

Added only in drivers that were already calling virCapabilitiesInitNUMA(). Instead of refactoring all the callers to behave the same way in case of error, just follow what the callers are doing for all the functions. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/lxc/lxc_conf.c | 3 +++ src/openvz/openvz_conf.c | 3 +++ src/phyp/phyp_driver.c | 3 +++ src/qemu/qemu_capabilities.c | 3 +++ src/uml/uml_conf.c | 3 +++ src/vbox/vbox_common.c | 3 +++ src/vmware/vmware_conf.c | 3 +++ src/vz/vz_driver.c | 2 ++ 8 files changed, 23 insertions(+) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index e47b667f582a..508b98ba21b3 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -81,6 +81,9 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); } + if (virCapabilitiesInitCaches(caps) < 0) + VIR_WARN("Failed to get host CPU cache info"); + /* Only probe for power management capabilities in the driver, * not in the emulator */ if (driver && virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 196fefb8de19..23a02d749e8b 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -168,6 +168,9 @@ virCapsPtr openvzCapsInit(void) if (virCapabilitiesInitNUMA(caps) < 0) goto no_memory; + if (virCapabilitiesInitCaches(caps) < 0) + goto no_memory; + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, caps->host.arch, diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 1803aa53b744..abf05a5b8771 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -340,6 +340,9 @@ phypCapsInit(void) ("Failed to query host NUMA topology, disabling NUMA capabilities"); } + if (virCapabilitiesInitCaches(caps) < 0) + VIR_WARN("Failed to get host CPU cache info"); + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_LINUX, caps->host.arch, diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f51141b99062..2ae8c816d64d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1105,6 +1105,9 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); } + if (virCapabilitiesInitCaches(caps) < 0) + VIR_WARN("Failed to get host CPU cache info"); + if (!(caps->host.cpu = virCPUProbeHost(caps->host.arch))) VIR_WARN("Failed to get host CPU"); diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 871653c5a64c..2be849a6c160 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -69,6 +69,9 @@ virCapsPtr umlCapsInit(void) VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); } + if (virCapabilitiesInitCaches(caps) < 0) + VIR_WARN("Failed to get host CPU cache info"); + if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities"); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index b71506ae5dc3..aef62e6d7e3a 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -79,6 +79,9 @@ vboxCapsInit(void) if (virCapabilitiesInitNUMA(caps) < 0) goto no_memory; + if (virCapabilitiesInitCaches(caps) < 0) + goto no_memory; + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, caps->host.arch, diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index bf4597c4748a..891d9a47f0b4 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -68,6 +68,9 @@ vmwareCapsInit(void) if (virCapabilitiesInitNUMA(caps) < 0) goto error; + if (virCapabilitiesInitCaches(caps) < 0) + goto error; + /* i686 guests are always supported */ if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 88f1960eb178..4fef9411048c 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -118,6 +118,8 @@ vzBuildCapabilities(void) if (virCapabilitiesInitNUMA(caps) < 0) goto error; + if (virCapabilitiesInitCaches(caps) < 0) + goto error; verify(ARRAY_CARDINALITY(archs) == ARRAY_CARDINALITY(emulators)); -- 2.12.2
participants (2)
-
Eli Qiao
-
Martin Kletzander