opd_proc.c File Reference

#include "op_hw_config.h"
#include "opd_proc.h"
#include "opd_image.h"
#include "opd_mapping.h"
#include "opd_sample_files.h"
#include "opd_kernel.h"
#include "opd_24_stats.h"
#include "opd_printf.h"
#include "oprofiled.h"
#include "op_interface.h"
#include "op_libiberty.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for opd_proc.c:

Go to the source code of this file.

Defines

#define OPD_MAX_PROC_HASH   1024

Typedefs

typedef void(* opd_proc_cb )(struct opd_proc *)

Functions

void opd_init_procs (void)
int opd_get_nr_procs (void)
static uint proc_hash (pid_t tid)
struct opd_procopd_new_proc (pid_t tid, pid_t tgid)
struct opd_procopd_get_proc (pid_t tid, pid_t tgid)
static void verb_show_sample (unsigned long offset, struct opd_map *map)
void opd_put_image_sample (struct opd_image *image, unsigned long offset, u32 counter)
static int opd_lookup_maps (struct opd_proc *proc, struct op_sample const *sample)
void opd_put_sample (struct op_sample const *sample)
void opd_handle_fork (struct op_note const *note)
void opd_handle_exec (pid_t tid, pid_t tgid)
void opd_handle_exit (struct op_note const *note)
static void opd_for_each_proc (opd_proc_cb proc_cb)
static void opd_delete_proc (struct opd_proc *proc)
void opd_proc_cleanup (void)
static void opd_age_proc (struct opd_proc *proc)
void opd_age_procs (void)
static void opd_remove_kernel_mapping (struct opd_proc *proc)
void opd_clear_kernel_mapping (void)

Variables

int cpu_number
static struct list_head opd_procs [OPD_MAX_PROC_HASH]
static int nr_procs

Detailed Description

Management of processes

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

Definition in file opd_proc.c.


Define Documentation

#define OPD_MAX_PROC_HASH   1024

Definition at line 31 of file opd_proc.c.

Referenced by opd_for_each_proc(), opd_init_procs(), and proc_hash().


Typedef Documentation

typedef void(* opd_proc_cb)(struct opd_proc *)

Definition at line 333 of file opd_proc.c.


Function Documentation

static void opd_age_proc ( struct opd_proc proc  )  [static]

opd_age_proc - age a struct opd_proc

Parameters:
proc proc to age

age dead proc in such way if a proc doesn't receive any samples between two age_proc the opd_proc struct is deleted

Definition at line 388 of file opd_proc.c.

References opd_proc::accessed, opd_proc::dead, and opd_delete_proc().

Referenced by opd_age_procs().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_age_procs ( void   ) 

opd_age_procs - age all dead process preparing them for a deletion

Definition at line 400 of file opd_proc.c.

References opd_age_proc(), and opd_for_each_proc().

Referenced by opd_alarm().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_clear_kernel_mapping ( void   ) 

opd_clear_kernel_mapping - remove all kernel mapping for all opd_proc

invalidate (by removing them) all kernel mapping. This function do nothing when separate_kernel == 0 because we don't add mapping for kernel sample in proc struct. As side effect decrease reference count of associated with these mapping which eventually close this image

Definition at line 429 of file opd_proc.c.

References opd_for_each_proc(), and opd_remove_kernel_mapping().

Referenced by opd_clear_module_info().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_delete_proc ( struct opd_proc proc  )  [static]

opd_delete_proc - delete a process

Parameters:
proc process to delete

Remove the process proc from the process list and free the associated structures.

Definition at line 364 of file opd_proc.c.

References list_del(), opd_proc::name, opd_proc::next, nr_procs, and opd_kill_maps().

Referenced by opd_age_proc(), and opd_proc_cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_for_each_proc ( opd_proc_cb  proc_cb  )  [static]
Parameters:
proc_cb callback to apply onto each existing proc struct

the callback receive a struct opd_proc * (not a const struct) and is allowed to freeze the proc struct itself.

Definition at line 341 of file opd_proc.c.

References list_entry, list_for_each_safe, opd_proc::next, OPD_MAX_PROC_HASH, and opd_procs.

Referenced by opd_age_procs(), opd_clear_kernel_mapping(), and opd_proc_cleanup().

