Skip to contentSkip to conversation

ring-buffer: Clean ring_buffer_poll_wait() error return

PATCH New Vincent Donnefort 1 participant 1 message Jan 31, 2024

Subsystems (2)
lore
Share & tools
lore

Vincent Donnefort

author maintainer
#0 lore raw

PATCH 1/1 ring-buffer: Clean ring_buffer_poll_wait() error return

The return type for ring_buffer_poll_wait() is __poll_t. This is behind the scenes an unsigned where we can set event bits. In case of a non-allocated CPU, we do return instead -EINVAL (0xffffffea). Lucky us, this ends up setting few error bits (EPOLLERR | EPOLLHUP | EPOLLNVAL), so user-space at least is aware something went wrong.

Nonetheless, this is an incorrect code. Replace that -EINVAL with a proper EPOLLERR to clean that output. As this doesn't change the behaviour, there's no need to treat this change as a bug fix.

kernel/trace/ring_buffer.c +1 -1
index 13aaf5e85b81..fd4bfe3ecf01 100644
@@ -944,7 +944,7 @@ __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu,
 		full = 0;
 	} else {
 		if (!cpumask_test_cpu(cpu, buffer->cpumask))
-			return -EINVAL;
+			return EPOLLERR;
 
 		cpu_buffer = buffer->buffers[cpu];
 		work = &cpu_buffer->irq_work;

base-commit: 29142dc92c37d3259a33aef15b03e6ee25b0d188

Signature · 1 line
2.43.0.429.g432eaa2c6b-goog