appio.c File Reference

appio component This file contains the source code for a component that enables PAPI to access application level file and socket I/O information. It does this through function replacement in the first person and by trapping syscalls in the third person. More...

Include dependency graph for appio.c:

Go to the source code of this file.

Data Structures

struct  appio_counters

Enumerations

enum  _appio_stats_t {
  READ_BYTES = 0, READ_CALLS, READ_ERR, READ_INTERRUPTED,
  READ_WOULD_BLOCK, READ_SHORT, READ_EOF, READ_BLOCK_SIZE,
  READ_USEC, WRITE_BYTES, WRITE_CALLS, WRITE_ERR,
  WRITE_SHORT, WRITE_INTERRUPTED, WRITE_WOULD_BLOCK, WRITE_BLOCK_SIZE,
  WRITE_USEC, OPEN_CALLS, OPEN_ERR, OPEN_FDS,
  SELECT_USEC, RECV_BYTES, RECV_CALLS, RECV_ERR,
  RECV_INTERRUPTED, RECV_WOULD_BLOCK, RECV_SHORT, RECV_EOF,
  RECV_BLOCK_SIZE, RECV_USEC, SOCK_READ_BYTES, SOCK_READ_CALLS,
  SOCK_READ_ERR, SOCK_READ_SHORT, SOCK_READ_WOULD_BLOCK, SOCK_READ_USEC,
  SOCK_WRITE_BYTES, SOCK_WRITE_CALLS, SOCK_WRITE_ERR, SOCK_WRITE_SHORT,
  SOCK_WRITE_WOULD_BLOCK, SOCK_WRITE_USEC, SEEK_CALLS, SEEK_ABS_STRIDE_SIZE,
  SEEK_USEC
}

Functions

int __close (int fd)
int close (int fd)
int __open (const char *pathname, int flags, mode_t mode)
int open (const char *pathname, int flags, mode_t mode)
int __select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
off_t __lseek (int fd, off_t offset, int whence)
off_t lseek (int fd, off_t offset, int whence)
ssize_t __read (int fd, void *buf, size_t count)
ssize_t read (int fd, void *buf, size_t count)
size_t _IO_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
size_t fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
ssize_t __write (int fd, const void *buf, size_t count)
ssize_t write (int fd, const void *buf, size_t count)
size_t _IO_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
size_t fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
static int _appio_init_thread (hwd_context_t *ctx)
static int _appio_init_component (int cidx)
static int _appio_init_control_state (hwd_control_state_t *ctl)
static int _appio_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _appio_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags)
static int _appio_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _appio_shutdown_thread (hwd_context_t *ctx)
static int _appio_shutdown_component (void)
static int _appio_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
static int _appio_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx)
static int _appio_set_domain (hwd_control_state_t *ctl, int domain)
static int _appio_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
static int _appio_ntv_enum_events (unsigned int *EventCode, int modifier)
static int _appio_ntv_name_to_code (char *name, unsigned int *EventCode)
static int _appio_ntv_code_to_name (unsigned int EventCode, char *name, int len)
static int _appio_ntv_code_to_descr (unsigned int EventCode, char *desc, int len)
static int _appio_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)

Variables

papi_vector_t _appio_vector
static APPIO_native_event_entry_t_appio_native_events
static __thread long long _appio_register_current [APPIO_MAX_COUNTERS]
static struct appio_counters _appio_counter_info [APPIO_MAX_COUNTERS]
struct timeval zerotv
int errno

Detailed Description

Author:
Philip Mucci phil.mucci@samaratechnologygroup.com
Tushar Mohan tusharmohan@gmail.com

Credit to: Jose Pedro Oliveira jpo@di.uminho.pt whose code in the linux net component was used as a template for many sections of code in this component.

Definition in file appio.c.


Enumeration Type Documentation