Here is the caller graph for this function:

int opd_get_nr_procs ( void   ) 

opd_get_nr_procs - return number of processes tracked

Definition at line 50 of file opd_proc.c.

References nr_procs.

Referenced by opd_print_24_stats().

Here is the caller graph for this function:

struct opd_proc* opd_get_proc ( pid_t  tid,
pid_t  tgid 
) [read]

opd_get_proc - get process from process list

Parameters:
tid tid for this process
tgid tgid for this process

A process with pid tid is searched on the process list, maintaining LRU order. If it is not found, NULL is returned, otherwise the process structure is returned.

Definition at line 85 of file opd_proc.c.

References list_add(), list_del(), list_entry, list_for_each_safe, opd_proc::next, list_head::next, opd_24_stats, OPD_PROC_QUEUE_ACCESS, OPD_PROC_QUEUE_DEPTH, opd_procs, proc_hash(), opd_proc::tgid, and opd_proc::tid.

Referenced by opd_get_ascii_procs(), opd_handle_exec(), opd_handle_exit(), opd_handle_fork(), opd_handle_mapping(), and opd_put_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_handle_exec ( pid_t  tid,
pid_t  tgid 
)

opd_handle_exec - deal with notification of execve()

Parameters:
tid tid for this process
tgid tgid for this process

Drop all mapping information for the process.

Definition at line 286 of file opd_proc.c.

References opd_proc::name, opd_get_proc(), opd_kill_maps(), opd_new_proc(), verbprintf, and vmisc.

Referenced by opd_do_notes().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_handle_exit ( struct op_note const *  note  ) 

opd_handle_exit - deal with exit notification

Parameters:
note note to handle

Deal with an exit() notification by setting the flag "dead" on a process. These will be later cleaned up by the SIGALRM handler.

sample->pid contains the process id of the exited process.

Definition at line 317 of file opd_proc.c.

References opd_proc::accessed, opd_proc::dead, opd_get_proc(), op_note::pid, op_note::tgid, verbprintf, and vmisc.

Referenced by opd_do_notes().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_handle_fork ( struct op_note const *  note  ) 

opd_handle_fork - deal with fork notification

Parameters:
note note to handle

Deal with a fork() notification by creating a new process structure, and copying mapping information from the old process.

sample->pid contains the process id of the old process. sample->eip contains the process id of the new process.

Definition at line 238 of file opd_proc.c.

References op_note::addr, opd_map::end, opd_map::image, opd_image::kernel, op_note::len, list_entry, list_for_each, opd_proc::maps, opd_proc::name, opd_image::name, opd_map::next, opd_map::offset, opd_add_mapping(), opd_get_image(), opd_get_proc(), opd_new_proc(), op_note::pid, separate_thread, opd_map::start, op_note::tgid, verbprintf, and vmisc.

Referenced by opd_do_notes().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_init_procs ( void   ) 

initialize opd_proc container

Definition at line 42 of file opd_proc.c.

References list_init(), OPD_MAX_PROC_HASH, and opd_procs.

Referenced by opd_24_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static int opd_lookup_maps ( struct opd_proc proc,
struct op_sample const *  sample 
) [static]

opd_lookup_maps - lookup a proc mappings for a sample

Parameters:
proc proc to lookup
sample sample to lookup

iterate through the proc maps searching the mapping which owns sample if sucessful sample count will be updated and we return non-zero

Definition at line 164 of file opd_proc.c.

References opd_proc::accessed, op_sample::counter, op_sample::eip, opd_map::image, list_entry, list_for_each, opd_proc::maps, opd_map::next, opd_map::offset, opd_24_stats, opd_is_in_map(), OPD_MAP_ARRAY_ACCESS, OPD_MAP_ARRAY_DEPTH, opd_map_offset(), OPD_PROCESS, opd_put_image_sample(), and verb_show_sample().

Referenced by opd_put_sample().

Here is the call graph for this function:

Here is the caller graph for this function:

struct opd_proc* opd_new_proc ( pid_t  tid,
pid_t  tgid 
) [read]

opd_new_proc - create a new process structure

Parameters:
tid tid for this process
tgid tgid for this process

Allocate and initialise a process structure and insert it into the procs hash table.

Definition at line 68 of file opd_proc.c.

