Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: EPERM for epoll_ctl() on every os.Open #44552

Closed
wmark opened this issue Feb 23, 2021 · 2 comments
Closed

runtime: EPERM for epoll_ctl() on every os.Open #44552

wmark opened this issue Feb 23, 2021 · 2 comments

Comments

@wmark
Copy link

@wmark wmark commented Feb 23, 2021

go version go1.16

  • Linux 5.10 and 5.4
  • xfs and ext4

attempts two useless epoll_ctl on every os.Open ,
either indicating that the epoll facility does not work for files, or an check is missing to turn it off as it is without any back-off.

I ran this under strace, as unprivileged user and root without difference, …

package main

import (
	"bytes"
	"fmt"
	"os"
)

func main() {
	f, _ := os.Open("/etc/os-release")
	//_ = f.Fd()
	var b bytes.Buffer
	n, _ := b.ReadFrom(f)
	f.Close()

	f, _ = os.Open("/etc/os-release")
	n, _ = b.ReadFrom(f)
	f.Close()

	fmt.Printf("in: %d\n", n)
}

… expecting this trailer (edited):

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
… (Either no epoll_ctl, or no EPERM.) …
… read(3, …
close(3)                                = 0

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
… (No epoll_ctl in any case, due to the preceding EPERM.) …
… read(3, …
close(3)                                = 0

… yet witnessed this (please note the EPERM):

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=3290965168, u64=140337052394672}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 3, 0xc00025fd4c) = -1 EPERM (Operation not permitted)
… read(3, …
close(3)                                = 0

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=3290965168, u64=140337052394672}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 3, 0xc00025fd4c) = -1 EPERM (Operation not permitted)
… read(3, …
close(3)                                = 0
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 23, 2021

The os package doesn't know apriori which files support epoll. So it just tries to use epoll for every file.

It does seem like we don't need the EPOLL_CTL_DEL if the EPOLL_CTL_ADD fails, though.

@ianlancetaylor ianlancetaylor added this to the Backlog milestone Feb 23, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 1, 2021

Change https://golang.org/cl/297392 mentions this issue: internal/poll, runtime: handle netpollopen error in poll_runtime_pollOpen

@gopherbot gopherbot closed this in ebb92df Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants