Skip to content

Commit 964fb30

Browse files
authored
Merge pull request #4116 from AkihiroSuda/fix-4094-2
guestagent: fix CPU 100% usage
2 parents a6de286 + 5b5269e commit 964fb30

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/guestagent/ticker/ebpf_linux.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package ticker
55

66
import (
7+
"os"
78
"strings"
89
"time"
910

@@ -99,6 +100,11 @@ func (ticker *ebpfTicker) Stop() {
99100

100101
func buildEbpfProg(events *ebpf.Map) (*ebpf.Program, error) {
101102
inst := asm.Instructions{
103+
// ignore events from the guestagent process itself
104+
asm.FnGetCurrentPidTgid.Call(),
105+
asm.RSh.Imm(asm.R0, 32),
106+
asm.JEq.Imm(asm.R0, int32(os.Getpid()), "ret"),
107+
102108
// ringbuf = &map
103109
asm.LoadMapPtr(asm.R1, events.FD()),
104110

@@ -120,7 +126,7 @@ func buildEbpfProg(events *ebpf.Map) (*ebpf.Program, error) {
120126
asm.FnRingbufOutput.Call(),
121127

122128
// return 0
123-
asm.Mov.Imm(asm.R0, 0),
129+
asm.Mov.Imm(asm.R0, 0).WithSymbol("ret"),
124130
asm.Return(),
125131
}
126132

0 commit comments

Comments
 (0)