References opd_proc::accessed, opd_proc::dead, list_add(), list_init(), opd_proc::maps, opd_proc::name, opd_proc::next, nr_procs, opd_procs, proc_hash(), opd_proc::tgid, and opd_proc::tid.

Referenced by opd_get_ascii_procs(), opd_handle_exec(), opd_handle_fork(), and opd_handle_mapping().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_proc_cleanup ( void   ) 

freeze all resource used by opd_procs managment

Definition at line 375 of file opd_proc.c.

References opd_delete_proc(), and opd_for_each_proc().

Referenced by opd_24_exit().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_put_image_sample ( struct opd_image image,
unsigned long  offset,
u32  counter 
)

opd_put_image_sample - write sample to file

Parameters:
image image for sample
offset (file) offset to write to
counter counter number

Add to the count stored at position offset in the image file. Overflow pins the count at the maximum value.

Definition at line 122 of file opd_proc.c.

References cpu_number, opd_image::ignored, odb_open_count(), odb_update_node(), OP_MAX_COUNTERS, opd_24_sfile_lru(), opd_24_stats, OPD_LOST_SAMPLEFILE, opd_open_24_sample_file(), opd_24_sfile::sample_file, and opd_image::sfiles.

Referenced by opd_handle_kernel_sample(), opd_handle_module_sample(), and opd_lookup_maps().

Here is the call graph for this function:

Here is the caller graph for this function:

void opd_put_sample ( struct op_sample const *  sample  ) 

opd_put_sample - process a sample

Parameters:
sample sample to process

Write out the sample to the appropriate sample file. This routine handles kernel and module samples as well as ordinary ones.

Definition at line 190 of file opd_proc.c.

References op_sample::counter, op_sample::eip, no_vmlinux, opd_24_stats, opd_add_kernel_map(), opd_eip_is_kernel(), opd_get_proc(), opd_handle_kernel_sample(), opd_lookup_maps(), OPD_LOST_MAP_PROCESS, OPD_LOST_PROCESS, OPD_SAMPLES, op_sample::pid, separate_kernel, op_sample::tgid, verbprintf, vmisc, and vsamples.

Referenced by opd_do_samples(), and opd_process_samples().

Here is the call graph for this function:

Here is the caller graph for this function:

static void opd_remove_kernel_mapping ( struct opd_proc proc  )  [static]

opd_remove_kernel_mapping - remove all kernel mapping for an opd_proc

Parameters:
proc proc where mappings must be updated.

invalidate (by removing them) all kernel mapping. This function do nothing when separate_kernel == 0 because we don't add mapping for kernel sample in proc struct.

Definition at line 414 of file opd_proc.c.

References opd_map::image, list_del(), list_entry, list_for_each_safe, opd_proc::maps, opd_map::next, opd_map::offset, opd_delete_image(), opd_eip_is_kernel(), and opd_map::start.

Referenced by opd_clear_kernel_mapping().

Here is the call graph for this function:

Here is the caller graph for this function:

static uint proc_hash ( pid_t  tid  )  [inline, static]

proc_hash - hash pid value

Parameters:
tid pid value to hash

Definition at line 61 of file opd_proc.c.

References OPD_MAX_PROC_HASH.

Referenced by opd_get_proc(), and opd_new_proc().

Here is the caller graph for this function:

static void verb_show_sample ( unsigned long  offset,
struct opd_map map 
) [inline, static]

verb_show_sample - print the sample out to the log

Parameters:
offset the offset value
map map to print

Definition at line 113 of file opd_proc.c.

References opd_map::end, opd_map::image, opd_image::name, opd_map::offset, opd_map::start, verbprintf, and vsamples.

Referenced by opd_lookup_maps().

Here is the caller graph for this function:


Variable Documentation

Definition at line 41 of file init.c.

Referenced by opd_do_samples(), and opd_put_image_sample().

int nr_procs [static]

Definition at line 39 of file opd_proc.c.

Referenced by opd_delete_proc(), opd_get_nr_procs(), and opd_new_proc().

struct list_head opd_procs[OPD_MAX_PROC_HASH] [static]

Definition at line 36 of file opd_proc.c.

Referenced by opd_for_each_proc(), opd_get_proc(), opd_init_procs(), and opd_new_proc().


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1