-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: fix TestPerfReaderWakeupEvents
The WakeupEvents limit is per ring, one per CPU. And when we execute BPF_PROG_RUN multiple times, we sometimes execute on different CPUs. This means that samples don't all go into a single ring. Fix this by forcing the producer to run on a single CPU. Fixes #1419 Co-developed-by: Dylan Reimerink <dylan@isovalent.com> Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package testutils | ||
|
||
import ( | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/cilium/ebpf/internal/unix" | ||
|
||
"github.com/go-quicktest/qt" | ||
) | ||
|
||
// LockOSThreadToSingleCPU force the current goroutine to run on a single CPU. | ||
func LockOSThreadToSingleCPU(tb testing.TB) { | ||
tb.Helper() | ||
|
||
runtime.LockOSThread() | ||
tb.Cleanup(runtime.UnlockOSThread) | ||
|
||
var old unix.CPUSet | ||
err := unix.SchedGetaffinity(0, &old) | ||
qt.Assert(tb, qt.IsNil(err)) | ||
|
||
// Schedule test to run on only CPU 0 | ||
var first unix.CPUSet | ||
first.Set(0) | ||
err = unix.SchedSetaffinity(0, &first) | ||
qt.Assert(tb, qt.IsNil(err)) | ||
|
||
tb.Cleanup(func() { | ||
_ = unix.SchedSetaffinity(0, &old) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters