Skip to content

Commit

Permalink
perf: Make struct ring_buffer less ambiguous
Browse files Browse the repository at this point in the history
eBPF requires needing to know the size of the perf ring buffer structure.
But it unfortunately has the same name as the generic ring buffer used by
tracing and oprofile. To make it less ambiguous, rename the perf ring buffer
structure to "perf_buffer".

As other parts of the ring buffer code has "perf_" as the prefix, it only
makes sense to give the ring buffer the "perf_" prefix as well.

Link: https://lore.kernel.org/r/20191213153553.GE20583@krava
Acked-by: Peter Zijlstra <peterz@infradead.org>
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (VMware) committed Jan 13, 2020
1 parent b3a987b commit 56de4e8
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 68 deletions.
6 changes: 3 additions & 3 deletions include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ struct swevent_hlist {
#define PERF_ATTACH_ITRACE 0x10

struct perf_cgroup;
struct ring_buffer;
struct perf_buffer;

struct pmu_event_list {
raw_spinlock_t lock;
Expand Down Expand Up @@ -694,7 +694,7 @@ struct perf_event {
struct mutex mmap_mutex;
atomic_t mmap_count;

struct ring_buffer *rb;
struct perf_buffer *rb;
struct list_head rb_entry;
unsigned long rcu_batches;
int rcu_pending;
Expand Down Expand Up @@ -854,7 +854,7 @@ struct perf_cpu_context {

struct perf_output_handle {
struct perf_event *event;
struct ring_buffer *rb;
struct perf_buffer *rb;
unsigned long wakeup;
unsigned long size;
u64 aux_flags;
Expand Down
42 changes: 21 additions & 21 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4373,7 +4373,7 @@ static void free_event_rcu(struct rcu_head *head)
}

static void ring_buffer_attach(struct perf_event *event,
struct ring_buffer *rb);
struct perf_buffer *rb);

static void detach_sb_event(struct perf_event *event)
{
Expand Down Expand Up @@ -5054,7 +5054,7 @@ perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
static __poll_t perf_poll(struct file *file, poll_table *wait)
{
struct perf_event *event = file->private_data;
struct ring_buffer *rb;
struct perf_buffer *rb;
__poll_t events = EPOLLHUP;

poll_wait(file, &event->waitq, wait);
Expand Down Expand Up @@ -5296,7 +5296,7 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon
return perf_event_set_bpf_prog(event, arg);

case PERF_EVENT_IOC_PAUSE_OUTPUT: {
struct ring_buffer *rb;
struct perf_buffer *rb;

rcu_read_lock();
rb = rcu_dereference(event->rb);
Expand Down Expand Up @@ -5432,7 +5432,7 @@ static void calc_timer_values(struct perf_event *event,
static void perf_event_init_userpage(struct perf_event *event)
{
struct perf_event_mmap_page *userpg;
struct ring_buffer *rb;
struct perf_buffer *rb;

rcu_read_lock();
rb = rcu_dereference(event->rb);
Expand Down Expand Up @@ -5464,7 +5464,7 @@ void __weak arch_perf_update_userpage(
void perf_event_update_userpage(struct perf_event *event)
{
struct perf_event_mmap_page *userpg;
struct ring_buffer *rb;
struct perf_buffer *rb;
u64 enabled, running, now;

rcu_read_lock();
Expand Down Expand Up @@ -5515,7 +5515,7 @@ EXPORT_SYMBOL_GPL(perf_event_update_userpage);
static vm_fault_t perf_mmap_fault(struct vm_fault *vmf)
{
struct perf_event *event = vmf->vma->vm_file->private_data;
struct ring_buffer *rb;
struct perf_buffer *rb;
vm_fault_t ret = VM_FAULT_SIGBUS;

if (vmf->flags & FAULT_FLAG_MKWRITE) {
Expand Down Expand Up @@ -5548,9 +5548,9 @@ static vm_fault_t perf_mmap_fault(struct vm_fault *vmf)
}

static void ring_buffer_attach(struct perf_event *event,
struct ring_buffer *rb)
struct perf_buffer *rb)
{
struct ring_buffer *old_rb = NULL;
struct perf_buffer *old_rb = NULL;
unsigned long flags;

if (event->rb) {
Expand Down Expand Up @@ -5608,7 +5608,7 @@ static void ring_buffer_attach(struct perf_event *event,

static void ring_buffer_wakeup(struct perf_event *event)
{
struct ring_buffer *rb;
struct perf_buffer *rb;

rcu_read_lock();
rb = rcu_dereference(event->rb);
Expand All @@ -5619,9 +5619,9 @@ static void ring_buffer_wakeup(struct perf_event *event)
rcu_read_unlock();
}

struct ring_buffer *ring_buffer_get(struct perf_event *event)
struct perf_buffer *ring_buffer_get(struct perf_event *event)
{
struct ring_buffer *rb;
struct perf_buffer *rb;

rcu_read_lock();
rb = rcu_dereference(event->rb);
Expand All @@ -5634,7 +5634,7 @@ struct ring_buffer *ring_buffer_get(struct perf_event *event)
return rb;
}

void ring_buffer_put(struct ring_buffer *rb)
void ring_buffer_put(struct perf_buffer *rb)
{
if (!refcount_dec_and_test(&rb->refcount))
return;
Expand Down Expand Up @@ -5672,7 +5672,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
{
struct perf_event *event = vma->vm_file->private_data;

struct ring_buffer *rb = ring_buffer_get(event);
struct perf_buffer *rb = ring_buffer_get(event);
struct user_struct *mmap_user = rb->mmap_user;
int mmap_locked = rb->mmap_locked;
unsigned long size = perf_data_size(rb);
Expand Down Expand Up @@ -5790,8 +5790,8 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
struct perf_event *event = file->private_data;
unsigned long user_locked, user_lock_limit;
struct user_struct *user = current_user();
struct perf_buffer *rb = NULL;
unsigned long locked, lock_limit;
struct ring_buffer *rb = NULL;
unsigned long vma_size;
unsigned long nr_pages;
long user_extra = 0, extra = 0;
Expand Down Expand Up @@ -6266,7 +6266,7 @@ static unsigned long perf_prepare_sample_aux(struct perf_event *event,
size_t size)
{
struct perf_event *sampler = event->aux_event;
struct ring_buffer *rb;
struct perf_buffer *rb;

data->aux_size = 0;

Expand Down Expand Up @@ -6299,7 +6299,7 @@ static unsigned long perf_prepare_sample_aux(struct perf_event *event,
return data->aux_size;
}

long perf_pmu_snapshot_aux(struct ring_buffer *rb,
long perf_pmu_snapshot_aux(struct perf_buffer *rb,
struct perf_event *event,
struct perf_output_handle *handle,
unsigned long size)
Expand Down Expand Up @@ -6338,8 +6338,8 @@ static void perf_aux_sample_output(struct perf_event *event,
struct perf_sample_data *data)
{
struct perf_event *sampler = event->aux_event;
struct perf_buffer *rb;
unsigned long pad;
struct ring_buffer *rb;
long size;

if (WARN_ON_ONCE(!sampler || !data->aux_size))
Expand Down Expand Up @@ -6707,7 +6707,7 @@ void perf_output_sample(struct perf_output_handle *handle,
int wakeup_events = event->attr.wakeup_events;

if (wakeup_events) {
struct ring_buffer *rb = handle->rb;
struct perf_buffer *rb = handle->rb;
int events = local_inc_return(&rb->events);

if (events >= wakeup_events) {
Expand Down Expand Up @@ -7150,15 +7150,15 @@ void perf_event_exec(void)
}

struct remote_output {
struct ring_buffer *rb;
struct perf_buffer *rb;
int err;
};

static void __perf_event_output_stop(struct perf_event *event, void *data)
{
struct perf_event *parent = event->parent;
struct remote_output *ro = data;
struct ring_buffer *rb = ro->rb;
struct perf_buffer *rb = ro->rb;
struct stop_event_data sd = {
.event = event,
};
Expand Down Expand Up @@ -10998,7 +10998,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
static int
perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
{
struct ring_buffer *rb = NULL;
struct perf_buffer *rb = NULL;
int ret = -EINVAL;

if (!output_event)
Expand Down
34 changes: 17 additions & 17 deletions kernel/events/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define RING_BUFFER_WRITABLE 0x01

struct ring_buffer {
struct perf_buffer {
refcount_t refcount;
struct rcu_head rcu_head;
#ifdef CONFIG_PERF_USE_VMALLOC
Expand Down Expand Up @@ -58,34 +58,34 @@ struct ring_buffer {
void *data_pages[0];
};

extern void rb_free(struct ring_buffer *rb);
extern void rb_free(struct perf_buffer *rb);

static inline void rb_free_rcu(struct rcu_head *rcu_head)
{
struct ring_buffer *rb;
struct perf_buffer *rb;

rb = container_of(rcu_head, struct ring_buffer, rcu_head);
rb = container_of(rcu_head, struct perf_buffer, rcu_head);
rb_free(rb);
}

static inline void rb_toggle_paused(struct ring_buffer *rb, bool pause)
static inline void rb_toggle_paused(struct perf_buffer *rb, bool pause)
{
if (!pause && rb->nr_pages)
rb->paused = 0;
else
rb->paused = 1;
}

extern struct ring_buffer *
extern struct perf_buffer *
rb_alloc(int nr_pages, long watermark, int cpu, int flags);
extern void perf_event_wakeup(struct perf_event *event);
extern int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
extern int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,
pgoff_t pgoff, int nr_pages, long watermark, int flags);
extern void rb_free_aux(struct ring_buffer *rb);
extern struct ring_buffer *ring_buffer_get(struct perf_event *event);
extern void ring_buffer_put(struct ring_buffer *rb);
extern void rb_free_aux(struct perf_buffer *rb);
extern struct perf_buffer *ring_buffer_get(struct perf_event *event);
extern void ring_buffer_put(struct perf_buffer *rb);

static inline bool rb_has_aux(struct ring_buffer *rb)
static inline bool rb_has_aux(struct perf_buffer *rb)
{
return !!rb->aux_nr_pages;
}
Expand All @@ -94,7 +94,7 @@ void perf_event_aux_event(struct perf_event *event, unsigned long head,
unsigned long size, u64 flags);

extern struct page *
perf_mmap_to_page(struct ring_buffer *rb, unsigned long pgoff);
perf_mmap_to_page(struct perf_buffer *rb, unsigned long pgoff);

#ifdef CONFIG_PERF_USE_VMALLOC
/*
Expand All @@ -103,25 +103,25 @@ perf_mmap_to_page(struct ring_buffer *rb, unsigned long pgoff);
* Required for architectures that have d-cache aliasing issues.
*/

static inline int page_order(struct ring_buffer *rb)
static inline int page_order(struct perf_buffer *rb)
{
return rb->page_order;
}

#else

static inline int page_order(struct ring_buffer *rb)
static inline int page_order(struct perf_buffer *rb)
{
return 0;
}
#endif

static inline unsigned long perf_data_size(struct ring_buffer *rb)
static inline unsigned long perf_data_size(struct perf_buffer *rb)
{
return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
}

static inline unsigned long perf_aux_size(struct ring_buffer *rb)
static inline unsigned long perf_aux_size(struct perf_buffer *rb)
{
return rb->aux_nr_pages << PAGE_SHIFT;
}
Expand All @@ -141,7 +141,7 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb)
buf += written; \
handle->size -= written; \
if (!handle->size) { \
struct ring_buffer *rb = handle->rb; \
struct perf_buffer *rb = handle->rb; \
\
handle->page++; \
handle->page &= rb->nr_pages - 1; \
Expand Down
Loading

0 comments on commit 56de4e8

Please sign in to comment.