kubelet/eviction: eliminate redundant allocations when handling eventfd

This commit is contained in:
Andy Pan 2020-11-24 14:39:47 +08:00
parent 8b2f5be319
commit 3033a64135

View File

@ -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)