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