qos_prof.h File Reference

Function-level profiling utilities. More...

#include "qos_debug.h"
#include <string.h>

Go to the source code of this file.

Data Structures

struct  qos_profile_t
 Profile data that is allocated for each profiled function. More...

Defines

#define QOS_PROF_MAX_COUNTS   128
 Maximum number of functions that can be profiled.
#define QOS_PROF_NAME_SIZE   32
 Maximum length for the name of a profiled function, including string terminator.
#define prof_vars
 This must be added in the var declaration section of a profiled function.
#define prof_func()
 This must be the first statement of a profiled function.
#define prof_return(args...)   do { return args; } while (0)
#define prof_end()   do { } while (0)
#define prof_call(args...)   do { } while (0)

Functions

static void prof_dump (void)
static qos_profile_tprof_register (const char *name)

Detailed Description

Function-level profiling utilities.

This file contains utilities for function-level profiling in either user-space or kernel-space. For each profiled function, the number of invocations and the total time spent inside function code (comprising called functions) is collected.

The prof_dump() function may be used to dump a report on the profiled functions. When in US, this info goes to stderr, when in KS, it goes to printk or klogger, depending on configuration.

In order to enable profiling, the QOS_PROFILE macro must be defined.

Use of this module prescribes to add, for each function to be profiled, the var declaration statement prof_vars, a call to prof_func() at the begin of the function, and exiting from the function through prof_return().

Furthermore, profiled code needs to be linked with qos_profile.c.

The typical sample use is as follows:

   void f(int x) {
     ...
     prof_vars;
     ...
     prof_func();
     ....
     if (! condition)
       prof_return();
     ...
     prof_return();
   }

   int g(int x) {
     ...
     prof_vars;
     ...
     prof_func();
     ....
     if (! condition)
       prof_return(-1);
     ...
     prof_return(0);
   }

Definition in file qos_prof.h.


Define Documentation

#define prof_call ( args...   )     do { } while (0)

Definition at line 168 of file qos_prof.h.

 
#define prof_end (  )     do { } while (0)
 
#define prof_func (  ) 

This must be the first statement of a profiled function.

Definition at line 143 of file qos_prof.h.

Referenced by qsup_cleanup_server(), qsup_get_approved_bw(), qsup_set_required_bw(), rres_block_hook(), rres_cleanup_hook(), rres_fork_hook(), and rres_unblock_hook().

#define prof_return ( args...   )     do { return args; } while (0)

Definition at line 166 of file qos_prof.h.

Referenced by qsup_cleanup_server(), and qsup_get_approved_bw().

#define prof_vars

This must be added in the var declaration section of a profiled function.

Definition at line 127 of file qos_prof.h.

Referenced by qsup_cleanup_server(), qsup_get_approved_bw(), qsup_set_required_bw(), rres_block_hook(), rres_cleanup_hook(), rres_fork_hook(), and rres_unblock_hook().

#define QOS_PROF_MAX_COUNTS   128

Maximum number of functions that can be profiled.

Memory usage for profile data is statically fixed to QOS_PROF_MAX_COUNTS * sizeof(qos_profile_t)

Definition at line 74 of file qos_prof.h.

Referenced by prof_register().

#define QOS_PROF_NAME_SIZE   32

Maximum length for the name of a profiled function, including string terminator.

Definition at line 77 of file qos_prof.h.


Function Documentation

static void prof_dump ( void   )  [inline, static]

Definition at line 99 of file qos_prof.h.

static qos_profile_t* prof_register ( const char *  name  )  [inline, static]
Generated on Mon Aug 2 22:39:17 2010 for qosres by  doxygen 1.6.3