Enumerator:
READ_BYTES 
READ_CALLS 
READ_ERR 
READ_INTERRUPTED 
READ_WOULD_BLOCK 
READ_SHORT 
READ_EOF 
READ_BLOCK_SIZE 
READ_USEC 
WRITE_BYTES 
WRITE_CALLS 
WRITE_ERR 
WRITE_SHORT 
WRITE_INTERRUPTED 
WRITE_WOULD_BLOCK 
WRITE_BLOCK_SIZE 
WRITE_USEC 
OPEN_CALLS 
OPEN_ERR 
OPEN_FDS 
SELECT_USEC 
RECV_BYTES 
RECV_CALLS 
RECV_ERR 
RECV_INTERRUPTED 
RECV_WOULD_BLOCK 
RECV_SHORT 
RECV_EOF 
RECV_BLOCK_SIZE 
RECV_USEC 
SOCK_READ_BYTES 
SOCK_READ_CALLS 
SOCK_READ_ERR 
SOCK_READ_SHORT 
SOCK_READ_WOULD_BLOCK 
SOCK_READ_USEC 
SOCK_WRITE_BYTES 
SOCK_WRITE_CALLS 
SOCK_WRITE_ERR 
SOCK_WRITE_SHORT 
SOCK_WRITE_WOULD_BLOCK 
SOCK_WRITE_USEC 
SEEK_CALLS 
SEEK_ABS_STRIDE_SIZE 
SEEK_USEC 

Definition at line 70 of file appio.c.


Function Documentation

int __close ( int  fd  ) 

Here is the caller graph for this function:

off_t __lseek ( int  fd,
off_t  offset,
int  whence 
)

Here is the caller graph for this function:

int __open ( const char *  pathname,
int  flags,
mode_t  mode 
)

Here is the caller graph for this function:

ssize_t __read ( int  fd,
void *  buf,
size_t  count 
)

Here is the caller graph for this function:

int __select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  timeout 
)

Here is the caller graph for this function:

ssize_t __write ( int  fd,
const void *  buf,
size_t  count 
)

Here is the caller graph for this function:

static int _appio_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
) [static]

Definition at line 553 of file appio.c.

00554 {
00555     ( void ) ctx;
00556     ( void ) code;
00557     ( void ) option;
00558 
00559     return PAPI_OK;
00560 }

static int _appio_init_component ( int  cidx  )  [static]

Definition at line 426 of file appio.c.

00427 {
00428 
00429     SUBDBG("_appio_component %d\n", cidx);
00430     _appio_native_events = (APPIO_native_event_entry_t *) papi_calloc(sizeof(APPIO_native_event_entry_t), APPIO_MAX_COUNTERS);
00431 
00432     if (_appio_native_events == NULL ) {
00433       PAPIERROR( "malloc():Could not get memory for events table" );
00434       return PAPI_ENOMEM;
00435     }
00436     int i;
00437     for (i=0; i<APPIO_MAX_COUNTERS; i++) {
00438       _appio_native_events[i].name = _appio_counter_info[i].name;
00439       _appio_native_events[i].description = _appio_counter_info[i].description;
00440       _appio_native_events[i].resources.selector = i + 1;
00441     }
00442   
00443     /* Export the total number of events available */
00444     _appio_vector.cmp_info.num_native_events = APPIO_MAX_COUNTERS;;
00445 
00446     /* Export the component id */
00447     _appio_vector.cmp_info.CmpIdx = cidx;
00448 
00449     return PAPI_OK;
00450 }

Here is the call graph for this function:

static int _appio_init_control_state ( hwd_control_state_t ctl  )  [static]

Definition at line 458 of file appio.c.

00459 {
00460     ( void ) ctl;
00461 
00462     return PAPI_OK;
00463 }

static int _appio_init_thread ( hwd_context_t ctx  )  [static]

Definition at line 413 of file appio.c.

00414 {
00415     ( void ) ctx;
00416     SUBDBG("_appio_init_thread %p\n", ctx);
00417     return PAPI_OK;
00418 }

static int _appio_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
) [static]

Definition at line 711 of file appio.c.

00712 {
00713     int index = EventCode;
00714 
00715     if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
00716         memcpy( ( APPIO_register_t * ) bits,
00717                 &( _appio_native_events[index].resources ),
00718                 sizeof ( APPIO_register_t ) );
00719         return PAPI_OK;
00720     }
00721 
00722     return PAPI_ENOEVNT;
00723 }

static int _appio_ntv_code_to_descr ( unsigned int  EventCode,
char *  desc,
int  len 
) [static]

