30typedef struct counter_info_struct
47typedef struct lustre_fs_struct
54 struct lustre_fs_struct *
next;
57#define LUSTRE_MAX_COUNTERS 100
58#define LUSTRE_MAX_COUNTER_TERMS LUSTRE_MAX_COUNTERS
65typedef struct LUSTRE_control_state
75typedef struct LUSTRE_context
82const char proc_base_path[] =
"./components/lustre/fake_proc/fs/lustre/";
104 if (NULL==new_table) {
105 SUBDBG(
"EXIT: PAPI_ENOMEM\n");
114 SUBDBG(
"EXIT: PAPI_OK\n");
127 SUBDBG(
"ENTER: name: %s, desc: %s, unit: %s\n",
name, desc, unit);
133 SUBDBG(
"EXIT: can not resize native table\n" );
139 if ( cntr == NULL ) {
140 SUBDBG(
"EXIT: can not allocate memory for new counter\n" );
147 cntr->
unit = strdup( unit );
154SUBDBG(
"EXIT: cntr: %p\n", cntr);
166 const char *procpath_general,
167 const char *procpath_readahead )
170 char counter_name[512];
173 SUBDBG(
"Adding lustre fs\n");
177 SUBDBG(
"can not allocate memory for new Lustre FS description\n" );
182 fff = fopen( procpath_general,
"r" );
184 SUBDBG(
"can not open '%s'\n", procpath_general );
192 fff = fopen( procpath_readahead,
"r" );
194 SUBDBG(
"can not open '%s'\n", procpath_readahead );
202 sprintf( counter_name,
"%s_llread",
name );
204 "bytes read on this lustre client",
212 sprintf( counter_name,
"%s_llwrite",
name );
214 "bytes written on this lustre client",
223 sprintf( counter_name,
"%s_wrong_readahead",
name );
225 "bytes read but discarded due to readahead",
260 char lustre_dir[PATH_MAX];
262 char path_readahead[PATH_MAX],path_stats[PATH_MAX];
265 int found_luster_fs = 0;
269 struct dirent *entry;
273 proc_dir = opendir( lustre_dir );
274 if ( proc_dir == NULL ) {
275 SUBDBG(
"EXIT: PAPI_ESYS (Cannot open %s)\n",lustre_dir);
279 while ( (entry = readdir( proc_dir )) != NULL ) {
280 memset( path, 0, PATH_MAX );
281 snprintf( path, PATH_MAX - 1,
"%s/%s/stats", lustre_dir,
283 SUBDBG(
"checking for file %s\n", path);
285 if ( ( tmp_fd =
open( path, O_RDONLY ) ) == -1 ) {
286 SUBDBG(
"Path: %s, can not be opened.\n", path);
295 idx = strlen( path );
298 while ( path[idx] ==
'\r' || path[idx] ==
'\n' )
303 ptr = strstr(path,
"llite/") + 6;
305 SUBDBG(
"Path: %s, missing llite directory, performance event not created.\n", path);
309 strncpy(fs_name, ptr,
sizeof(fs_name)-1);
310 fs_name[
sizeof(fs_name)-1] =
'\0';
312 SUBDBG(
"found Lustre FS: %s\n", fs_name);
314 snprintf( path_stats, PATH_MAX - 1,
318 SUBDBG(
"Found file %s\n", path_stats);
320 snprintf( path_readahead, PATH_MAX - 1,
321 "%s/%s/read_ahead_stats",
324 SUBDBG(
"Now checking for file %s\n", path_readahead);
326 strcpy( ptr,
"read_ahead_stats" );
327 addLustreFS( fs_name, path_stats, path_readahead );
330 closedir( proc_dir );
332 if (found_luster_fs == 0) {
333 SUBDBG(
"EXIT: PAPI_ESYS (No luster file systems found)\n");
337 SUBDBG(
"EXIT: PAPI_OK\n");
351 while ( fs != NULL ) {
357 if (fgets(buffer,BUFSIZ,
fff)==NULL)
break;
359 if (strstr( buffer,
"write_bytes" )) {
364 if (strstr( buffer,
"read_bytes" )) {
365 sscanf(buffer,
"%*s %*d %*s %*s %*d %*d %llu",&fs->
read_cntr->
value);
375 if (fgets(buffer,BUFSIZ,
fff)==NULL)
break;
377 if (strstr( buffer,
"read but discarded")) {
402 if ( cntr != NULL ) {
418 while ( fs != NULL ) {
452 SUBDBG(
"EXIT: ret: %d\n", ret);
461 SUBDBG(
"EXIT: ret: %d\n", ret);
532 SUBDBG(
"ENTER: ctl: %p, native: %p, count: %d, ctx: %p\n", ctl,
native,
count, ctx);
544 SUBDBG(
"EXIT: PAPI_OK\n");
604 long long **
events,
int flags )
698 SUBDBG(
"EXIT: PAPI_OK\n");
709 SUBDBG(
"ENTER: EventCode: %#x, name: %p, len: %d\n", EventCode,
name, len);
718 SUBDBG(
"EXIT: PAPI_ENOEVNT\n");
729 SUBDBG(
"ENTER: EventCode: %#x, name: %p, len: %d\n", EventCode,
name, len);
738 SUBDBG(
"EXIT: PAPI_ENOEVNT\n");
749 SUBDBG(
"ENTER: EventCode: %p, modifier: %d\n", EventCode, modifier);
754 SUBDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
759 int index = *EventCode;
762 *EventCode = *EventCode + 1;
763 SUBDBG(
"EXIT: *EventCode: %#x\n", *EventCode);
766 SUBDBG(
"EXIT: PAPI_ENOEVNT\n");
772 SUBDBG(
"EXIT: PAPI_EINVAL\n");
784 .short_name =
"lustre",
786 .description =
"Lustre filesystem statistics",
795 .fast_real_timer = 0,
796 .fast_virtual_timer = 0,
798 .attach_must_ptrace = 0,
int open(const char *pathname, int flags, mode_t mode)
struct papi_vectors * _papi_hwd[]
char events[MAX_EVENTS][BUFSIZ]
static struct temp_event * last
static int _lustre_shutdown_component(void)
static void host_finalize(void)
static void read_lustre_counter()
static counter_info * addCounter(const char *name, const char *desc, const char *unit)
static int _lustre_init_component(int cidx)
static int _lustre_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
static int _lustre_reset(hwd_context_t *ctx, hwd_control_state_t *ctrl)
static int init_lustre_counters(void)
static int _lustre_stop(hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _lustre_init_control_state(hwd_control_state_t *ctl)
papi_vector_t _lustre_vector
static lustre_fs * root_lustre_fs
const char proc_base_path[]
static int _lustre_set_domain(hwd_control_state_t *cntrl, int domain)
static int addLustreFS(const char *name, const char *procpath_general, const char *procpath_readahead)
static int _lustre_ntv_enum_events(unsigned int *EventCode, int modifier)
static int resize_native_table()
#define LUSTRE_MAX_COUNTERS
static int _lustre_shutdown_thread(hwd_context_t *ctx)
static int _lustre_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
static int _lustre_update_control_state(hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
static int _lustre_init_thread(hwd_context_t *ctx)
static int _lustre_start(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)
counter_info LUSTRE_native_event_entry_t
counter_info LUSTRE_register_t
counter_info LUSTRE_reg_alloc_t
static int _lustre_ntv_code_to_name(unsigned int EventCode, char *name, int len)
static counter_info ** lustre_native_table
Return codes and api definitions.
#define SUBDBG(format, args...)
int fclose(FILE *__stream)
#define papi_calloc(a, b)
LUSTRE_control_state_t state
long long current_count[LUSTRE_MAX_COUNTERS]
long long start_count[LUSTRE_MAX_COUNTERS]
long long difference[LUSTRE_MAX_COUNTERS]
int which_counter[LUSTRE_MAX_COUNTERS]
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char * proc_file_readahead
struct lustre_fs_struct * next
counter_info * readahead_cntr
counter_info * write_cntr
PAPI_component_info_t cmp_info