Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
cpu_buffer.c File Reference
#include <linux/sched.h>
#include <linux/oprofile.h>
#include <linux/errno.h>
#include "event_buffer.h"
#include "cpu_buffer.h"
#include "buffer_sync.h"
#include "oprof.h"

Go to the source code of this file.

Macros

#define OP_BUFFER_FLAGS   0
 
#define DEFAULT_TIMER_EXPIRE   (HZ / 10)
 
#define RB_EVENT_HDR_SIZE   4
 

Functions

 DEFINE_PER_CPU (struct oprofile_cpu_buffer, op_cpu_buffer)
 
unsigned long oprofile_get_cpu_buffer_size (void)
 
void oprofile_cpu_buffer_inc_smpl_lost (void)
 
void free_cpu_buffers (void)
 
int alloc_cpu_buffers (void)
 
void start_cpu_work (void)
 
void end_cpu_work (void)
 
void flush_cpu_work (void)
 
struct op_sampleop_cpu_buffer_write_reserve (struct op_entry *entry, unsigned long size)
 
int op_cpu_buffer_write_commit (struct op_entry *entry)
 
struct op_sampleop_cpu_buffer_read_entry (struct op_entry *entry, int cpu)
 
unsigned long op_cpu_buffer_entries (int cpu)
 
void oprofile_add_ext_hw_sample (unsigned long pc, struct pt_regs *const regs, unsigned long event, int is_kernel, struct task_struct *task)
 
void oprofile_add_ext_sample (unsigned long pc, struct pt_regs *const regs, unsigned long event, int is_kernel)
 
void oprofile_add_sample (struct pt_regs *const regs, unsigned long event)
 
void oprofile_write_reserve (struct op_entry *entry, struct pt_regs *const regs, unsigned long pc, int code, int size)
 
int oprofile_add_data (struct op_entry *entry, unsigned long val)
 
int oprofile_add_data64 (struct op_entry *entry, u64 val)
 
int oprofile_write_commit (struct op_entry *entry)
 
void oprofile_add_pc (unsigned long pc, int is_kernel, unsigned long event)
 
void oprofile_add_trace (unsigned long pc)
 

Detailed Description

Remarks
Copyright 2002-2009 OProfile authors
Read the file COPYING
Author
John Levon levon.nosp@m.@mov.nosp@m.ement.nosp@m.aria.nosp@m.n.org
Barry Kasindorf barry.nosp@m..kas.nosp@m.indor.nosp@m.f@am.nosp@m.d.com
Robert Richter rober.nosp@m.t.ri.nosp@m.chter.nosp@m.@amd.nosp@m..com

Each CPU has a local buffer that stores PC value/event pairs. We also log context switches when we notice them. Eventually each CPU's buffer is processed into the global event buffer by sync_buffer().

We use a local buffer for two reasons: an NMI or similar interrupt cannot synchronise, and high sampling rates would lead to catastrophic global synchronisation if a global buffer was used.

Definition in file cpu_buffer.c.

Macro Definition Documentation

#define DEFAULT_TIMER_EXPIRE   (HZ / 10)

Definition at line 38 of file cpu_buffer.c.

#define OP_BUFFER_FLAGS   0

Definition at line 31 of file cpu_buffer.c.

#define RB_EVENT_HDR_SIZE   4

Definition at line 60 of file cpu_buffer.c.

Function Documentation

int alloc_cpu_buffers ( void  )

Definition at line 62 of file cpu_buffer.c.

DEFINE_PER_CPU ( struct oprofile_cpu_buffer  ,
op_cpu_buffer   
)
void end_cpu_work ( void  )

Definition at line 112 of file cpu_buffer.c.

void flush_cpu_work ( void  )

Definition at line 117 of file cpu_buffer.c.

void free_cpu_buffers ( void  )

Definition at line 53 of file cpu_buffer.c.

unsigned long op_cpu_buffer_entries ( int  cpu)

Definition at line 176 of file cpu_buffer.c.

struct op_sample* op_cpu_buffer_read_entry ( struct op_entry entry,
int  cpu 
)
read

Definition at line 161 of file cpu_buffer.c.

int op_cpu_buffer_write_commit ( struct op_entry entry)

Definition at line 156 of file cpu_buffer.c.

struct op_sample* op_cpu_buffer_write_reserve ( struct op_entry entry,
unsigned long  size 
)
read

Definition at line 142 of file cpu_buffer.c.

int oprofile_add_data ( struct op_entry entry,
unsigned long  val 
)

Definition at line 384 of file cpu_buffer.c.

int oprofile_add_data64 ( struct op_entry entry,
u64  val 
)

Definition at line 391 of file cpu_buffer.c.

void oprofile_add_ext_hw_sample ( unsigned long  pc,
struct pt_regs *const  regs,
unsigned long  event,
int  is_kernel,
struct task_struct task 
)

Add an hardware sample.

Definition at line 319 of file cpu_buffer.c.

void oprofile_add_ext_sample ( unsigned long  pc,
struct pt_regs *const  regs,
unsigned long  event,
int  is_kernel 
)

Add an extended sample. Use this when the PC is not from the regs, and we cannot determine if we're in kernel mode from the regs.

This function does perform a backtrace.

Definition at line 326 of file cpu_buffer.c.

void oprofile_add_pc ( unsigned long  pc,
int  is_kernel,
unsigned long  event 
)

Definition at line 413 of file cpu_buffer.c.

void oprofile_add_sample ( struct pt_regs *const  regs,
unsigned long  event 
)

Add a sample. This may be called from any context.

Definition at line 332 of file cpu_buffer.c.

void oprofile_add_trace ( unsigned long  pc)

Definition at line 419 of file cpu_buffer.c.

void oprofile_cpu_buffer_inc_smpl_lost ( void  )

Definition at line 46 of file cpu_buffer.c.

unsigned long oprofile_get_cpu_buffer_size ( void  )

Definition at line 41 of file cpu_buffer.c.

int oprofile_write_commit ( struct op_entry entry)

Definition at line 406 of file cpu_buffer.c.

void oprofile_write_reserve ( struct op_entry entry,
struct pt_regs *const  regs,
unsigned long  pc,
int  code,
int  size 
)

Definition at line 355 of file cpu_buffer.c.

void start_cpu_work ( void  )

Definition at line 95 of file cpu_buffer.c.