* Steven Rostedt <rostedt@xxxxxxxxxxx> [240410 13:41]: > On Sat, 6 Apr 2024 18:36:46 +0100 > Vincent Donnefort <vdonnefort@xxxxxxxxxx> wrote: > > > +int ring_buffer_map(struct trace_buffer *buffer, int cpu, > > + struct vm_area_struct *vma) > > +{ > > + struct ring_buffer_per_cpu *cpu_buffer; > > + unsigned long flags, *subbuf_ids; > > + int err = 0; > > + > > + if (!cpumask_test_cpu(cpu, buffer->cpumask)) > > + return -EINVAL; > > + > > + cpu_buffer = buffer->buffers[cpu]; > > + > > + mutex_lock(&cpu_buffer->mapping_lock); > > + > > + if (cpu_buffer->mapped) { > > + err = __rb_map_vma(cpu_buffer, vma); > > + if (!err) > > + err = __rb_inc_dec_mapped(cpu_buffer, true); > > + mutex_unlock(&cpu_buffer->mapping_lock); > > + return err; > > + } > > + > > + /* prevent another thread from changing buffer/sub-buffer sizes */ > > + mutex_lock(&buffer->mutex); > > + > > + err = rb_alloc_meta_page(cpu_buffer); > > + if (err) > > + goto unlock; > > + > > + /* subbuf_ids include the reader while nr_pages does not */ > > + subbuf_ids = kcalloc(cpu_buffer->nr_pages + 1, sizeof(*subbuf_ids), GFP_KERNEL); > > + if (!subbuf_ids) { > > + rb_free_meta_page(cpu_buffer); > > + err = -ENOMEM; > > + goto unlock; > > + } > > + > > + atomic_inc(&cpu_buffer->resize_disabled); > > + > > + /* > > + * Lock all readers to block any subbuf swap until the subbuf IDs are > > + * assigned. > > + */ > > + raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); > > + rb_setup_ids_meta_page(cpu_buffer, subbuf_ids); > > + raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); > > + > > + err = __rb_map_vma(cpu_buffer, vma); > > + if (!err) { > > + raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); > > + cpu_buffer->mapped = 1; > > + raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); > > + } else { > > + kfree(cpu_buffer->subbuf_ids); > > + cpu_buffer->subbuf_ids = NULL; > > + rb_free_meta_page(cpu_buffer); > > + } > > +unlock: > > Nit: For all labels, please add a space before them. Otherwise, diffs will > show "unlock" as the function and not "ring_buffer_map", making it harder > to find where the change is. > Isn't the inclusion of a space before labels outdate since 'git diff' superseds 'diff' and fixed this issue? Thanks, Liam