Definition at line 694 of file appio.c.

00695 {
00696     int index = EventCode;
00697 
00698     if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
00699         strncpy(desc, _appio_counter_info[index].description, len );
00700         return PAPI_OK;
00701     }
00702 
00703     return PAPI_ENOEVNT;
00704 }

static int _appio_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
) [static]

Definition at line 677 of file appio.c.

00678 {
00679     int index = EventCode;
00680 
00681     if ( index >= 0 && index < APPIO_MAX_COUNTERS ) {
00682         strncpy( name, _appio_counter_info[index].name, len );
00683         return PAPI_OK;
00684     }
00685 
00686     return PAPI_ENOEVNT;
00687 }

static int _appio_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
) [static]

Definition at line 626 of file appio.c.

00627 {
00628     int index;
00629 
00630     switch ( modifier ) {
00631         case PAPI_ENUM_FIRST:
00632             *EventCode = 0;
00633             return PAPI_OK;
00634             break;
00635 
00636         case PAPI_ENUM_EVENTS:
00637             index = *EventCode;
00638             if ( index < APPIO_MAX_COUNTERS - 1 ) {
00639                 *EventCode = *EventCode + 1;
00640                 return PAPI_OK;
00641             } else {
00642                 return PAPI_ENOEVNT;
00643             }
00644             break;
00645 
00646         default:
00647             return PAPI_EINVAL;
00648             break;
00649     }
00650     return PAPI_EINVAL;
00651 }

static int _appio_ntv_name_to_code ( char *  name,
unsigned int *  EventCode 
) [static]

Definition at line 658 of file appio.c.

00659 {
00660     int i;
00661 
00662     for ( i=0; i<APPIO_MAX_COUNTERS; i++) {
00663         if (strcmp(name, _appio_counter_info[i].name) == 0) {
00664             *EventCode = i;
00665             return PAPI_OK;
00666         }
00667     }
00668 
00669     return PAPI_ENOEVNT;
00670 }

static int _appio_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  events,
int  flags 
) [static]

Definition at line 485 of file appio.c.

00487 {
00488     (void) flags;
00489     (void) ctx;
00490 
00491     SUBDBG("_appio_read %p %p\n", ctx, ctl);
00492     APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
00493     int i;
00494 
00495     for ( i=0; i<appio_ctl->num_events; i++ ) {
00496             int index = appio_ctl->counter_bits[i];
00497             SUBDBG("event=%d, index=%d, val=%lld\n", i, index, _appio_register_current[index]);
00498             appio_ctl->values[index] = _appio_register_current[index];
00499     }
00500     *events = appio_ctl->values;
00501 
00502     return PAPI_OK;
00503 }

static int _appio_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
) [static]

Definition at line 613 of file appio.c.

00614 {
00615     ( void ) ctx;
00616     ( void ) ctl;
00617 
00618     return PAPI_OK;
00619 }

static int _appio_set_domain ( hwd_control_state_t ctl,
int  domain 
) [static]

Definition at line 597 of file appio.c.

00598 {
00599     ( void ) ctl;
00600 
00601     int found = 0;
00602 
00603     if ( PAPI_DOM_USER == domain )   found = 1;
00604 
00605     if ( !found )
00606         return PAPI_EINVAL;
00607 
00608     return PAPI_OK;
00609 }

static int _appio_shutdown_component ( void   )  [static]

Definition at line 540 of file appio.c.

00541 {
00542     papi_free( _appio_native_events );
00543     return PAPI_OK;
00544 }

static int _appio_shutdown_thread ( hwd_context_t ctx  )  [static]

Definition at line 528 of file appio.c.

00529 {
00530     ( void ) ctx;
00531 
00532     return PAPI_OK;
00533 }

static int _appio_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
) [static]

Definition at line 467 of file appio.c.

00468 {
00469     ( void ) ctx;
00470 
00471     SUBDBG("_appio_start %p %p\n", ctx, ctl);
00472     APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
00473 
00474     /* this memset needs to move to thread_init */
00475     memset(_appio_register_current, 0, APPIO_MAX_COUNTERS * sizeof(_appio_register_current[0]));
00476 
00477     /* set initial values to 0 */
00478     memset(appio_ctl->values, 0, APPIO_MAX_COUNTERS*sizeof(appio_ctl->values[0]));
00479     
00480     return PAPI_OK;
00481 }

