opd_kernel.c File Reference

#include "opd_kernel.h"
#include "opd_proc.h"
#include "opd_image.h"
#include "opd_mapping.h"
#include "opd_printf.h"
#include "opd_24_stats.h"
#include "oprofiled.h"
#include "op_fileio.h"
#include "op_config_24.h"
#include "op_libiberty.h"
#include "p_module.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
Include dependency graph for opd_kernel.c:

Go to the source code of this file.

Data Structures

struct  opd_module

Functions

void opd_init_kernel_image (void)
void opd_parse_kernel_range (char const *arg)
static struct opd_moduleopd_create_module (char *name, unsigned long start, unsigned long end)
static struct opd_moduleopd_find_module_by_name (char *name)
void opd_clear_module_info (void)
static void opd_get_module_info (void)
static void opd_drop_module_sample (unsigned long eip)
static struct opd_moduleopd_find_module_by_eip (unsigned long eip)
static void opd_handle_module_sample (unsigned long eip, u32 counter)
void opd_handle_kernel_sample (unsigned long eip, u32 counter)
int opd_eip_is_kernel (unsigned long eip)
void opd_add_kernel_map (struct opd_proc *proc, unsigned long eip)

Variables

static struct opd_imagekernel_image
static unsigned long kernel_start
static unsigned long kernel_end
static struct list_head opd_modules = { &opd_modules, &opd_modules }
static unsigned int nr_modules = 0

Detailed Description

Dealing with the kernel and kernel module samples

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
John Levon
Philippe Elie

Definition in file opd_kernel.c.


Function Documentation

void opd_add_kernel_map ( struct opd_proc proc,
unsigned long  eip 
)

opd_add_kernel_map - add a module or kernel maps to a proc struct

Parameters:
proc owning proc of the new mapping
eip eip inside the new mapping

We assume than eip >= kernel_start

Definition at line 411 of file opd_kernel.c.

References app_name, opd_module::end, opd_module::image, kernel_end, kernel_start, opd_module::name, opd_image::name, opd_proc::name, opd_add_mapping(), opd_clear_module_info(), opd_drop_module_sample(), opd_find_module_by_eip(), opd_get_kernel_image(), opd_get_module_info(), opd_module::start, opd_proc::tgid, opd_proc::tid, verbprintf, vmisc, vmlinux, and vmodule.

Referenced by opd_put_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_clear_module_info ( void   ) 

opd_clear_module_info - clear kernel module information

Clear and free all kernel module information and reset values.

Definition at line 113 of file opd_kernel.c.

References list_entry, list_for_each_safe, list_init(), opd_module::module_list, opd_module::name, opd_clear_kernel_mapping(), verbprintf, and vmodule.

Referenced by opd_24_exit(), opd_add_kernel_map(), opd_do_notes(), and opd_handle_module_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct opd_module* opd_create_module ( char *  name,
unsigned long  start,
unsigned long  end 
) [static, read]

opd_create_module - allocate and initialise a module description

Parameters:
name module name
start start address
end end address

Definition at line 79 of file opd_kernel.c.

References opd_module::end, opd_module::image, list_add(), opd_module::module_list, opd_module::name, and opd_module::start.

Referenced by opd_drop_module_sample(), and opd_find_module_by_name().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_drop_module_sample ( unsigned long  eip  )  [static]

opd_drop_module_sample - drop a module sample efficiently

Parameters:
eip eip of sample

This function is called to recover from failing to put a samples even after re-reading /proc/ksyms. It's either a rogue sample, or from a module that didn't create symbols (like in some initrd setups). So we check with query_module() if we can place it in a symbol-less module, and if so create a negative entry for it, to quickly ignore future samples.

Problem uncovered by Bob Montgomery <bobm@fc.hp.com>

Definition at line 271 of file opd_kernel.c.

References module_info::addr, opd_module::name, opd_24_stats, opd_create_module(), OPD_LOST_MODULE, QM_INFO, QM_MODULES, query_module(), module_info::size, verbprintf, and vmodule.

Referenced by opd_add_kernel_map(), and opd_handle_module_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

int opd_eip_is_kernel ( unsigned long  eip  ) 

opd_eip_is_kernel - is the sample from kernel/module space

Parameters:
eip EIP value

Returns 1 if eip is in the address space starting at kernel_start, 0 otherwise.

