|
PAPI
5.0.1.0
|
A component for the luster filesystem. More...

Go to the source code of this file.
Definition in file linux-lustre.c.
Definition at line 58 of file linux-lustre.c.
| #define LUSTRE_MAX_COUNTERS 100 |
Definition at line 57 of file linux-lustre.c.
Definition at line 61 of file linux-lustre.c.
| typedef counter_info LUSTRE_reg_alloc_t |
Definition at line 62 of file linux-lustre.c.
| typedef counter_info LUSTRE_register_t |
Definition at line 60 of file linux-lustre.c.
| int _lustre_ctl | ( | hwd_context_t * | ctx, |
| int | code, | ||
| _papi_int_option_t * | option | ||
| ) |
Definition at line 621 of file linux-lustre.c.
{
( void ) ctx;
( void ) code;
( void ) option;
return PAPI_OK;
}
| int _lustre_init_component | ( | ) |
Definition at line 401 of file linux-lustre.c.
{
int ret = PAPI_OK;
/* See if lustre filesystem exists */
ret=detect_lustre();
if (ret!=PAPI_OK) {
strncpy(_lustre_vector.cmp_info.disabled_reason,
"No lustre filesystems found",PAPI_MAX_STR_LEN);
return ret;
}
ret=init_lustre_counters();
_lustre_vector.cmp_info.num_native_events=num_events;
return ret;
}

