mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
scoot pinning around
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gaissmai/bart"
|
"github.com/gaissmai/bart"
|
||||||
"github.com/rcrowley/go-metrics"
|
"github.com/rcrowley/go-metrics"
|
||||||
|
"github.com/slackhq/nebula/util"
|
||||||
|
|
||||||
"github.com/slackhq/nebula/config"
|
"github.com/slackhq/nebula/config"
|
||||||
"github.com/slackhq/nebula/firewall"
|
"github.com/slackhq/nebula/firewall"
|
||||||
@@ -387,7 +388,7 @@ func (f *Interface) listenIn(reader tio.Queue, i int) {
|
|||||||
if n := len(f.cpuAffinity); n > 0 {
|
if n := len(f.cpuAffinity); n > 0 {
|
||||||
cpu = f.cpuAffinity[i%n]
|
cpu = f.cpuAffinity[i%n]
|
||||||
}
|
}
|
||||||
if err := pinThreadToCPU(cpu); err != nil {
|
if err := util.PinThreadToCPU(cpu); err != nil {
|
||||||
f.l.Warn("failed to pin tun reader to CPU", "queue", i, "cpu", cpu, "err", err)
|
f.l.Warn("failed to pin tun reader to CPU", "queue", i, "cpu", cpu, "err", err)
|
||||||
}
|
}
|
||||||
rejectBuf := make([]byte, mtu)
|
rejectBuf := make([]byte, mtu)
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//go:build linux && !android && !e2e_testing
|
//go:build linux && !android && !e2e_testing
|
||||||
|
|
||||||
package nebula
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -8,13 +8,13 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// pinThreadToCPU restricts the calling OS thread to the given CPU via
|
// PinThreadToCPU restricts the calling OS thread to the given CPU via
|
||||||
// sched_setaffinity(2). Combined with runtime.LockOSThread on the
|
// sched_setaffinity(2). Combined with runtime.LockOSThread on the
|
||||||
// goroutine, this prevents the kernel from migrating us across CPUs and
|
// goroutine, this prevents the kernel from migrating us across CPUs and
|
||||||
// in turn keeps every sendmmsg from this goroutine going through the
|
// in turn keeps every sendmmsg from this goroutine going through the
|
||||||
// same XPS-selected TX ring, eliminating the wire-side reorder that
|
// same XPS-selected TX ring, eliminating the wire-side reorder that
|
||||||
// otherwise fragments one nebula flow across multiple rings.
|
// otherwise fragments one nebula flow across multiple rings.
|
||||||
func pinThreadToCPU(cpu int) error {
|
func PinThreadToCPU(cpu int) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
var set unix.CPUSet
|
var set unix.CPUSet
|
||||||
set.Zero()
|
set.Zero()
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
//go:build !linux || android || e2e_testing
|
//go:build !linux || android || e2e_testing
|
||||||
|
|
||||||
package nebula
|
package util
|
||||||
|
|
||||||
// pinThreadToCPU is a no-op outside Linux: only Linux exposes a stable
|
// PinThreadToCPU is a no-op outside Linux: only Linux exposes a stable
|
||||||
// per-thread CPU affinity API and only Linux has XPS-driven TX ring
|
// per-thread CPU affinity API and only Linux has XPS-driven TX ring
|
||||||
// selection in the first place. On every other platform there's nothing
|
// selection in the first place. On every other platform there's nothing
|
||||||
// to fix here.
|
// to fix here.
|
||||||
func pinThreadToCPU(_ int) error {
|
func PinThreadToCPU(_ int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user