Definition at line 394 of file opd_kernel.c.

References kernel_start.

Referenced by opd_put_sample(), and opd_remove_kernel_mapping().

Here is the caller graph for this function:

static struct opd_module* opd_find_module_by_eip ( unsigned long  eip  )  [static, read]

opd_find_module_by_eip - find a module by its eip

Parameters:
eip EIP value

find in the modules container the module which contain this eip return NULL if not found. caller must check than the module image is valid

Definition at line 321 of file opd_kernel.c.

References opd_module::end, list_entry, list_for_each, opd_module::module_list, and opd_module::start.

Referenced by opd_add_kernel_map(), and opd_handle_module_sample().

Here is the caller graph for this function:

static struct opd_module* opd_find_module_by_name ( char *  name  )  [static, read]

opd_find_module_by_name - find a module by name, ccreating a new once if search fail

Parameters:
name module name

Definition at line 98 of file opd_kernel.c.

References list_entry, list_for_each, opd_module::module_list, opd_module::name, and opd_create_module().

Referenced by opd_get_module_info().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_get_module_info ( void   )  [static]

opd_get_module_info - parse mapping information for kernel modules

Parse the file /proc/ksyms to read in mapping information for all kernel modules. The modutils package adds special symbols to this file which allows determination of the module image and mapping addresses of the form :

__insmod_modulename_Oobjectfile_Mmtime_Vversion __insmod_modulename_Ssectionname_Llength

Currently the image file "objectfile" is stored, and details of ".text" sections.

There is no query_module API that allow to get directly the pathname of a module so we need to parse all the /proc/ksyms.

Definition at line 149 of file opd_kernel.c.

References opd_module::end, filename, opd_module::image, nr_modules, op_close_file(), op_get_line(), op_try_open_file(), opd_find_module_by_name(), opd_get_kernel_image(), opd_image::ref_count, opd_module::start, verbprintf, and vmodule.

Referenced by opd_add_kernel_map(), and opd_handle_module_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_handle_kernel_sample ( unsigned long  eip,
u32  counter 
)

opd_handle_kernel_sample - process a kernel sample

Parameters:
eip EIP value of sample
counter counter number

Handle a sample in kernel address space or in a module. The sample is output to the relevant image file.

Definition at line 381 of file opd_kernel.c.

References kernel_end, kernel_start, no_vmlinux, opd_24_stats, opd_handle_module_sample(), OPD_KERNEL, and opd_put_image_sample().

Referenced by opd_put_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_handle_module_sample ( unsigned long  eip,
u32  counter 
) [static]

opd_handle_module_sample - process a module sample

Parameters:
eip EIP value
counter counter number

Process a sample in module address space. The sample eip is matched against module information. If the search was successful, the sample is output to the relevant file.

Note that for modules and the kernel, the offset will be wrong in the file, as it is not a file offset, but the offset from the text section. This is fixed up in pp.

If the sample could not be located in a module, it is treated as a kernel sample.

Definition at line 352 of file opd_kernel.c.

References opd_module::image, opd_module::name, opd_24_stats, opd_clear_module_info(), opd_drop_module_sample(), opd_find_module_by_eip(), opd_get_module_info(), OPD_LOST_MODULE, OPD_MODULE, opd_put_image_sample(), opd_module::start, verbprintf, and vmodule.

Referenced by opd_handle_kernel_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_init_kernel_image ( void   ) 

opd_init_kernel_image - initialise the kernel image

Definition at line 46 of file opd_kernel.c.

References opd_get_kernel_image(), opd_image::ref_count, and vmlinux.

Referenced by opd_24_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_parse_kernel_range ( char const *  arg  ) 

opd_parse_kernel_range - parse the kernel range values

Definition at line 56 of file opd_kernel.c.

References kernel_end, kernel_start, verbprintf, and vmisc.

Referenced by opd_24_init().

Here is the caller graph for this function:


Variable Documentation

unsigned long kernel_end [static]
struct opd_image* kernel_image [static]

Definition at line 38 of file opd_kernel.c.

unsigned long kernel_start [static]
unsigned int nr_modules = 0 [static]

Definition at line 44 of file opd_kernel.c.

Referenced by opd_get_module_info().

struct list_head opd_modules = { &opd_modules, &opd_modules } [static]

Definition at line 43 of file opd_kernel.c.


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1