static int _appio_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
) [static]

Definition at line 507 of file appio.c.

00508 {
00509     (void) ctx;
00510 
00511     SUBDBG("_appio_stop ctx=%p ctl=%p\n", ctx, ctl);
00512     APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
00513     int i;
00514     for ( i=0; i<appio_ctl->num_events; i++ ) {
00515             int index = appio_ctl->counter_bits[i];
00516             SUBDBG("event=%d, index=%d, val=%lld\n", i, index, _appio_register_current[index]);
00517             appio_ctl->values[i] = _appio_register_current[index];
00518     }
00519 
00520     return PAPI_OK;
00521 }

static int _appio_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
) [static]

Definition at line 564 of file appio.c.

00566 {
00567     ( void ) ctx;
00568     ( void ) ctl;
00569 
00570     SUBDBG("_appio_update_control_state ctx=%p ctl=%p num_events=%d\n", ctx, ctl, count);
00571     int i, index;
00572     APPIO_control_state_t *appio_ctl = (APPIO_control_state_t *) ctl;
00573     (void) ctx;
00574 
00575     for ( i = 0; i < count; i++ ) {
00576         index = native[i].ni_event;
00577         appio_ctl->counter_bits[i] = index;
00578         native[i].ni_position = index;
00579     }
00580     appio_ctl->num_events = count;
00581 
00582     return PAPI_OK;
00583 }

size_t _IO_fread ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Here is the caller graph for this function:

size_t _IO_fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Here is the caller graph for this function:

int close ( int  fd  ) 

Definition at line 175 of file appio.c.

00175                   {
00176   int retval;
00177   SUBDBG("appio: intercepted close(%d)\n", fd);
00178   retval = __close(fd);
00179   if ((retval == 0) && (_appio_register_current[OPEN_FDS]>0)) _appio_register_current[OPEN_FDS]--;
00180   return retval;
00181 }

Here is the call graph for this function:

size_t fread ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Definition at line 275 of file appio.c.

00275                                                                  {
00276   size_t retval;
00277   SUBDBG("appio: intercepted fread(%p,%lu,%lu,%p)\n", ptr, (unsigned long) size, (unsigned long) nmemb, (void*) stream);
00278   long long start_ts = PAPI_get_real_usec();
00279   retval = _IO_fread(ptr,size,nmemb,stream);
00280   long long duration = PAPI_get_real_usec() - start_ts;
00281   int n = _appio_register_current[READ_CALLS]++; // read calls
00282   if (retval > 0) {
00283     _appio_register_current[READ_BLOCK_SIZE]= (n * _appio_register_current[READ_BLOCK_SIZE]+ size*nmemb)/(n+1);//mean size
00284     _appio_register_current[READ_BYTES]+= retval * size; // read bytes
00285     if (retval < nmemb) _appio_register_current[READ_SHORT]++; // read short
00286     _appio_register_current[READ_USEC] += duration;
00287   }
00288 
00289   /* A value of zero returned means one of two things..*/
00290   if (retval == 0) {
00291      if (feof(stream)) _appio_register_current[READ_EOF]++; // read eof
00292      else _appio_register_current[READ_ERR]++; // read err
00293   }
00294   return retval;
00295 }

Here is the call graph for this function:

Here is the caller graph for this function:

size_t fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Definition at line 387 of file appio.c.

00387                                                                         {
00388   size_t retval;
00389   SUBDBG("appio: intercepted fwrite(%p,%lu,%lu,%p)\n", ptr, (unsigned long) size, (unsigned long) nmemb, (void*) stream);
00390   long long start_ts = PAPI_get_real_usec();
00391   retval = _IO_fwrite(ptr,size,nmemb,stream);
00392   long long duration = PAPI_get_real_usec() - start_ts;
00393   int n = _appio_register_current[WRITE_CALLS]++; // write calls
00394   if (retval > 0) {
00395     _appio_register_current[WRITE_BLOCK_SIZE]= (n * _appio_register_current[WRITE_BLOCK_SIZE] + size*nmemb)/(n+1); // mean block size
00396     _appio_register_current[WRITE_BYTES]+= retval * size; // write bytes
00397     if (retval < nmemb) _appio_register_current[WRITE_SHORT]++; // short write
00398     _appio_register_current[WRITE_USEC] += duration;
00399   }
00400   if (retval == 0) _appio_register_current[WRITE_ERR]++; // err
00401   return retval;
00402 }

