Merge pull request #96828 from panjf2000/opt-epoll-eventfd

kubelet/eviction: eliminate redundant allocations when handling eventfd
This commit is contained in:
Kubernetes Prow Robot 2022-03-01 13:59:54 -08:00 committed by GitHub
commit 5d6a793221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,6 +116,7 @@ func (n *linuxCgroupNotifier) Start(eventCh chan<- struct{}) {
klog.InfoS("Eviction manager: error adding epoll eventfd", "err", err)
return
}
buf := make([]byte, eventSize)
for {
select {
case <-n.stop:
@ -131,7 +132,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.InfoS("Eviction manager: error reading memcg events", "err", err)