⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf_genplot.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
📖 第 1 页 / 共 3 页
字号:
	rnsec = (wrap_time % ctimer_ticks_per_sec)*1000000000L / ctimer_ticks_per_sec;		if (after_rpcc > before_rpcc)		rnsec += ((unsigned long)(after_rpcc-before_rpcc))*1000000000L / ctimer_ticks_per_sec;	else		rnsec += (((unsigned long)(0xffffffffL)) - ((unsigned long)(before_rpcc-after_rpcc))) 			* 1000000000L / ctimer_ticks_per_sec;	if ( rnsec >= 1000000000L) 	{		rsec += rnsec / 1000000000L;		rnsec %= 1000000000L;	}		/* if time is long by more than 28 secs and we a have wraps */	if (wraps && (rsec > (after.tv_sec - before.tv_sec)+28 ))	{		wraps--;		rsec = wrap_time / ctimer_ticks_per_sec;		rnsec = (wrap_time % ctimer_ticks_per_sec)*1000000000L / ctimer_ticks_per_sec;				if (after_rpcc > before_rpcc)			rnsec += ((unsigned long)(after_rpcc-before_rpcc))*1000000000L / ctimer_ticks_per_sec;		else			rnsec += (((unsigned long)(0xffffffffL)) - ((unsigned long)(before_rpcc-after_rpcc))) 				* 1000000000L / ctimer_ticks_per_sec;		if ( rnsec >= 1000000000L) 		{			rsec += rnsec / 1000000000L;			rnsec %= 1000000000L;		}	}			/* we may need to add another wrap_time if things boneheaded */	if ( (after.tv_sec - before.tv_sec ) > rsec+10 )	{		wrap_time = 0xffffffff;		rsec += wrap_time / ctimer_ticks_per_sec;		rnsec += (wrap_time % ctimer_ticks_per_sec)*1000000000L / ctimer_ticks_per_sec;		if ( rnsec >= 1000000000L) 		{			rsec += rnsec / 1000000000L;			rnsec %= 1000000000L;		}	}		after.tv_sec = rsec;	after.tv_usec = rnsec / 1000;	}  elapsed = after;  dev = &dkudev.dev;  nio = dev->read_svc_cnt + dev->write_svc_cnt + dev->other_svc_cnt;  total_tv = dev->total;  sec = (double)elapsed.tv_sec;  sec += (double)elapsed.tv_usec / (double)USEC_PER_SEC;  if (ccdt.ci_ios != nio) {    fprintf(stderr, "ERROR: ci_ios=%lu nio=%lu\n", ccdt.ci_ios, nio);    exit(1);  }  gook = 0;  rc = ioctl(dev_fd, CCDIOCUNCONFIG, &gook);  if (rc) {    perror("CCDIOCUNCONFIG");    exit(1);  }  *num_iosp = nio;  if (sec != (double)0.0)    *ios_per_secp = ((double)nio) / sec;  else    *ios_per_secp = (double)0.0;  *response_timep = (double)ccdt.ci_ticks;  *response_timep /= (double)ctimer_ticks_per_sec;  *response_timep *= (double)1000.0;  if (nio)    *response_timep /= (double)nio;  else    *response_timep = (double)0.0;  close(dev_fd);  before_idle_sec = before_idle_ts.tv_sec;  before_idle_sec += before_idle_ts.tv_nsec / 1000000000.0;  after_idle_sec = after_idle_ts.tv_sec;  after_idle_sec += after_idle_ts.tv_nsec / 1000000000.0;  idle_sec = after_idle_sec - before_idle_sec;  *cpu_utilp = (double)1.0 - (idle_sec / sec);  close(pdl_fd);  free(config);}static void kdo_run_script(  char       *cfg_name,  char       *script_name,  RF_uint64  *num_iosp,  double     *ios_per_secp,  double     *response_timep,  double     *cpu_utilp){  unsigned long before_rpcc, after_rpcc, ctimer_ticks_per_sec, rsec, rnsec;  double sec, before_idle_sec, after_idle_sec, idle_sec;  timespec_t before_idle_ts, after_idle_ts, idle_ts;  struct timeval before, after, total_tv, elapsed;  int dev_fd, rc, keep, pdl_fd;  dku_get_dev_t dkudev;  RF_Config_t *config;  RF_AccTotals_t acc;  dku_dev_t *dev;  RF_uint64 nio;  void *p;  *ios_per_secp = *response_timep = *cpu_utilp = 0.0;  *num_iosp = 0;  config = (RF_Config_t *)malloc(sizeof(RF_Config_t));  rc = rf_get_cpu_ticks_per_sec((long *)&ctimer_ticks_per_sec);  if (rc) {    perror("rf_get_cpu_ticks_per_sec");    exit(1);  }  pdl_fd = open("/dev/pdl", O_RDWR);  if (pdl_fd < 0) {    perror("pdl_fd");    exit(1);  }  dev_fd = open(kdevname, O_RDWR);  if (dev_fd < 0) {    perror(kdevname);    fprintf(stderr, "ERROR: could not open %s\n", kdevname);    exit(1);  }  rc = rf_MakeConfig(cfg_name, config);  if (rc) {    fprintf(stderr, "ERROR: rc=%d reading %s\n", rc, cfg_name);    exit(1);  }  p = config;  /*   * Shut down any old config.   * Ignore return val- if it's not configged, that's   * an error, but I don't care.   */  ioctl(dev_fd, RAIDFRAME_SHUTDOWN, NULL);  rc = ioctl(dev_fd, RAIDFRAME_CONFIGURE, &p);  if (rc) {    perror("RAIDFRAME_CONFIGURE");    exit(1);  }  /* turn on acctotals capture */  keep = 1;  rc = ioctl(dev_fd, RAIDFRAME_KEEP_ACCTOTALS, &keep);  if (rc) {    perror("RAIDFRAME_KEEP_ACCTOTALS");    exit(1);  }  sync(); sync(); sync();  rc = ioctl(dev_fd, SCSI_DKU_RESET_DEV);  if (rc) {    perror("SCSI_DKU_RESET_DEV");    exit(1);  }  rc = ioctl(dev_fd, RAIDFRAME_RESET_ACCTOTALS, NULL);  if (rc) {    perror("RAIDFRAME_RESET_ACCTOTALS");    exit(1);  }  rc = PDL_get_total_idle_time(pdl_fd, &before_idle_ts);  if (rc < 0) {    perror("PDL_get_total_idle_time");    exit(1);  }  before_rpcc = 0xffffffff & rf_rpcc();  gettimeofday(&before, 0);  play_trace(script_name, kdevname);  after_rpcc = 0xffffffff & rf_rpcc();  gettimeofday(&after, 0);  rc = PDL_get_total_idle_time(pdl_fd, &after_idle_ts);  if (rc < 0) {    perror("PDL_get_total_idle_time");    exit(1);  }  rc = ioctl(dev_fd, SCSI_DKU_DEV, &dkudev);  if (rc) {    perror("SCSI_DKU_DEV");    exit(1);  }  rc = ioctl(dev_fd, RAIDFRAME_GET_ACCTOTALS, &acc);  if (rc) {    perror("RAIDFRAME_GET_ACCTOTALS");    exit(1);  }  /*   * Dan's magic timing code   */	{	unsigned long wraps;	unsigned long wrap_time = ((unsigned long)0xffffffff);		wrap_time /= (ctimer_ticks_per_sec/100);	wraps = 100 * ((unsigned long) after.tv_sec - before.tv_sec);	wraps /= wrap_time;	if (wraps && ( after_rpcc <= before_rpcc ))		wraps--;		wrap_time = wraps * ((unsigned long)0xffffffff);		rsec = wrap_time / ctimer_ticks_per_sec;	rnsec = (wrap_time % ctimer_ticks_per_sec)*1000000000L / ctimer_ticks_per_sec;		if (after_rpcc > before_rpcc)		rnsec += ((unsigned long)(after_rpcc-before_rpcc))*1000000000L / ctimer_ticks_per_sec;	else		rnsec += (((unsigned long)(0xffffffffL)) - ((unsigned long)(before_rpcc-after_rpcc))) 			* 1000000000L / ctimer_ticks_per_sec;	if ( rnsec >= 1000000000L) 	{		rsec += rnsec / 1000000000L;		rnsec %= 1000000000L;	}		/* if time is long by more than 28 secs and we a have wraps */	if (wraps && (rsec > (after.tv_sec - before.tv_sec)+28 ))	{		wraps--;		rsec = wrap_time / ctimer_ticks_per_sec;		rnsec = (wrap_time % ctimer_ticks_per_sec)*1000000000L / ctimer_ticks_per_sec;				if (after_rpcc > before_rpcc)			rnsec += ((unsigned long)(after_rpcc-before_rpcc))*1000000000L / ctimer_ticks_per_sec;		else			rnsec += (((unsigned long)(0xffffffffL)) - ((unsigned long)(before_rpcc-after_rpcc))) 				* 1000000000L / ctimer_ticks_per_sec;		if ( rnsec >= 1000000000L) 		{			rsec += rnsec / 1000000000L;			rnsec %= 1000000000L;		}	}			/* we may need to add another wrap_time if things boneheaded */	if ( (after.tv_sec - before.tv_sec ) > rsec+10 )	{		wrap_time = 0xffffffff;		rsec += wrap_time / ctimer_ticks_per_sec;		rnsec += (wrap_time % ctimer_ticks_per_sec)*1000000000L / ctimer_ticks_per_sec;		if ( rnsec >= 1000000000L) 		{			rsec += rnsec / 1000000000L;			rnsec %= 1000000000L;		}	}		after.tv_sec = rsec;	after.tv_usec = rnsec / 1000;	}  elapsed = after;  dev = &dkudev.dev;  nio = dev->read_svc_cnt + dev->write_svc_cnt + dev->other_svc_cnt;  total_tv = dev->total;  sec = (double)elapsed.tv_sec;  sec += (double)elapsed.tv_usec / (double)USEC_PER_SEC;  if (acc.user_reccount != nio) {    fprintf(stderr, "ERROR: user_reccount=%lu nio=%lu\n", acc.user_reccount, nio);    exit(1);  }  rc = ioctl(dev_fd, RAIDFRAME_SHUTDOWN, NULL);  if (rc) {    perror("RAIDFRAME_SHUTDOWN");    exit(1);  }  *num_iosp = nio;  if (sec != (double)0.0)    *ios_per_secp = ((double)nio) / sec;  else    *ios_per_secp = (double)0.0;  *response_timep = (double)acc.total_us;  *response_timep /= (double)1000.0;  if (nio)    *response_timep /= (double)nio;  else    *response_timep = (double)0.0;  close(dev_fd);  before_idle_sec = before_idle_ts.tv_sec;  before_idle_sec += before_idle_ts.tv_nsec / 1000000000.0;  after_idle_sec = after_idle_ts.tv_sec;  after_idle_sec += after_idle_ts.tv_nsec / 1000000000.0;  idle_sec = after_idle_sec - before_idle_sec;  *cpu_utilp = (double)1.0 - (idle_sec / sec);  close(pdl_fd);  free(config);}#endif /* RF_CMU_PDL > 0 && !SIMULATE */static void do_run_script(  char       *cfg_name,  char       *script_name,  RF_uint64  *num_iosp,  double     *ios_per_secp,  double     *response_timep){  RF_ShutdownList_t *shutdownList;  RF_Config_t *config;  RF_Raid_t *raidPtr;  int rc;  config = (RF_Config_t *)malloc(sizeof(RF_Config_t));  if (config == NULL) {    fprintf(stderr, "ERROR: could not allocate config\n");    exit(1);  }  bzero(config, sizeof(RF_Config_t));  raidPtr = (RF_Raid_t *)malloc(sizeof(RF_Raid_t));  if (raidPtr == NULL) {    fprintf(stderr, "ERROR: could not allocate RAID structure\n");    exit(1);  }  bzero((char *)raidPtr, sizeof(RF_Raid_t));  *ios_per_secp = *response_timep = 0.0;  *num_iosp = 0;  shutdownList = NULL;  rf_BootRaidframe();  rc = rf_MakeConfig(cfg_name, config);  if (rc) {    fprintf(stderr, "ERROR: rc=%d reading %s\n", rc, cfg_name);    exit(1);  }  rc = rf_Configure(raidPtr, config);  free(config->layoutSpecific);  if (rc) {    fprintf(stderr, "ERROR: rc=%d configuring %s\n", rc, cfg_name);    exit(1);  }  rf_TestcodeInit(raidPtr);  raidPtr->keep_acc_totals = 1;  doScriptTest(raidPtr, script_name, &shutdownList);  ExtractStats(raidPtr, num_iosp, ios_per_secp, response_timep);  rf_test_running = 0;  rf_ShutdownList(&shutdownList);  rf_Shutdown(raidPtr);  rf_UnbootRaidframe();  free(raidPtr);  free(config);}#define LINE 4096static void usage(){  fprintf(stderr, "USAGE: %s <options> configlist worklist output\n", rf_gp_progname);  fprintf(stderr, "options:\n");#if RF_CMU_PDL > 0 && !defined(SIMULATE)  fprintf(stderr, "  -k <devicename> run against kernel device\n");  fprintf(stderr, "  -s <devicename> run against striping driver\n");#endif /* RF_CMU_PDL > 0 && !SIMULATE */  fprintf(stderr, "  -n   no graph keys\n");  fprintf(stderr, "  -o   generate plots\n");  fprintf(stderr, "  -p   generate plots, don't do runs\n");  fflush(stderr);  exit(1);}main(argc, argv)  int     argc;  char  **argv;{  char *worklist_filename, *configlist_filename, *out_filebase;  double ios_per_sec, response_time, cpu_util;  struct plconfig *cfglist, *cfg, *cfglistl;  struct workload *wrklist, *wrk, *wrklistl;  char buf[LINE], buf2[LINE], *tok;  int l, n, i, line, targc, j, rc;  FILE *wl, *cl, *outf, *bf;  struct graphsym *gs;  RF_uint64 num_ios;#if RF_CMU_PDL > 0 && !defined(SIMULATE)  int is_striper = (-1);  FILE *outf_cpu;#endif /* RF_CMU_PDL > 0 && !defined(SIMULATE) */  rf_gp_progname = argv[0];  cfglist = cfglistl = NULL;  wrklist = wrklistl = NULL;  if (argc < 4)    usage();  targc = argc - 3;  configlist_filename = argv[targc];  worklist_filename = argv[targc+1];  out_filebase = argv[targc+2];  sprintf(out_filename, "%s.out", out_filebase);  sprintf(out_ps_filename, "%s.ps", out_filebase);  sprintf(out_mif_filename, "%s.mif", out_filebase);#if RF_CMU_PDL > 0 && !defined(SIMULATE)  sprintf(out_cpu_filename, "%s_cpu.out", out_filebase);  sprintf(out_cpu_ps_filename, "%s_cpu.ps", out_filebase);  sprintf(out_cpu_mif_filename, "%s_cpu.mif", out_filebase);#endif /* RF_CMU_PDL > 0 && !defined(SIMULATE) */  for(i=1;i<targc;i++) {    if (argv[i][0] != '-')      usage();    l = strlen(argv[i]);    for(j=1;j<l;j++) {      switch(argv[i][j]) {#if RF_CMU_PDL > 0 && !defined(SIMULATE)        case 'k':          if (is_striper != (-1))            usage();          is_striper = 0;          if (j+1 < l)            usage();          i++;          if (i >= targc)            usage();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -