PAPI  5.7.0.0
linux-lustre.c File Reference

A component for the luster filesystem. More...

Include dependency graph for linux-lustre.c:

Go to the source code of this file.

Data Structures

struct  STEALTIME_reg_alloc_t
 
struct  string_list
 
struct  lustre_fs
 
struct  LUSTRE_control_state_t
 
struct  LUSTRE_context_t
 

Macros

#define LUSTRE_MAX_COUNTERS   100
 
#define LUSTRE_MAX_COUNTER_TERMS   LUSTRE_MAX_COUNTERS
 

Typedefs

typedef counter_info LUSTRE_register_t
 
typedef counter_info LUSTRE_native_event_entry_t
 
typedef counter_info LUSTRE_reg_alloc_t
 

Functions

static int resize_native_table ()
 
static counter_infoaddCounter (const char *name, const char *desc, const char *unit)
 
static int addLustreFS (const char *name, const char *procpath_general, const char *procpath_readahead)
 
static int init_lustre_counters (void)
 
static void read_lustre_counter ()
 
static void host_finalize (void)
 
static int _lustre_init_component (int cidx)
 
static int _lustre_init_thread (hwd_context_t *ctx)
 
static int _lustre_shutdown_component (void)
 
static int _lustre_shutdown_thread (hwd_context_t *ctx)
 
static int _lustre_init_control_state (hwd_control_state_t *ctl)
 
static int _lustre_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
static int _lustre_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _lustre_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int _lustre_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
 
static int _lustre_reset (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
static int _lustre_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
static int _lustre_set_domain (hwd_control_state_t *cntrl, int domain)
 
static int _lustre_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
static int _lustre_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
static int _lustre_ntv_enum_events (unsigned int *EventCode, int modifier)
 

Variables

const char proc_base_path [] = "/proc/fs/lustre/"
 
static counter_info ** lustre_native_table = NULL
 
static int num_events = 0
 
static int table_size = 32
 
static lustre_fsroot_lustre_fs = NULL
 
papi_vector_t _lustre_vector
 

Detailed Description

Author
Haihang You (in collaboration with Michael Kluge, TU Dresden) you@e.nosp@m.ecs..nosp@m.utk.e.nosp@m.du
Heike Jagode jagod.nosp@m.e@ee.nosp@m.cs.ut.nosp@m.k.ed.nosp@m.u
Vince Weaver vweav.nosp@m.er1@.nosp@m.eecs..nosp@m.utk..nosp@m.edu

Definition in file linux-lustre.c.

Macro Definition Documentation

◆ LUSTRE_MAX_COUNTER_TERMS

#define LUSTRE_MAX_COUNTER_TERMS   LUSTRE_MAX_COUNTERS

Definition at line 58 of file linux-lustre.c.

◆ LUSTRE_MAX_COUNTERS

#define LUSTRE_MAX_COUNTERS   100

Definition at line 57 of file linux-lustre.c.

Typedef Documentation

◆ LUSTRE_native_event_entry_t

Definition at line 61 of file linux-lustre.c.

◆ LUSTRE_reg_alloc_t

Definition at line 62 of file linux-lustre.c.

◆ LUSTRE_register_t

Definition at line 60 of file linux-lustre.c.

Function Documentation

◆ _lustre_ctl()

static int _lustre_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)
static

Definition at line 666 of file linux-lustre.c.

667 {
668  ( void ) ctx;
669  ( void ) code;
670  ( void ) option;
671 
672  return PAPI_OK;
673 }
#define PAPI_OK
Definition: fpapi.h:105

◆ _lustre_init_component()

static int _lustre_init_component ( int  cidx)
static

Definition at line 443 of file linux-lustre.c.

