From 3033a641356dbb744caa8f683aff41b5202b309e Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Tue, 24 Nov 2020 14:39:47 +0800 Subject: [PATCH] kubelet/eviction: eliminate redundant allocations when handling eventfd --- pkg/kubelet/eviction/threshold_notifier_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubelet/eviction/threshold_notifier_linux.go b/pkg/kubelet/eviction/threshold_notifier_linux.go index 270a7452db9..a46d4530c7a 100644 --- a/pkg/kubelet/eviction/threshold_notifier_linux.go +++ b/pkg/kubelet/eviction/threshold_notifier_linux.go @@ -107,6 +107,7 @@ func (n *linuxCgroupNotifier) Start(eventCh chan<- struct{}) { klog.Warningf("eviction manager: error adding epoll eventfd: %v", err) return } + buf := make([]byte, eventSize) for { select { case <-n.stop: @@ -122,7 +123,6 @@ func (n *linuxCgroupNotifier) Start(eventCh chan<- struct{}) { continue } // Consume the event from the eventfd - buf := make([]byte, eventSize) _, err = unix.Read(n.eventfd, buf) if err != nil { klog.Warningf("eviction manager: error reading memcg events: %v", err)