Latch, mutex and beyond

kernel_io_outlier.d

#!/usr/sbin/dtrace -ZCs
#pragma D option quiet 
inline long IO_OUTLIER_THRESHOLD= 524288000;

/*------------------------------------------------------------------------------*/
/* Oracle 12c database uses the following DTrace script for V$KERNEL_IO_OUTLIER  
   Oracle utilizes libdtrace(3LIB) interface to read aggregate data.

   Additional DTrace probes at end of this file allow the script run standalone 
     Usage:  ./kernel_io_outlier.d ORACLE_SID
/*------------------------------------------------------------------------------*/

syscall::pwrite:entry
/execname == "oracle" &&  substr(strtok(curpsinfo->pr_psargs, " "), -strlen($$1)) == $$1 
&& fds[arg0].fi_fs == "specfs" && strstr(fds[arg0].fi_pathname, "zfs") == NULL/
{
  self->in = 1;
  self->sz = arg2;
  self->wts = walltimestamp;
  self->ts = timestamp;
  self->off = arg3;
  self->dev = fds[arg0].fi_name;
}

io:::start
/self->in/
{
  self->iostartts = timestamp;
}

io:::wait-start
/self->in/
{
  self->wtstartts = timestamp;
}

io:::wait-done
/self->ts && self->wtstartts/
{
  self->wtendts = timestamp;
}

io:::wait-done
/self->ts && self->wtendts && (self->wtendts - self->wtstartts) > IO_OUTLIER_THRESHOLD /
{
  self->toobig = 1;
}

syscall::pwrite:return
/self->in && self->toobig/
{
  this->e2e = timestamp - self->ts;
  this->setup = self->iostartts - self->ts;
  this->queue = self->wtstartts - self->iostartts;
  this->txfr = self->wtendts - self->wtstartts;
  this->cleanup = timestamp - self->wtendts;
/*  @toobig[self->wts, self->dev, self->off, self->sz, this->e2e, this->setup,  this->queue, this->txfr, this->cleanup,  pid, curpsinfo->pr_psargs] = count();*/
  @toobig[self->wts/1000000000, self->sz/1024, self->off, self->dev, 
     curpsinfo->pr_psargs,  this->e2e/1000, this->setup/1000,  
     this->queue/1000, this->txfr/1000, this->cleanup/1000,  pid] = count();
  outlier=1;
}
syscall::pwrite:return
/self->in/
{
  self->in = 0;
  self->ts = 0;
  self->wts = 0;
  self->iostartts = 0;
  self->wtstartts = 0;
  self->wtendts = 0;
  self->sz = 0;
  self->off = 0;
  self->dev = 0;
  self->toobig = 0;
}

/*------------------------------------------------------------------------------*/
 
BEGIN
{ 
  outlier=0;
  printf(" TIMESTAMP    IO_SIZE  IO_OFFSET DEVICE_NAME     PROCESS_NAME    TOTAL_LATENCY SETUP_LATENCY QUEUE_TO_HBA_LATENCY TRANSFER_LATENCY CLEANUP_LATENCY      PID\n");
  printf("---------- ---------- ---------- --------------- --------------- ------------- ------------- -------------------- ---------------- --------------- --------\n");   
}

tick-3sec
/ outlier>0 /
{

  printa("%10d %10d %10d %15s %15s %13d %13d %20d %16d %15d %8d\n",@toobig);
  trunc(@toobig);
  outlier=0;
}

2 Comments »

  1. […] DTrace can do the same itself. Script kernel_io_oulier.d consist of original V$KERNEL_IO_OUTLIER script plus additional printing probes. It takes ORACLE_SID […]

    Pingback by V$KERNEL_IO_OUTLIER | Latch, mutex and beyond — September 20, 2013 @ 9:11 pm | Reply

  2. […] I have chosen Systemtap to simulate V$KERNEL_IO_OUTLIER on LINUX as it’s one of the more mature tool.So i am going here to write a monitoring  script  based on the script developed by Andrey Nikolaev : https://andreynikolaev.wordpress.com/tools/kernel_io_outlier-d/ […]

    Pingback by Simulating V$KERNEL_IO_OUTLIER on LINUX using Systemtap | Hatem Mahmoud Oracle's blog — February 25, 2015 @ 12:39 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.