github.com/google/cadvisor@v0.49.1/perf/types_libpfm.go (about)

     1  //go:build libpfm && cgo
     2  // +build libpfm,cgo
     3  
     4  // Copyright 2020 Google Inc. All Rights Reserved.
     5  //
     6  // Licensed under the Apache License, Version 2.0 (the "License");
     7  // you may not use this file except in compliance with the License.
     8  // You may obtain a copy of the License at
     9  //
    10  //     http://www.apache.org/licenses/LICENSE-2.0
    11  //
    12  // Unless required by applicable law or agreed to in writing, software
    13  // distributed under the License is distributed on an "AS IS" BASIS,
    14  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  // See the License for the specific language governing permissions and
    16  // limitations under the License.
    17  
    18  // Types related to handling perf events that are missing from unix package.
    19  package perf
    20  
    21  import "C"
    22  import (
    23  	"io"
    24  	"unsafe"
    25  )
    26  
    27  // GroupReadFormat allows to read perf event's values for grouped events.
    28  // See https://man7.org/linux/man-pages/man2/perf_event_open.2.html section "Reading results" with PERF_FORMAT_GROUP specified.
    29  type GroupReadFormat struct {
    30  	Nr          uint64 /* The number of events */
    31  	TimeEnabled uint64 /* if PERF_FORMAT_TOTAL_TIME_ENABLED */
    32  	TimeRunning uint64 /* if PERF_FORMAT_TOTAL_TIME_RUNNING */
    33  }
    34  
    35  type Values struct {
    36  	Value uint64 /* The value of the event */
    37  	ID    uint64 /* if PERF_FORMAT_ID */
    38  }
    39  
    40  // pfmPerfEncodeArgT represents structure that is used to parse perf event nam
    41  // into perf_event_attr using libpfm.
    42  type pfmPerfEncodeArgT struct {
    43  	attr unsafe.Pointer
    44  	fstr unsafe.Pointer
    45  	size C.size_t
    46  	_    C.int // idx
    47  	_    C.int // cpu
    48  	_    C.int // flags
    49  }
    50  
    51  type readerCloser interface {
    52  	io.Reader
    53  	io.Closer
    54  }