444 {
445  SUBDBG("ENTER:\n");
446  int ret = PAPI_OK;
447 
450  if (ret!=PAPI_OK) {
452  "No lustre filesystems found",PAPI_MAX_STR_LEN);
453  host_finalize(); // cleanup.
454  SUBDBG("EXIT: ret: %d\n", ret);
455  return ret;
456  }
457 
460 
461  SUBDBG("EXIT: ret: %d\n", ret);
462  return ret;
463 }
#define PAPI_OK
Definition: fpapi.h:105
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:637
papi_vector_t _lustre_vector
Definition: linux-lustre.c:94
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
static int cidx
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int num_events
Definition: linux-lustre.c:88
long long ret
Definition: iozone.c:1346
static void host_finalize(void)
Definition: linux-lustre.c:396
static int init_lustre_counters(void)
Definition: linux-lustre.c:257
static int resize_native_table()
Definition: linux-lustre.c:99
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
Here is the call graph for this function:

◆ _lustre_init_control_state()

static int _lustre_init_control_state ( hwd_control_state_t ctl)
static

Definition at line 510 of file linux-lustre.c.

511 {
512  LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
513 
514  memset(lustre_ctl->start_count,0,sizeof(long long)*LUSTRE_MAX_COUNTERS);
515  memset(lustre_ctl->current_count,0,sizeof(long long)*LUSTRE_MAX_COUNTERS);
516 
517  return PAPI_OK;
518 }
#define PAPI_OK
Definition: fpapi.h:105
#define LUSTRE_MAX_COUNTERS
Definition: linux-lustre.c:57
long long current_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:68
long long start_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:67

◆ _lustre_init_thread()

static int _lustre_init_thread ( hwd_context_t ctx)
static

Definition at line 473 of file linux-lustre.c.

474 {
475  (void) ctx;
476 
477  return PAPI_OK;
478 }
#define PAPI_OK
Definition: fpapi.h:105

◆ _lustre_ntv_code_to_descr()

static int _lustre_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)
static

Definition at line 725 of file linux-lustre.c.

726 {
727  SUBDBG("ENTER: EventCode: %#x, name: %p, len: %d\n", EventCode, name, len);
728  int event=EventCode;
729 
730  if (event >=0 && event < num_events) {
731  strncpy( name, lustre_native_table[event]->description, len-1 );
732  name[len-1] = '\0';
733  SUBDBG("EXIT: description: %s\n", name);
734  return PAPI_OK;
735  }
736  SUBDBG("EXIT: PAPI_ENOEVNT\n");
737  return PAPI_ENOEVNT;
738 }
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int num_events
Definition: linux-lustre.c:88
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
#define PAPI_ENOEVNT
Definition: fpapi.h:112

◆ _lustre_ntv_code_to_name()

static int _lustre_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)
static

Definition at line 705 of file linux-lustre.c.

706 {
707  SUBDBG("ENTER: EventCode: %#x, name: %p, len: %d\n", EventCode, name, len);
708  int event=EventCode;
709 
710  if (event >=0 && event < num_events) {
711  strncpy( name, lustre_native_table[event]->name, len-1 );
712  name[len-1] = '\0';
713  SUBDBG("EXIT: event name: %s\n", name);
714  return PAPI_OK;
715  }
716  SUBDBG("EXIT: PAPI_ENOEVNT\n");
717  return PAPI_ENOEVNT;
718 }
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int num_events
Definition: linux-lustre.c:88
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
#define PAPI_ENOEVNT
Definition: fpapi.h:112

◆ _lustre_ntv_enum_events()

static int _lustre_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)
static

Definition at line 745 of file linux-lustre.c.

746 {
747  SUBDBG("ENTER: EventCode: %p, modifier: %d\n", EventCode, modifier);
748 
749  if ( modifier == PAPI_ENUM_FIRST ) {
750  if (num_events==0) return PAPI_ENOEVNT;
751  *EventCode = 0;
752  SUBDBG("EXIT: *EventCode: %#x\n", *EventCode);
753  return PAPI_OK;
754  }
755 
756  if ( modifier == PAPI_ENUM_EVENTS ) {
757  int index = *EventCode;
758 
759  if ((index+1 < num_events) && lustre_native_table[index + 1]) {
760  *EventCode = *EventCode + 1;
761  SUBDBG("EXIT: *EventCode: %#x\n", *EventCode);
762  return PAPI_OK;
763  } else {
764  SUBDBG("EXIT: PAPI_ENOEVNT\n");
765  return PAPI_ENOEVNT;
766  }
767  }
768 
769 
770  SUBDBG("EXIT: PAPI_EINVAL\n");
771  return PAPI_EINVAL;
772 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_EINVAL
Definition: fpapi.h:106
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int num_events
Definition: linux-lustre.c:88
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
#define PAPI_ENOEVNT
Definition: fpapi.h:112

◆ _lustre_read()

static int _lustre_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
)
static

