tracing: Set actual size after ring buffer resize
[platform/kernel/linux-starfive.git] / kernel / trace / trace.c
index a3c4f98..bc96567 100644 (file)
@@ -6286,6 +6286,15 @@ static void set_buffer_entries(struct array_buffer *buf, unsigned long val)
                per_cpu_ptr(buf->data, cpu)->entries = val;
 }
 
+static void update_buffer_entries(struct array_buffer *buf, int cpu)
+{
+       if (cpu == RING_BUFFER_ALL_CPUS) {
+               set_buffer_entries(buf, ring_buffer_size(buf->buffer, 0));
+       } else {
+               per_cpu_ptr(buf->data, cpu)->entries = ring_buffer_size(buf->buffer, cpu);
+       }
+}
+
 #ifdef CONFIG_TRACER_MAX_TRACE
 /* resize @tr's buffer to the size of @size_tr's entries */
 static int resize_buffer_duplicate_size(struct array_buffer *trace_buf,
@@ -6364,18 +6373,12 @@ static int __tracing_resize_ring_buffer(struct trace_array *tr,
                return ret;
        }
 
-       if (cpu == RING_BUFFER_ALL_CPUS)
-               set_buffer_entries(&tr->max_buffer, size);
-       else
-               per_cpu_ptr(tr->max_buffer.data, cpu)->entries = size;
+       update_buffer_entries(&tr->max_buffer, cpu);
 
  out:
 #endif /* CONFIG_TRACER_MAX_TRACE */
 
-       if (cpu == RING_BUFFER_ALL_CPUS)
-               set_buffer_entries(&tr->array_buffer, size);
-       else
-               per_cpu_ptr(tr->array_buffer.data, cpu)->entries = size;
+       update_buffer_entries(&tr->array_buffer, cpu);
 
        return ret;
 }