Skip to contentSkip to conversation

ring-buffer: Minor fixes for 5.10

PATCH New Steven Rostedt 1 participant 3 messages Oct 23, 2020

Subsystems (3)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover ring-buffer: Minor fixes for 5.10

The success return value of ring_buffer_resize() is stated to be zero, and checked that way. But it is incorrectly returning the size allocade.

Also, a documentation fix.

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: e1981f75d398c0afe83c8ffa4e5864f037967409

Qiujun Huang (2):
ring-buffer: Return 0 on success from ring_buffer_resize()
ring-buffer: Update the description for ring_buffer_wait

----

 kernel/trace/ring_buffer.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 ring-buffer: Return 0 on success from ring_buffer_resize()

From: Qiujun Huang <[email protected]>

We don't need to check the new buffer size, and the return value had confused resize_buffer_duplicate_size().
...

	ret = ring_buffer_resize(trace_buf->buffer,
		per_cpu_ptr(size_buf->data,cpu_id)->entries, cpu_id);
	if (ret == 0)
		per_cpu_ptr(trace_buf->data, cpu_id)->entries =
			per_cpu_ptr(size_buf->data, cpu_id)->entries;

...

Fixes d60da506cbeb3 ("tracing: Add a resize function to make one buffer equivalent to another buffer")
---
 kernel/trace/ring_buffer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/ring_buffer.c +4 -4
index 15bf28b13e50..5c6a9c6a058f 100644
@@ -1952,18 +1952,18 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
 {
 	struct ring_buffer_per_cpu *cpu_buffer;
 	unsigned long nr_pages;
-	int cpu, err = 0;
+	int cpu, err;
 
 	/*
 	 * Always succeed at resizing a non-existent buffer:
 	 */
 	if (!buffer)
-		return size;
+		return 0;
 
 	/* Make sure the requested buffer exists */
 	if (cpu_id != RING_BUFFER_ALL_CPUS &&
 	    !cpumask_test_cpu(cpu_id, buffer->cpumask))
-		return size;
+		return 0;
 
 	nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
 
@@ -2119,7 +2119,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
 	}
 
 	mutex_unlock(&buffer->mutex);
-	return size;
+	return 0;
 
  out_err:
 	for_each_buffer_cpu(buffer, cpu) {
Signature · 1 line
2.28.0
author maintainer
#2 lore raw

PATCH 2/2 ring-buffer: Update the description for ring_buffer_wait

In reply to Steven Rostedt

From: Qiujun Huang <[email protected]>

The function changed at some point, but the description was not updated.

---
 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ring_buffer.c +1 -1
index 5c6a9c6a058f..7f45fd9d5a45 100644
@@ -793,7 +793,7 @@ static void rb_wake_up_waiters(struct irq_work *work)
  * ring_buffer_wait - wait for input to the ring buffer
  * @buffer: buffer to wait on
  * @cpu: the cpu buffer to wait on
- * @full: wait until a full page is available, if @cpu != RING_BUFFER_ALL_CPUS
+ * @full: wait until the percentage of pages are available, if @cpu != RING_BUFFER_ALL_CPUS
  *
  * If @cpu == RING_BUFFER_ALL_CPUS then the task will wake up as soon
  * as data is added to any of the @buffer's cpu buffers. Otherwise
Signature · 1 line
2.28.0