Definition at line 601 of file linux-lustre.c.

603 {
604  (void) ctx;
605  ( void ) flags;
606 
607  LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
608  int i;
609 
611 
612  for(i=0;i<lustre_ctl->num_events;i++) {
613  lustre_ctl->current_count[i]=
614  lustre_native_table[lustre_ctl->which_counter[i]]->value;
615  lustre_ctl->difference[i]=lustre_ctl->current_count[i]-
616  lustre_ctl->start_count[i];
617  }
618 
619  *events = lustre_ctl->difference;
620 
621  return PAPI_OK;
622 
623 }
#define PAPI_OK
Definition: fpapi.h:105
long long difference[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:69
char events[MAX_EVENTS][BUFSIZ]
int which_counter[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:70
long long current_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:68
long long start_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:67
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
static void read_lustre_counter()
Definition: linux-lustre.c:347
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _lustre_reset()

static int _lustre_reset ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)
static

Definition at line 632 of file linux-lustre.c.

633 {
634 
635  /* re-initializes counter_start values to current */
636 
637  _lustre_start(ctx,ctrl);
638 
639  return PAPI_OK;
640 }
#define PAPI_OK
Definition: fpapi.h:105
static int _lustre_start(hwd_context_t *ctx, hwd_control_state_t *ctl)
Definition: linux-lustre.c:551
Here is the call graph for this function:

◆ _lustre_set_domain()

static int _lustre_set_domain ( hwd_control_state_t cntrl,
int  domain 
)
static

Definition at line 688 of file linux-lustre.c.

689 {
690  ( void ) cntrl;
691  ( void ) domain;
692  SUBDBG("ENTER: \n");
693 
694  // this component does not allow limiting which domains will increment event counts
695 
696  SUBDBG("EXIT: PAPI_OK\n");
697  return PAPI_OK;
698 }
#define PAPI_OK
Definition: fpapi.h:105
#define SUBDBG(format, args...)
Definition: papi_debug.h:63

◆ _lustre_shutdown_component()

static int _lustre_shutdown_component ( void  )
static

Definition at line 485 of file linux-lustre.c.

486 {
487  SUBDBG("ENTER:\n");
488  host_finalize( );
489  SUBDBG("EXIT:\n");
490  return PAPI_OK;
491 }
#define PAPI_OK
Definition: fpapi.h:105
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static void host_finalize(void)
Definition: linux-lustre.c:396
Here is the call graph for this function:

◆ _lustre_shutdown_thread()

static int _lustre_shutdown_thread ( hwd_context_t ctx)
static

Definition at line 497 of file linux-lustre.c.

498 {
499  ( void ) ctx;
500 
501  return PAPI_OK;
502 }
#define PAPI_OK
Definition: fpapi.h:105

◆ _lustre_start()

static int _lustre_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 551 of file linux-lustre.c.

552 {
553  ( void ) ctx;
554 
555  LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
556  int i;
557 
559 
560  for(i=0;i<lustre_ctl->num_events;i++) {
561  lustre_ctl->current_count[i]=
562  lustre_native_table[lustre_ctl->which_counter[i]]->value;
563  }
564 
565  memcpy( lustre_ctl->start_count,
566  lustre_ctl->current_count,
567  LUSTRE_MAX_COUNTERS * sizeof ( long long ) );
568 
569  return PAPI_OK;
570 }
#define PAPI_OK
Definition: fpapi.h:105
int which_counter[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:70
#define LUSTRE_MAX_COUNTERS
Definition: linux-lustre.c:57
long long current_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:68
long long start_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:67
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
static void read_lustre_counter()
Definition: linux-lustre.c:347
int i
Definition: fileop.c:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _lustre_stop()

static int _lustre_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 577 of file linux-lustre.c.

578 {
579 
580  (void) ctx;
581  LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
582  int i;
583 
585 
586  for(i=0;i<lustre_ctl->num_events;i++) {
587  lustre_ctl->current_count[i]=
588  lustre_native_table[lustre_ctl->which_counter[i]]->value;
589  }
590 
591  return PAPI_OK;
592 
593 }
#define PAPI_OK
Definition: fpapi.h:105
int which_counter[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:70
long long current_count[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:68
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
static void read_lustre_counter()
Definition: linux-lustre.c:347
int i
Definition: fileop.c:140
Here is the call graph for this function:

◆ _lustre_update_control_state()

static int _lustre_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)
static

Definition at line 525 of file linux-lustre.c.

529 {
530  SUBDBG("ENTER: ctl: %p, native: %p, count: %d, ctx: %p\n", ctl, native, count, ctx);
531  LUSTRE_control_state_t *lustre_ctl = (LUSTRE_control_state_t *)ctl;
532  ( void ) ctx;
533  int i, index;
534 
535  for ( i = 0; i < count; i++ ) {
536  index = native[i].ni_event;
537  lustre_ctl->which_counter[i]=index;
538  native[i].ni_position = i;
539  }
540 
541  lustre_ctl->num_events=count;
542  SUBDBG("EXIT: PAPI_OK\n");
543  return PAPI_OK;
544 }
#define PAPI_OK
Definition: fpapi.h:105
int which_counter[LUSTRE_MAX_COUNTERS]
Definition: linux-lustre.c:70
static int native
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static long count
int i
Definition: fileop.c:140

◆ addCounter()

static counter_info* addCounter ( const char *  name,
const char *  desc,
const char *  unit 
)
static

add a counter to the list of available counters

Parameters
namethe short name of the counter
desca longer description
unitthe unit for this counter

Definition at line 125 of file linux-lustre.c.

126 {
127  SUBDBG("ENTER: name: %s, desc: %s, unit: %s\n", name, desc, unit);
128 
129  counter_info *cntr;
130 
131  if ( num_events >= table_size )
132  if (PAPI_OK != resize_native_table()) {
133  SUBDBG("EXIT: can not resize native table\n" );
134  return NULL;
135  }
136 
137  cntr = malloc( sizeof ( counter_info ) );
138 
139  if ( cntr == NULL ) {
140  SUBDBG("EXIT: can not allocate memory for new counter\n" );
141  return NULL;
142  }
143 
144  cntr->idx=num_events;
145  cntr->name = strdup( name );
146  cntr->description = strdup( desc );
147  cntr->unit = strdup( unit );
148  cntr->value = 0;
149 
151 
152  num_events++;
153 
154 SUBDBG("EXIT: cntr: %p\n", cntr);
155  return cntr;
156 }
#define PAPI_OK
Definition: fpapi.h:105
static const char * name
Definition: fork_overflow.c:31
static int table_size
Definition: linux-lustre.c:89
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static int num_events
Definition: linux-lustre.c:88
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
static int resize_native_table()
Definition: linux-lustre.c:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addLustreFS()

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

Parameters
namefs name
procpath_generalpath to the 'stats' file in /proc/fs/lustre/... for this fs
procpath_readaheadpath to the 'readahead' file in /proc/fs/lustre/... for this fs

Definition at line 165 of file linux-lustre.c.

168 {
169  lustre_fs *fs, *last;
170  char counter_name[512];
171  FILE *fff;
172 
173  SUBDBG("Adding lustre fs\n");
174 
175  fs = malloc( sizeof ( lustre_fs ) );
176  if ( fs == NULL ) {
177  SUBDBG("can not allocate memory for new Lustre FS description\n" );
178  return PAPI_ENOMEM;
179  }
180 
181  fs->proc_file=strdup(procpath_general);
182  fff = fopen( procpath_general, "r" );
183  if ( fff == NULL ) {
184  SUBDBG("can not open '%s'\n", procpath_general );
185  free(fs->proc_file); // strdup.
186  free(fs); // malloc.
187  return PAPI_ESYS;
188  }
189  fclose(fff);
190 
191  fs->proc_file_readahead = strdup(procpath_readahead);
192  fff = fopen( procpath_readahead, "r" );
193  if ( fff == NULL ) {
194  SUBDBG("can not open '%s'\n", procpath_readahead );
195  free(fs->proc_file_readahead); // strdup.
196  free(fs->proc_file); // strdup.
197  free(fs); // malloc.
198  return PAPI_ESYS;
199  }
200  fclose(fff);
201 
202  sprintf( counter_name, "%s_llread", name );
203  if (NULL == (fs->read_cntr = addCounter( counter_name,
204  "bytes read on this lustre client",
205  "bytes" ))) {
206  free(fs->proc_file_readahead); // strdup.
207  free(fs->proc_file); // strdup.
208  free(fs); // malloc.
209  return PAPI_ENOMEM;
210  }
211 
212  sprintf( counter_name, "%s_llwrite", name );
213  if ( NULL == (fs->write_cntr = addCounter( counter_name,
214  "bytes written on this lustre client",
215  "bytes" ))) {
216  free(fs->read_cntr);
217  free(fs->proc_file_readahead); // strdup.
218  free(fs->proc_file); // strdup.
219  free(fs); // malloc.
220  return PAPI_ENOMEM;
221  }
222 
223  sprintf( counter_name, "%s_wrong_readahead", name );
224  if ( NULL == (fs->readahead_cntr = addCounter( counter_name,
225  "bytes read but discarded due to readahead",
226  "bytes" ))) {
227  free(fs->read_cntr);
228  free(fs->write_cntr);
229  free(fs->proc_file_readahead); // strdup.
230  free(fs->proc_file); // strdup.
231  free(fs); // malloc.
232  return PAPI_ENOMEM;
233  }
234 
235  fs->next = NULL;
236 
237  /* Insert into the linked list */
238  /* Does this need locking? */
239  if ( root_lustre_fs == NULL ) {
240  root_lustre_fs = fs;
241  } else {
243 
244  while ( last->next != NULL )
245  last = last->next;
246 
247  last->next = fs;
248  }
249  return PAPI_OK;
250 }
#define PAPI_OK
Definition: fpapi.h:105
struct lustre_fs_struct * next
Definition: linux-lustre.c:54
static counter_info * addCounter(const char *name, const char *desc, const char *unit)
Definition: linux-lustre.c:125
#define PAPI_ENOMEM
Definition: fpapi.h:107
static const char * name
Definition: fork_overflow.c:31
char * proc_file_readahead
Definition: linux-lustre.c:50
counter_info * read_cntr
Definition: linux-lustre.c:52
char * proc_file
Definition: linux-lustre.c:49
FILE * fff[MAX_EVENTS]
struct temp_event * next
#define PAPI_ESYS
Definition: fpapi.h:108
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
counter_info * write_cntr
Definition: linux-lustre.c:51
static struct temp_event * last
static lustre_fs * root_lustre_fs
Definition: linux-lustre.c:92
counter_info * readahead_cntr
Definition: linux-lustre.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_finalize()

static void host_finalize ( void  )
static

frees all allocated resources

Definition at line 396 of file linux-lustre.c.

397 {
398  int i;
399  lustre_fs *fs, *next_fs;
400  counter_info *cntr;
401 
402  for(i=0;i<num_events;i++) {
403  cntr=lustre_native_table[i];
404  if ( cntr != NULL ) {
405  free( cntr->name );
406  free( cntr->description );
407  free( cntr->unit );
408  free( cntr );
409  }
410  lustre_native_table[i]=NULL;
411  }
412 
413  papi_free(lustre_native_table); // Free the table itself.
414  lustre_native_table = NULL; // clear the pointer.
415  num_events = 0;
416  table_size = 32;
417 
418  fs = root_lustre_fs;
419 
420  while ( fs != NULL ) {
421  next_fs = fs->next;
422  free(fs->read_cntr);
423  free(fs->write_cntr);
424  free(fs->proc_file_readahead); // strdup.
425  free(fs->proc_file); // strdup.
426  free(fs); // malloc.
427  fs = next_fs;
428  }
429 
430  root_lustre_fs = NULL;
431 }
struct lustre_fs_struct * next
Definition: linux-lustre.c:54
#define papi_free(a)
Definition: papi_memory.h:35
char * proc_file_readahead
Definition: linux-lustre.c:50
counter_info * read_cntr
Definition: linux-lustre.c:52
static int table_size
Definition: linux-lustre.c:89
char * proc_file
Definition: linux-lustre.c:49
counter_info * write_cntr
Definition: linux-lustre.c:51
static int num_events
Definition: linux-lustre.c:88
static lustre_fs * root_lustre_fs
Definition: linux-lustre.c:92
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
int i
Definition: fileop.c:140
Here is the caller graph for this function:

◆ init_lustre_counters()

static int init_lustre_counters ( void  )
static

goes through proc and tries to discover all mounted Lustre fs

Definition at line 257 of file linux-lustre.c.

258 {
259  SUBDBG("ENTER:\n");
260  char lustre_dir[PATH_MAX];
261  char path[PATH_MAX];
262  char path_readahead[PATH_MAX],path_stats[PATH_MAX];
263  char *ptr;
264  char fs_name[100];
265  int found_luster_fs = 0;
266  int idx = 0;
267  int tmp_fd;
268  DIR *proc_dir;
269  struct dirent *entry;
270 
271  sprintf(lustre_dir,"%s/llite",proc_base_path);
272 
273  proc_dir = opendir( lustre_dir );
274  if ( proc_dir == NULL ) {
275  SUBDBG("EXIT: PAPI_ESYS (Cannot open %s)\n",lustre_dir);
276  return PAPI_ESYS;
277  }
278 
279  while ( (entry = readdir( proc_dir )) != NULL ) {
280  memset( path, 0, PATH_MAX );
281  snprintf( path, PATH_MAX - 1, "%s/%s/stats", lustre_dir,
282  entry->d_name );
283  SUBDBG("checking for file %s\n", path);
284 
285  if ( ( tmp_fd = open( path, O_RDONLY ) ) == -1 ) {
286  SUBDBG("Path: %s, can not be opened.\n", path);
287  continue;
288  }
289 
290  close( tmp_fd );
291 
292  /* erase \r and \n at the end of path */
293  /* why is this necessary? */
294 
295  idx = strlen( path );
296  idx--;
297 
298  while ( path[idx] == '\r' || path[idx] == '\n' )
299  path[idx--] = 0;
300 
301  /* Lustre paths are of type server-UUID */
302 
303  idx = 0;
304 
305  ptr = strstr(path,"llite/") + 6;
306  if (ptr == NULL) {
307  SUBDBG("Path: %s, missing llite directory, performance event not created.\n", path);
308  continue;
309  }
310 
311  strncpy(fs_name, ptr, sizeof(fs_name)-1);
312  fs_name[sizeof(fs_name)-1] = '\0';
313 
314  SUBDBG("found Lustre FS: %s\n", fs_name);
315 
316  snprintf( path_stats, PATH_MAX - 1,
317  "%s/%s/stats",
318  lustre_dir,
319  entry->d_name );
320  SUBDBG("Found file %s\n", path_stats);
321 
322  snprintf( path_readahead, PATH_MAX - 1,
323  "%s/%s/read_ahead_stats",
324  lustre_dir,
325  entry->d_name );
326  SUBDBG("Now checking for file %s\n", path_readahead);
327 
328  strcpy( ptr, "read_ahead_stats" );
329  addLustreFS( fs_name, path_stats, path_readahead );
330  found_luster_fs++;
331  }
332  closedir( proc_dir );
333 
334  if (found_luster_fs == 0) {
335  SUBDBG("EXIT: PAPI_ESYS (No luster file systems found)\n");
336  return PAPI_ESYS;
337  }
338 
339  SUBDBG("EXIT: PAPI_OK\n");
340  return PAPI_OK;
341 }
#define PAPI_OK
Definition: fpapi.h:105
int close(int fd)
Definition: appio.c:175
#define PAPI_ESYS
Definition: fpapi.h:108
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:184
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
const char proc_base_path[]
Definition: linux-lustre.c:84
#define PATH_MAX
Definition: fileop.c:68
static int addLustreFS(const char *name, const char *procpath_general, const char *procpath_readahead)
Definition: linux-lustre.c:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_lustre_counter()

static void read_lustre_counter ( )
static

updates all Lustre related counters

Definition at line 347 of file linux-lustre.c.

348 {
350  FILE *fff;
351  char buffer[BUFSIZ];
352 
353  while ( fs != NULL ) {
354 
355  /* read values from stats file */
356  fff=fopen(fs->proc_file,"r" );
357  if (fff != NULL) {
358  while(1) {
359  if (fgets(buffer,BUFSIZ,fff)==NULL) break;
360 
361  if (strstr( buffer, "write_bytes" )) {
362  sscanf(buffer,"%*s %*d %*s %*s %*d %*d %llu",&fs->write_cntr->value);
363  SUBDBG("Read %llu write_bytes\n",fs->write_cntr->value);
364  }
365 
366  if (strstr( buffer, "read_bytes" )) {
367  sscanf(buffer,"%*s %*d %*s %*s %*d %*d %llu",&fs->read_cntr->value);
368  SUBDBG("Read %llu read_bytes\n",fs->read_cntr->value);
369  }
370  }
371  fclose(fff);
372  }
373 
374  fff=fopen(fs->proc_file_readahead,"r");
375  if (fff != NULL) {
376  while(1) {
377  if (fgets(buffer,BUFSIZ,fff)==NULL) break;
378 
379  if (strstr( buffer, "read but discarded")) {
380  sscanf(buffer,"%*s %*s %*s %llu",&fs->readahead_cntr->value);
381  SUBDBG("Read %llu discared\n",fs->readahead_cntr->value);
382  break;
383  }
384  }
385  fclose(fff);
386  }
387  fs = fs->next;
388  }
389 }
struct lustre_fs_struct * next
Definition: linux-lustre.c:54
char * proc_file_readahead
Definition: linux-lustre.c:50
counter_info * read_cntr
Definition: linux-lustre.c:52
char * proc_file
Definition: linux-lustre.c:49
FILE * fff[MAX_EVENTS]
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
counter_info * write_cntr
Definition: linux-lustre.c:51
char * buffer
Definition: iozone.c:1366
static lustre_fs * root_lustre_fs
Definition: linux-lustre.c:92
counter_info * readahead_cntr
Definition: linux-lustre.c:53
Here is the caller graph for this function:

◆ resize_native_table()

static int resize_native_table ( )
static

Definition at line 99 of file linux-lustre.c.

99  {
100  SUBDBG("ENTER:\n");
101  counter_info** new_table;
102  int new_size = table_size*2;
103  new_table = (counter_info**)papi_calloc(new_size, sizeof(counter_info*));
104  if (NULL==new_table) {
105  SUBDBG("EXIT: PAPI_ENOMEM\n");
106  return PAPI_ENOMEM;
107  }
108  if ( lustre_native_table) {
109  memcpy(new_table, lustre_native_table, sizeof(counter_info*) * table_size );
111  }
112  lustre_native_table = new_table;
113  table_size*=2;
114  SUBDBG("EXIT: PAPI_OK\n");
115  return PAPI_OK;
116 }
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_ENOMEM
Definition: fpapi.h:107
#define papi_free(a)
Definition: papi_memory.h:35
static int table_size
Definition: linux-lustre.c:89
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
static counter_info ** lustre_native_table
Definition: linux-lustre.c:87
#define papi_calloc(a, b)
Definition: papi_memory.h:37
Here is the caller graph for this function:

Variable Documentation

◆ _lustre_vector

papi_vector_t _lustre_vector

Definition at line 94 of file linux-lustre.c.

◆ lustre_native_table

counter_info** lustre_native_table = NULL
static

Definition at line 87 of file linux-lustre.c.

◆ num_events

int num_events = 0
static

Definition at line 88 of file linux-lustre.c.

◆ proc_base_path

const char proc_base_path[] = "/proc/fs/lustre/"

Definition at line 84 of file linux-lustre.c.

◆ root_lustre_fs

lustre_fs* root_lustre_fs = NULL
static

Definition at line 92 of file linux-lustre.c.

◆ table_size

int table_size = 32
static

Definition at line 89 of file linux-lustre.c.