Here is the call graph for this function:

Here is the caller graph for this function:

off_t lseek ( int  fd,
off_t  offset,
int  whence 
)

Definition at line 210 of file appio.c.

00210                                               {
00211   off_t retval;
00212   SUBDBG("appio: intercepted lseek(%d,%ld,%d)\n", fd, offset, whence);
00213   long long start_ts = PAPI_get_real_usec();
00214   retval = __lseek(fd, offset, whence);
00215   long long duration = PAPI_get_real_usec() - start_ts;
00216   int n = _appio_register_current[SEEK_CALLS]++;
00217   _appio_register_current[SEEK_USEC] += duration;
00218   if (offset < 0) offset = -offset; // get abs offset
00219   _appio_register_current[SEEK_ABS_STRIDE_SIZE]= (n * _appio_register_current[SEEK_ABS_STRIDE_SIZE] + offset)/(n+1); // mean absolute stride size
00220   return retval;
00221 }

Here is the call graph for this function:

Here is the caller graph for this function:

int open ( const char *  pathname,
int  flags,
mode_t  mode 
)

Definition at line 184 of file appio.c.

00184                                                        {
00185   int retval;
00186   SUBDBG("appio: intercepted open(%s,%d,%d)\n", pathname, flags, mode);
00187   retval = __open(pathname,flags,mode);
00188   _appio_register_current[OPEN_CALLS]++;
00189   if (retval < 0) _appio_register_current[OPEN_ERR]++;
00190   else _appio_register_current[OPEN_FDS]++;
00191   return retval;
00192 }

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t read ( int  fd,
void *  buf,
size_t  count 
)

Definition at line 225 of file appio.c.

00225                                               {
00226   int retval;
00227   SUBDBG("appio: intercepted read(%d,%p,%lu)\n", fd, buf, (unsigned long)count);
00228 
00229   struct stat st;
00230   int issocket = 0;
00231   if (fstat(fd, &st) == 0) {
00232     if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
00233   }
00234   // check if read would block on descriptor
00235   fd_set readfds;
00236   FD_ZERO(&readfds);
00237   FD_SET(fd, &readfds);
00238   int ready = __select(fd+1, &readfds, NULL, NULL, &zerotv);
00239   if (ready == 0) {
00240      _appio_register_current[READ_WOULD_BLOCK]++; 
00241      if (issocket) _appio_register_current[SOCK_READ_WOULD_BLOCK]++; 
00242   }
00243 
00244   long long start_ts = PAPI_get_real_usec();
00245   retval = __read(fd,buf, count);
00246   long long duration = PAPI_get_real_usec() - start_ts;
00247   int n = _appio_register_current[READ_CALLS]++; // read calls
00248   if (issocket) _appio_register_current[SOCK_READ_CALLS]++; // read calls
00249   if (retval > 0) {
00250     _appio_register_current[READ_BLOCK_SIZE]= (n * _appio_register_current[READ_BLOCK_SIZE] + count)/(n+1); // mean size
00251     _appio_register_current[READ_BYTES] += retval; // read bytes
00252     if (issocket) _appio_register_current[SOCK_READ_BYTES] += retval;
00253     if (retval < (int)count) {
00254        _appio_register_current[READ_SHORT]++; // read short
00255        if (issocket) _appio_register_current[SOCK_READ_SHORT]++; // read short
00256     }
00257     _appio_register_current[READ_USEC] += duration;
00258     if (issocket) _appio_register_current[SOCK_READ_USEC] += duration;
00259   }
00260   if (retval < 0) { 
00261     _appio_register_current[READ_ERR]++; // read err
00262     if (issocket) _appio_register_current[SOCK_READ_ERR]++; // read err
00263     if (EINTR == errno)
00264       _appio_register_current[READ_INTERRUPTED]++; // signal interrupted the read
00265     //if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
00266     //  _appio_register_current[READ_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
00267     //  if (issocket) _appio_register_current[SOCK_READ_WOULD_BLOCK]++; //read would block on descriptor marked as non-blocking
00268     //}
00269   }
00270   if (retval == 0) _appio_register_current[READ_EOF]++; // read eof
00271   return retval;
00272 }

