MCPcopy Create free account
hub / github.com/containerd/cgroups / getStatPSIFromFile

Function getStatPSIFromFile

cgroup2/utils.go:538–574  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

536}
537
538func getStatPSIFromFile(path string) *stats.PSIStats {
539 f, err := os.Open(path)
540 if err != nil {
541 return nil
542 }
543 defer f.Close()
544
545 psistats := &stats.PSIStats{}
546 sc := bufio.NewScanner(f)
547 for sc.Scan() {
548 parts := strings.Fields(sc.Text())
549 var pv *stats.PSIData
550 switch parts[0] {
551 case "some":
552 psistats.Some = &stats.PSIData{}
553 pv = psistats.Some
554 case "full":
555 psistats.Full = &stats.PSIData{}
556 pv = psistats.Full
557 }
558 if pv != nil {
559 err = parsePSIData(parts[1:], pv)
560 if err != nil {
561 log.L.WithError(err).Errorf("failed to read file %s", path)
562 return nil
563 }
564 }
565 }
566
567 if err := sc.Err(); err != nil {
568 if !errors.Is(err, unix.ENOTSUP) && !errors.Is(err, unix.EOPNOTSUPP) {
569 log.L.WithError(err).Error("unable to parse PSI data")
570 }
571 return nil
572 }
573 return psistats
574}
575
576func parsePSIData(psi []string, data *stats.PSIData) error {
577 for _, f := range psi {

Callers 4

TestParseStatCPUPSIFunction · 0.85
StatFilteredMethod · 0.85
readCPUStatsFunction · 0.85
readMemoryStatsFunction · 0.85

Calls 1

parsePSIDataFunction · 0.85

Tested by 1

TestParseStatCPUPSIFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…