Update to new cadvisor v0.48.1

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2023-10-31 07:51:09 -04:00
parent 0294521985
commit 8b9fc325e2
36 changed files with 425 additions and 331 deletions

View File

@@ -62,7 +62,7 @@ type group struct {
var (
isLibpfmInitialized = false
libpmfMutex = sync.Mutex{}
libpfmMutex = sync.Mutex{}
)
const (
@@ -70,8 +70,8 @@ const (
)
func init() {
libpmfMutex.Lock()
defer libpmfMutex.Unlock()
libpfmMutex.Lock()
defer libpfmMutex.Unlock()
pErr := C.pfm_initialize()
if pErr != C.PFM_SUCCESS {
klog.Errorf("unable to initialize libpfm: %d", int(pErr))
@@ -266,10 +266,12 @@ func readPerfEventAttr(name string, pfmGetOsEventEncoding func(string, unsafe.Po
func pfmGetOsEventEncoding(name string, perfEventAttrMemory unsafe.Pointer) error {
event := pfmPerfEncodeArgT{}
fstr := C.CString("")
defer C.free(unsafe.Pointer(fstr))
event.fstr = unsafe.Pointer(fstr)
event.attr = perfEventAttrMemory
event.size = C.ulong(unsafe.Sizeof(event))
cSafeName := C.CString(name)
defer C.free(unsafe.Pointer(cSafeName))
pErr := C.pfm_get_os_event_encoding(cSafeName, C.PFM_PLM0|C.PFM_PLM3, C.PFM_OS_PERF_EVENT, unsafe.Pointer(&event))
if pErr != C.PFM_SUCCESS {
return fmt.Errorf("unable to transform event name %s to perf_event_attr: %d", name, int(pErr))
@@ -409,8 +411,8 @@ func (c *collector) Destroy() {
// Finalize terminates libpfm4 to free resources.
func Finalize() {
libpmfMutex.Lock()
defer libpmfMutex.Unlock()
libpfmMutex.Lock()
defer libpfmMutex.Unlock()
klog.V(1).Info("Attempting to terminate libpfm4")
if !isLibpfmInitialized {

View File

@@ -25,7 +25,6 @@ package perf
import "C"
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
@@ -70,7 +69,7 @@ func getPMU(pmus uncorePMUs, gotType uint32) (*pmu, error) {
type uncorePMUs map[string]pmu
func readUncorePMU(path string, name string, cpumaskRegexp *regexp.Regexp) (*pmu, error) {
buf, err := ioutil.ReadFile(filepath.Join(path, pmuTypeFilename))
buf, err := os.ReadFile(filepath.Join(path, pmuTypeFilename))
if err != nil {
return nil, err
}
@@ -80,7 +79,7 @@ func readUncorePMU(path string, name string, cpumaskRegexp *regexp.Regexp) (*pmu
return nil, err
}
buf, err = ioutil.ReadFile(filepath.Join(path, pmuCpumaskFilename))
buf, err = os.ReadFile(filepath.Join(path, pmuCpumaskFilename))
if err != nil {
return nil, err
}