Here is the call graph for this function:

Here is the caller graph for this function:

int select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  timeout 
)

Definition at line 199 of file appio.c.

00199                                                                                                     {
00200   int retval;
00201   SUBDBG("appio: intercepted select(%d,%p,%p,%p,%p)\n", nfds,readfds,writefds,exceptfds,timeout);
00202   long long start_ts = PAPI_get_real_usec();
00203   retval = __select(nfds,readfds,writefds,exceptfds,timeout);
00204   long long duration = PAPI_get_real_usec() - start_ts;
00205   _appio_register_current[SELECT_USEC] += duration;
00206   return retval;
00207 }

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t write ( int  fd,
const void *  buf,
size_t  count 
)

Definition at line 298 of file appio.c.

00298                                                      {
00299   int retval;
00300   SUBDBG("appio: intercepted write(%d,%p,%lu)\n", fd, buf, (unsigned long)count);
00301   struct stat st;
00302   int issocket = 0;
00303   if (fstat(fd, &st) == 0) {
00304     if ((st.st_mode & S_IFMT) == S_IFSOCK) issocket = 1;
00305   }
00306 
00307   // check if write would block on descriptor
00308   fd_set writefds;
00309   FD_ZERO(&writefds);
00310   FD_SET(fd, &writefds);
00311   int ready = __select(fd+1, NULL, &writefds, NULL, &zerotv);
00312   if (ready == 0) {
00313     _appio_register_current[WRITE_WOULD_BLOCK]++; 
00314     if (issocket) _appio_register_current[SOCK_WRITE_WOULD_BLOCK]++; 
00315   }
00316 
00317   long long start_ts = PAPI_get_real_usec();
00318   retval = __write(fd,buf, count);
00319   long long duration = PAPI_get_real_usec() - start_ts;
00320   int n = _appio_register_current[WRITE_CALLS]++; // write calls
00321   if (issocket) _appio_register_current[SOCK_WRITE_CALLS]++; // socket write
00322   if (retval >= 0) {
00323     _appio_register_current[WRITE_BLOCK_SIZE]= (n * _appio_register_current[WRITE_BLOCK_SIZE] + count)/(n+1); // mean size
00324     _appio_register_current[WRITE_BYTES]+= retval; // write bytes
00325     if (issocket) _appio_register_current[SOCK_WRITE_BYTES] += retval;
00326     if (retval < (int)count) {
00327       _appio_register_current[WRITE_SHORT]++; // short write
00328       if (issocket) _appio_register_current[SOCK_WRITE_SHORT]++; 
00329     }
00330     _appio_register_current[WRITE_USEC] += duration;
00331     if (issocket) _appio_register_current[SOCK_WRITE_USEC] += duration;
00332   }
00333   if (retval < 0) {
00334     _appio_register_current[WRITE_ERR]++; // err
00335     if (issocket) _appio_register_current[SOCK_WRITE_ERR]++;
00336     if (EINTR == errno)
00337       _appio_register_current[WRITE_INTERRUPTED]++; // signal interrupted the op
00338     //if ((EAGAIN == errno) || (EWOULDBLOCK == errno)) {
00339     //  _appio_register_current[WRITE_WOULD_BLOCK]++; //op would block on descriptor marked as non-blocking
00340     //  if (issocket) _appio_register_current[SOCK_WRITE_WOULD_BLOCK]++;
00341     //}
00342   }
00343   return retval;
00344 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct appio_counters _appio_counter_info[APPIO_MAX_COUNTERS] [static]

Definition at line 65 of file appio.c.

__thread long long _appio_register_current[APPIO_MAX_COUNTERS] [static]

Definition at line 69 of file appio.c.

Definition at line 57 of file appio.c.

int errno
struct timeval zerotv

Definition at line 196 of file appio.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1