| int _lustre_init_control_state | ( | hwd_control_state_t * | ctl | ) |
Definition at line 466 of file linux-lustre.c.
{
LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
memset(lustre_ctl->start_count,0,sizeof(long long)*LUSTRE_MAX_COUNTERS);
memset(lustre_ctl->current_count,0,sizeof(long long)*LUSTRE_MAX_COUNTERS);
return PAPI_OK;
}
| int _lustre_init_thread | ( | hwd_context_t * | ctx | ) |
Definition at line 429 of file linux-lustre.c.
{
(void) ctx;
return PAPI_OK;
}
| int _lustre_ntv_code_to_descr | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 683 of file linux-lustre.c.
{
int event=EventCode;
if (event >=0 && event < num_events) {
strncpy( name, lustre_native_table[event]->description, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
| int _lustre_ntv_code_to_name | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 666 of file linux-lustre.c.
{
int event=EventCode;
if (event >=0 && event < num_events) {
strncpy( name, lustre_native_table[event]->name, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
| int _lustre_ntv_enum_events | ( | unsigned int * | EventCode, |
| int | modifier | ||
| ) |
Definition at line 700 of file linux-lustre.c.
{
if ( modifier == PAPI_ENUM_FIRST ) {
if (num_events==0) return PAPI_ENOEVNT;
*EventCode = 0;
return PAPI_OK;
}
if ( modifier == PAPI_ENUM_EVENTS ) {
int index = *EventCode;
if ( lustre_native_table[index + 1] ) {
*EventCode = *EventCode + 1;
return PAPI_OK;
} else {
return PAPI_ENOEVNT;
}
}
return PAPI_EINVAL;
}
| int _lustre_read | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl, | ||
| long long ** | events, | ||
| int | flags | ||
| ) |
Definition at line 556 of file linux-lustre.c.
{
(void) ctx;
( void ) flags;
LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
int i;
read_lustre_counter( );
for(i=0;i<lustre_ctl->num_events;i++) {
lustre_ctl->current_count[i]=
lustre_native_table[lustre_ctl->which_counter[i]]->value;
lustre_ctl->difference[i]=lustre_ctl->current_count[i]-
lustre_ctl->start_count[i];
}
*events = lustre_ctl->difference;
return PAPI_OK;
}

| int _lustre_reset | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl | ||
| ) |
Definition at line 587 of file linux-lustre.c.
{
/* re-initializes counter_start values to current */
_lustre_start(ctx,ctrl);
return PAPI_OK;
}

| int _lustre_set_domain | ( | hwd_control_state_t * | cntrl, |
| int | domain | ||
| ) |
Definition at line 642 of file linux-lustre.c.
{
( void ) cntrl;
int found = 0;
if ( PAPI_DOM_USER & domain ) {
found = 1;
}
if ( PAPI_DOM_KERNEL & domain ) {
found = 1;
}
if ( PAPI_DOM_OTHER & domain ) {
found = 1;
}
if ( !found )
return PAPI_EINVAL;
return PAPI_OK;
}
| int _lustre_shutdown_component | ( | void | ) |
Definition at line 441 of file linux-lustre.c.
{
host_finalize( );
return PAPI_OK;
}

| int _lustre_shutdown_thread | ( | hwd_context_t * | ctx | ) |
Definition at line 453 of file linux-lustre.c.
{
( void ) ctx;
return PAPI_OK;
}
| int _lustre_start | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 506 of file linux-lustre.c.
{
( void ) ctx;
LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
int i;
read_lustre_counter( );
for(i=0;i<lustre_ctl->num_events;i++) {
lustre_ctl->current_count[i]=
lustre_native_table[lustre_ctl->which_counter[i]]->value;
}
memcpy( lustre_ctl->start_count,
lustre_ctl->current_count,
LUSTRE_MAX_COUNTERS * sizeof ( long long ) );
return PAPI_OK;
}


| int _lustre_stop | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctl | ||
| ) |
Definition at line 532 of file linux-lustre.c.
{
(void) ctx;
LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
int i;
read_lustre_counter( );
for(i=0;i<lustre_ctl->num_events;i++) {
lustre_ctl->current_count[i]=
lustre_native_table[lustre_ctl->which_counter[i]]->value;
}
return PAPI_OK;
}

| int _lustre_update_control_state | ( | hwd_control_state_t * | ctl, |
| NativeInfo_t * | native, | ||
| int | count, | ||
| hwd_context_t * | ctx | ||
| ) |
Definition at line 481 of file linux-lustre.c.
{
LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
( void ) ctx;
int i, index;
for ( i = 0; i < count; i++ ) {
index = native[i].ni_event;
lustre_ctl->which_counter[i]=index;
native[i].ni_position = i;
}
lustre_ctl->num_events=count;
return PAPI_OK;
}
| int _lustre_write | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl, | ||
| long long * | from | ||
| ) |
Definition at line 602 of file linux-lustre.c.
{
( void ) ctx;
( void ) ctrl;
( void ) from;
return PAPI_OK;
}
| static counter_info* addCounter | ( | const char * | name, |
| const char * | desc, | ||
| const char * | unit | ||
| ) | [static] |
add a counter to the list of available counters
| name | the short name of the counter |
| desc | a longer description |
| unit | the unit for this counter |
Definition at line 103 of file linux-lustre.c.
{
counter_info *cntr;
cntr = malloc( sizeof ( counter_info ) );
if ( cntr == NULL ) {
SUBDBG("can not allocate memory for new counter\n" );
return NULL;
}
cntr->idx=num_events;
cntr->name = strdup( name );
cntr->description = strdup( desc );
cntr->unit = strdup( unit );
cntr->value = 0;
lustre_native_table[num_events]=cntr;
num_events++;
return cntr;
}

| static int addLustreFS | ( | const char * | name, |
| const char * | procpath_general, | ||
| const char * | procpath_readahead | ||
| ) | [static] |
adds a Lustre fs to the fs list and creates the counters for it
| name | fs name |
| procpath_general | path to the 'stats' file in /proc/fs/lustre/... for this fs |
| procpath_readahead | path to the 'readahead' file in /proc/fs/lustre/... for this fs |
Definition at line 134 of file linux-lustre.c.
{
lustre_fs *fs, *last;
char counter_name[512];
FILE *fff;
SUBDBG("Adding lustre fs\n");
fs = malloc( sizeof ( lustre_fs ) );
if ( fs == NULL ) {
SUBDBG("can not allocate memory for new Lustre FS description\n" );
return PAPI_ENOMEM;
}
fs->proc_file=strdup(procpath_general);
fff = fopen( procpath_general, "r" );
if ( fff == NULL ) {
SUBDBG("can not open '%s'\n", procpath_general );
free(fs);
return PAPI_ESYS;
}
fclose(fff);
fs->proc_file_readahead = strdup(procpath_readahead);
fff = fopen( procpath_readahead, "r" );
if ( fff == NULL ) {
SUBDBG("can not open '%s'\n", procpath_readahead );
free(fs);
return PAPI_ESYS;
}
fclose(fff);
sprintf( counter_name, "%s_llread", name );
fs->read_cntr = addCounter( counter_name,
"bytes read on this lustre client",
"bytes" );
sprintf( counter_name, "%s_llwrite", name );
fs->write_cntr = addCounter( counter_name,
"bytes written on this lustre client",
"bytes" );
sprintf( counter_name, "%s_wrong_readahead", name );
fs->readahead_cntr = addCounter( counter_name,
"bytes read but discarded due to readahead",
"bytes" );
fs->next = NULL;
/* Insert into the linked list */
/* Does this need locking? */
if ( root_lustre_fs == NULL ) {
root_lustre_fs = fs;
} else {
last = root_lustre_fs;
while ( last->next != NULL )
last = last->next;
last->next = fs;
}
free(fs);
return PAPI_OK;
}


| static int detect_lustre | ( | ) | [static] |
see if lustre filesystem is supported by kernel
Definition at line 373 of file linux-lustre.c.
{
char lustre_directory[BUFSIZ];
DIR *proc_dir;
sprintf(lustre_directory,"%s/llite",proc_base_path);
proc_dir = opendir( proc_base_path );
if ( proc_dir == NULL ) {
SUBDBG("we are not able to read %s\n",lustre_directory);
return PAPI_ESYS;
}
closedir(proc_dir);
return PAPI_OK;
}

| static void host_finalize | ( | void | ) | [static] |
frees all allocated resources
Definition at line 338 of file linux-lustre.c.
{
int i;
lustre_fs *fs, *next_fs;
counter_info *cntr;
for(i=0;i<num_events;i++) {
cntr=lustre_native_table[i];
if ( cntr != NULL ) {
free( cntr->name );
free( cntr->description );
free( cntr->unit );
free( cntr );
}
lustre_native_table[i]=NULL;
}
fs = root_lustre_fs;
while ( fs != NULL ) {
next_fs = fs->next;
free(fs->proc_file);
free(fs->proc_file_readahead);
free( fs );
fs = next_fs;
}
root_lustre_fs = NULL;
}

| static int init_lustre_counters | ( | void | ) | [static] |
goes through proc and tries to discover all mounted Lustre fs
Definition at line 206 of file linux-lustre.c.
{
char lustre_dir[PATH_MAX];
char path[PATH_MAX];
char path_readahead[PATH_MAX],path_stats[PATH_MAX];
char *ptr;
char fs_name[100];
int idx = 0;
int tmp_fd;
DIR *proc_dir;
struct dirent *entry;
sprintf(lustre_dir,"%s/llite",proc_base_path);
proc_dir = opendir( lustre_dir );
if ( proc_dir == NULL ) {
SUBDBG("Cannot open %s\n",lustre_dir);
return PAPI_ESYS;
}
entry = readdir( proc_dir );
while ( entry != NULL ) {
memset( path, 0, PATH_MAX );
snprintf( path, PATH_MAX - 1, "%s/%s/stats", lustre_dir,
entry->d_name );
SUBDBG("checking for file %s\n", path);
if ( ( tmp_fd = open( path, O_RDONLY ) ) != -1 ) {
close( tmp_fd );
/* erase \r and \n at the end of path */
/* why is this necessary? */
idx = strlen( path );
idx--;
while ( path[idx] == '\r' || path[idx] == '\n' )
path[idx--] = 0;
/* Lustre paths are of type server-UUID */
idx = 0;
ptr = strstr(path,"llite/") + 6;
while ( *ptr && *ptr != '-' && idx < 100 ) {
fs_name[idx] = *ptr;
ptr++;
idx++;
}
SUBDBG("found Lustre FS: %s\n", fs_name);
snprintf( path_stats, PATH_MAX - 1,
"%s/%s/stats",
lustre_dir,
entry->d_name );
SUBDBG("Found file %s\n", path_stats);
snprintf( path_readahead, PATH_MAX - 1,
"%s/%s/read_ahead_stats",
lustre_dir,
entry->d_name );
SUBDBG("Now checking for file %s\n", path_readahead);
strcpy( ptr, "read_ahead_stats" );
addLustreFS( fs_name, path_stats, path_readahead );
}
entry = readdir( proc_dir );
}
closedir( proc_dir );
return PAPI_OK;
}


| static void read_lustre_counter | ( | ) | [static] |
updates all Lustre related counters
Definition at line 289 of file linux-lustre.c.
{
lustre_fs *fs = root_lustre_fs;
FILE *fff;
char buffer[BUFSIZ];
while ( fs != NULL ) {
/* read values from stats file */
fff=fopen(fs->proc_file,"r" );
if (fff != NULL) {
while(1) {
if (fgets(buffer,BUFSIZ,fff)==NULL) break;
if (strstr( buffer, "write_bytes" )) {
sscanf(buffer,"%*s %*d %*s %*s %*d %*d %lld",&fs->write_cntr->value);
SUBDBG("Read %lld write_bytes\n",fs->write_cntr->value);
}
if (strstr( buffer, "read_bytes" )) {
sscanf(buffer,"%*s %*d %*s %*s %*d %*d %lld",&fs->read_cntr->value);
SUBDBG("Read %lld read_bytes\n",fs->read_cntr->value);
}
}
fclose(fff);
}
fff=fopen(fs->proc_file_readahead,"r");
if (fff != NULL) {
while(1) {
if (fgets(buffer,BUFSIZ,fff)==NULL) break;
if (strstr( buffer, "read but discarded")) {
sscanf(buffer,"%*s %*s %*s %lld",&fs->readahead_cntr->value);
SUBDBG("Read %lld discared\n",fs->readahead_cntr->value);
break;
}
}
fclose(fff);
}
fs = fs->next;
}
}

Definition at line 90 of file linux-lustre.c.
counter_info* lustre_native_table[100] [static] |
Definition at line 84 of file linux-lustre.c.
int num_events = 0 [static] |
Definition at line 85 of file linux-lustre.c.
| const char proc_base_path[] = "/proc/fs/lustre/" |
Definition at line 81 of file linux-lustre.c.
lustre_fs* root_lustre_fs = NULL [static] |
Definition at line 88 of file linux-lustre.c.