Skip to contentSkip to conversation

perf/ring_buffer: Add EPOLLRDNORM flag for poll

PATCH Superseded Tao Chen 3 participants 7 messages Mar 13, 2025 – Mar 14, 2025 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tao Chen

author
#0 lore raw

PATCH 1/1 perf/ring_buffer: Add EPOLLRDNORM flag for poll

The poll man page says POLLRDNORM is equivalent to POLLIN, so add EPOLLRDNORM here.

---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +1 -1
index 59a52b1a1..5130b119d 100644
@@ -19,7 +19,7 @@
 
 static void perf_output_wakeup(struct perf_output_handle *handle)
 {
-	atomic_set(&handle->rb->poll, EPOLLIN);
+	atomic_set(&handle->rb->poll, EPOLLIN | EPOLLRDNORM);
 
 	handle->event->pending_wakeup = 1;
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 13 lines · Tao Chen

The poll man page says POLLRDNORM is equivalent to POLLIN, so add EPOLLRDNORM here.

---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +0 -0
index 59a52b1a1..5130b119d 100644

kernel/events/ring_buffer.c line 22

Quoted 5 lines
kernel/events/ring_buffer.c +1 -1
@@ -19,7 +19,7 @@
 
 static void perf_output_wakeup(struct perf_output_handle *handle)
 {
-	atomic_set(&handle->rb->poll, EPOLLIN);
+	atomic_set(&handle->rb->poll, EPOLLIN | EPOLLRDNORM);

So what does EPOLLRDNORM mean to begin with? There doesn't seem to be separate/specific handling of it anywhere in the kernel that I can see...

Thanks,

Ingo

author
#2 lore raw
Quoted 17 lines · Ingo Molnar
Quoted 14 lines · Tao Chen

The poll man page says POLLRDNORM is equivalent to POLLIN, so add EPOLLRDNORM here.

---
  kernel/events/ring_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +0 -0
index 59a52b1a1..5130b119d 100644
@@ -19,7 +19,7 @@
 
Quoted 9 lines

kernel/events/ring_buffer.c line 22

Quoted 4 lines
kernel/events/ring_buffer.c +1 -1
  static void perf_output_wakeup(struct perf_output_handle *handle)
  {
-	atomic_set(&handle->rb->poll, EPOLLIN);
+	atomic_set(&handle->rb->poll, EPOLLIN | EPOLLRDNORM);

So what does EPOLLRDNORM mean to begin with? There doesn't seem to be separate/specific handling of it anywhere in the kernel that I can see...

It seems that if user set pollfd with POLLRDNORM, perf_poll will not return until timeout even if perf_output_wakeup called, whereas POLLIN returns.

Quoted 3 lines

Thanks,

Ingo

Signature · 2 lines
Best Regards
Tao Chen
#3 lore raw
Quoted 27 lines · Tao Chen
Quoted 11 lines · Ingo Molnar
Quoted 8 lines · Tao Chen

The poll man page says POLLRDNORM is equivalent to POLLIN, so add EPOLLRDNORM here.

---
  kernel/events/ring_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

kernel/events/ring_buffer.c line 21

Quoted 9 lines
kernel/events/ring_buffer.c +1 -1
index 59a52b1a1..5130b119d 100644
@@ -19,7 +19,7 @@
  static void perf_output_wakeup(struct perf_output_handle *handle)
  {
-	atomic_set(&handle->rb->poll, EPOLLIN);
+	atomic_set(&handle->rb->poll, EPOLLIN | EPOLLRDNORM);

So what does EPOLLRDNORM mean to begin with? There doesn't seem to be separate/specific handling of it anywhere in the kernel that I can see...

Quoted 2 lines

It seems that if user set pollfd with POLLRDNORM, perf_poll will not return until timeout even if perf_output_wakeup called, whereas POLLIN returns.

Mind adding this to the changelog, and explain that this patch fixes this particular poll() functionality and semantics for userspace?

Thanks,

Ingo

author
#4 lore raw
Quoted 2 lines · Ingo Molnar

explain that this patch fixes
this particular poll() functionality and semantics

will do it, thanks.

Signature · 2 lines
Best Regards
Tao Chen
maintainer
#5 lore raw
In reply to Ingo Molnar

Hello,

Quoted 30 lines · Ingo Molnar
Quoted 27 lines · Tao Chen
Quoted 25 lines · Ingo Molnar
Quoted 13 lines · Tao Chen

The poll man page says POLLRDNORM is equivalent to POLLIN, so add EPOLLRDNORM here.

---
  kernel/events/ring_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +0 -0
index 59a52b1a1..5130b119d 100644

kernel/events/ring_buffer.c line 21

Quoted 4 lines
kernel/events/ring_buffer.c +1 -1
@@ -19,7 +19,7 @@
  static void perf_output_wakeup(struct perf_output_handle *handle)
  {
-	atomic_set(&handle->rb->poll, EPOLLIN);
+	atomic_set(&handle->rb->poll, EPOLLIN | EPOLLRDNORM);

So what does EPOLLRDNORM mean to begin with? There doesn't seem to be separate/specific handling of it anywhere in the kernel that I can see...

Quoted 5 lines
Quoted 2 lines

It seems that if user set pollfd with POLLRDNORM, perf_poll will not return until timeout even if perf_output_wakeup called, whereas POLLIN returns.

Mind adding this to the changelog, and explain that this patch fixes this particular poll() functionality and semantics for userspace?

Off topic, but I think it should return something (either POLLHUP or POLLERR) when the event goes to an error state like pinned events are not scheduled.

Thanks,
Namhyung

#6 lore raw
Quoted 36 lines · Namhyung Kim

Hello,

Quoted 33 lines · Ingo Molnar
Quoted 29 lines · Tao Chen
Quoted 11 lines · Ingo Molnar
Quoted 8 lines · Tao Chen

The poll man page says POLLRDNORM is equivalent to POLLIN, so add EPOLLRDNORM here.

---
  kernel/events/ring_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

kernel/events/ring_buffer.c line 21

Quoted 9 lines
kernel/events/ring_buffer.c +1 -1
index 59a52b1a1..5130b119d 100644
@@ -19,7 +19,7 @@
  static void perf_output_wakeup(struct perf_output_handle *handle)
  {
-	atomic_set(&handle->rb->poll, EPOLLIN);
+	atomic_set(&handle->rb->poll, EPOLLIN | EPOLLRDNORM);

So what does EPOLLRDNORM mean to begin with? There doesn't seem to be separate/specific handling of it anywhere in the kernel that I can see...

It seems that if user set pollfd with POLLRDNORM, perf_poll will not return until timeout even if perf_output_wakeup called, whereas POLLIN returns.

Quoted 6 lines
Quoted 2 lines

Mind adding this to the changelog, and explain that this patch fixes this particular poll() functionality and semantics for userspace?

Off topic, but I think it should return something (either POLLHUP or POLLERR) when the event goes to an error state like pinned events are not scheduled.

Mind sending a patch for that?

Thanks,

Ingo