lkml.org 
[lkml]   [2002]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Enhanced profiling support (was Re: vm lock contention reduction)

Sorry, the attachment never made it ...

===================================================
Karim Yaghmour
karim@opersys.com
Embedded and Real-Time Linux Expert
===================================================/* Example usage of custom event API */

#define MODULE

#if 0
#define CONFIG_TRACE
#endif

#include <linux/config.h>
#include <linux/module.h>
#include <linux/trace.h>
#include <asm/string.h>

struct delta_event
{
int an_int;
char a_char;
};

static int alpha_id, omega_id, theta_id, delta_id, rho_id;

int init_module(void)
{
uint8_t a_byte;
char a_char;
int an_int;
int a_hex;
char* a_string = "We are initializing the module";
struct delta_event a_delta_event;

/* Create events */
alpha_id = trace_create_event("Alpha",
"Number %d, String %s, Hex %08X",
CUSTOM_EVENT_FORMAT_TYPE_STR,
NULL);
omega_id = trace_create_event("Omega",
"Number %d, Char %c",
CUSTOM_EVENT_FORMAT_TYPE_STR,
NULL);
theta_id = trace_create_event("Theta",
"Plain string",
CUSTOM_EVENT_FORMAT_TYPE_STR,
NULL);
delta_id = trace_create_event("Delta",
NULL,
CUSTOM_EVENT_FORMAT_TYPE_HEX,
NULL);
rho_id = trace_create_event("Rho",
NULL,
CUSTOM_EVENT_FORMAT_TYPE_HEX,
NULL);

/* Trace events */
an_int = 1;
a_hex = 0xFFFFAAAA;
trace_std_formatted_event(alpha_id, an_int, a_string, a_hex);
an_int = 25;
a_char = 'c';
trace_std_formatted_event(omega_id, an_int, a_char);
trace_std_formatted_event(theta_id);
memset(&a_delta_event, 0, sizeof(a_delta_event));
trace_raw_event(delta_id, sizeof(a_delta_event), &a_delta_event);
a_byte = 0x12;
trace_raw_event(rho_id, sizeof(a_byte), &a_byte);

return 0;
}

void cleanup_module(void)
{
uint8_t a_byte;
char a_char;
int an_int;
int a_hex;
char* a_string = "We are initializing the module";
struct delta_event a_delta_event;

/* Trace events */
an_int = 324;
a_hex = 0xABCDEF10;
trace_std_formatted_event(alpha_id, an_int, a_string, a_hex);
an_int = 789;
a_char = 's';
trace_std_formatted_event(omega_id, an_int, a_char);
trace_std_formatted_event(theta_id);
memset(&a_delta_event, 0xFF, sizeof(a_delta_event));
trace_raw_event(delta_id, sizeof(a_delta_event), &a_delta_event);
a_byte = 0xA4;
trace_raw_event(rho_id, sizeof(a_byte), &a_byte);

/* Destroy the events created */
trace_destroy_event(alpha_id);
trace_destroy_event(omega_id);
trace_destroy_event(theta_id);
trace_destroy_event(delta_id);
trace_destroy_event(rho_id);
}

\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.069 / U:1.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site