-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathperf_generic.go
More file actions
23 lines (19 loc) · 851 Bytes
/
Copy pathperf_generic.go
File metadata and controls
23 lines (19 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//+build !amd64
package perf
import (
"syscall"
"golang.org/x/sys/unix"
)
// doEnableRunDisable enables the counters, executes f, and disables them. Where
// possible it is implemented in assembly to minimize non-deterministic
// overhead. It is assumed that perfFD is known to be a valid file descriptor at
// the time of the call, no error checking occurs.
func doEnableRunDisable(fd uintptr, f func()) {
// syscall.RawSyscall is the most economic way we can do this
// generically. It's one branch less than unix.RawSyscall, and many
// instructions less than the generic unix.Syscall, which must notify
// the runtime by eventually calling runtime.{enter,exit}syscall.
syscall.RawSyscall(unix.SYS_IOCTL, fd, uintptr(unix.PERF_EVENT_IOC_ENABLE), 0)
f()
syscall.RawSyscall(unix.SYS_IOCTL, fd, uintptr(unix.PERF_EVENT_IOC_DISABLE), 0)
}