<div>
                    <br>
                </div>
                <div></div>
                 
                <p style="color: #A0A0A8;">On Friday, 31 March 2017 at 7:39 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>On Fri, Mar 31, 2017 at 05:32:16PM +0800, Eli Qiao wrote:</div><blockquote type="cite"><div><div><br></div><div><br></div><div>On Thursday, 30 March 2017 at 10:03 PM, Martin Kletzander wrote:</div><div><br></div><blockquote type="cite"><div><div>Signed-off-by: Martin Kletzander <mkletzan@redhat.com (<a href="mailto:mkletzan@redhat.com">mailto: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></blockquote><div><br></div><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></div></blockquote><div><br></div><div>What do you mean?  The files look just like they look in the system.</div><div>It's a copy of what actually is under /sys/devices/system.  The</div><div>description is in the kernel.</div><div><br></div></div></div></span></blockquote><div>Okay, never mind. </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div></div><blockquote type="cite"><div><blockquote type="cite"><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></blockquote><div><br></div><div><br></div><div>cpu/cpu0/cache/index3/size</div></div></blockquote><div><br></div><div>???</div><div><br></div></div></div></span></blockquote><div>ignore this. </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div></div><blockquote type="cite"><div><blockquote type="cite"><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></blockquote><div><br></div><div><br></div><div>Can we add notes here to tell the value is in unite KiB ?</div></div></blockquote><div><br></div><div>Well what if you want to use this for another file in the future?  This</div><div>function will be able to read it even if the file has "1M" in it.  Or</div><div>did you mean something else?</div></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>My mistake, it’s should B (not KiB), It’s okay.
                </div>