home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / bsd / 5201 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  7.2 KB

  1. Path: sparky!uunet!usc!sdd.hp.com!think.com!cayman!brad
  2. From: brad@cuba.cayman (Brad Parker)
  3. Newsgroups: comp.unix.bsd
  4. Subject: iostat & wd.c (small patch)
  5. Message-ID: <BRAD.92Sep6134203@cuba.cayman>
  6. Date: 6 Sep 92 17:42:03 GMT
  7. Sender: news@cayman.COM
  8. Organization: You must be kidding...
  9. Lines: 250
  10. Nntp-Posting-Host: cuba
  11.  
  12.  
  13. I was curious how my two IDE drives where doing under 386BSD, so I
  14. added missing support for some kernel globals used by iostat.  I also
  15. changed the stock net2 iostat to report "kbytes" like sunos.
  16.  
  17. I did not get "msps" (ms per seek) working since I don't know how to
  18. eastimate the "words per second" rate of an IDE drive. The calculation
  19. seems a bit hokey to me anyway i.e. 
  20.  
  21.     busy_time - known_xfer_rate_per_wds*words_xfered -> "seek" overhead
  22.  
  23. This seems like an "interesting" number but I don't get how to
  24. calculate the known xfer rate since this is highly cpu dependant for a
  25. non-dma IDE controller (right?).  If I'm lost or clueless on this,
  26. please send me a note.  I'm not very IDE literate.
  27.  
  28. I verifed the resulting numbers with a little test program and a known
  29. MS-DOS disk speed checker.  I got between 300kbytes/sec and 900kbytes/sec
  30. depending on the size of the "userland" i/o request (this, to the raw
  31. device, of course).
  32.  
  33. -brad
  34.  
  35. diff -c -r1.2 wd.c
  36. *** /tmp/,RCSt1000115    Sun Sep  6 13:27:01 1992
  37. --- wd.c    Sun Sep  6 10:22:41 1992
  38. ***************
  39. *** 54,59 ****
  40. --- 54,60 ----
  41.   #include "uio.h"
  42.   #include "malloc.h"
  43.   #include "machine/cpu.h"
  44. + #include "sys/dkstat.h"
  45.   #include "i386/isa/isa_device.h"
  46.   #include "i386/isa/icu.h"
  47.   #include "i386/isa/wdreg.h"
  48. ***************
  49. *** 430,435 ****
  50. --- 431,444 ----
  51.       wdtab.b_active = 1;        /* mark controller active */
  52.       wdc = du->dk_port;
  53.   
  54. +     /* instrumentation */
  55. +     if (du->dk_unit >= 0 && du->dk_skip == 0) {
  56. +         dk_busy |= 1 << du->dk_unit;
  57. +         ++dk_seek[du->dk_unit];
  58. +         ++dk_xfer[du->dk_unit];
  59. +         dk_wds[du->dk_unit] += bp->b_bcount >> 6;
  60. +     }
  61.       /* if starting a multisector transfer, or doing single transfers */
  62.       if (du->dk_skip == 0 || (du->dk_flags & DKFL_SINGLE)) {
  63.           if (wdtab.b_errcnt && (bp->b_flags & B_READ) == 0)
  64. ***************
  65. *** 598,603 ****
  66. --- 607,616 ----
  67.   
  68.       wdxfer[du->dk_unit]++;
  69.       if (wdtab.b_active) {
  70. +         if (du->dk_unit >= 0)
  71. +             dk_busy &=~ (1 << du->dk_unit);
  72.           if ((bp->b_flags & B_ERROR) == 0) {
  73.               du->dk_skip++;        /* Add to successful sectors. */
  74.               if (wdtab.b_errcnt && (du->dk_flags & DKFL_QUIET) == 0)
  75. diff -c -r1.1 iostat.c
  76. *** /tmp/,RCSt1000121    Sun Sep  6 13:27:50 1992
  77. --- iostat.c    Sun Sep  6 11:01:56 1992
  78. ***************
  79. *** 311,317 ****
  80.       (void)printf("         cpu\n tin tout");
  81.       for (i = 0; i < dk_ndrive; i++)
  82.           if (dr_select[i])
  83. !             (void)printf(" sps tps msps ");
  84.       (void)printf(" us ni sy id\n");
  85.   }
  86.   
  87. --- 311,317 ----
  88.       (void)printf("         cpu\n tin tout");
  89.       for (i = 0; i < dk_ndrive; i++)
  90.           if (dr_select[i])
  91. !             (void)printf(" bps tps msps ");
  92.       (void)printf(" us ni sy id\n");
  93.   }
  94.   
  95. ***************
  96. *** 324,333 ****
  97.       for (dn = 0; dn < dk_ndrive; ++dn) {
  98.           if (!dr_select[dn])
  99.               continue;
  100. !         words = cur.dk_wds[dn] * 32;        /* words xfer'd */
  101. !         (void)printf("%4.0f",            /* sectors */
  102. !             words / (DEV_BSIZE / 2) / etime);
  103.   
  104.           (void)printf("%4.0f", cur.dk_xfer[dn] / etime);
  105.   
  106.           if (dk_wpms[dn] && cur.dk_xfer[dn]) {
  107. --- 324,334 ----
  108.       for (dn = 0; dn < dk_ndrive; ++dn) {
  109.           if (!dr_select[dn])
  110.               continue;
  111. !         words = cur.dk_wds[dn] * 32;    /* words = 32*64 byte xfer's */
  112. !         (void)printf("%4.0f",        /* kbytes/second */
  113. !                  (words / 512) / etime);
  114.   
  115. +                         /* transfers/second */
  116.           (void)printf("%4.0f", cur.dk_xfer[dn] / etime);
  117.   
  118.           if (dk_wpms[dn] && cur.dk_xfer[dn]) {
  119. ***************
  120. *** 342,347 ****
  121. --- 343,357 ----
  122.           } else
  123.               msps = 0;
  124.           (void)printf("%5.1f ", msps);
  125. + #ifdef DEBUG
  126. +         if (dn == 1) {
  127. +             printf("\nwords %.2f, dk_wpms %d\n",
  128. +                    words, dk_wpms[dn]);
  129. +             printf("etime %.2f, atime %.2f, xtime %.2f, itime %.2f\n",
  130. +                    etime, atime, xtime, itime);
  131. +         }
  132. + #endif
  133.       }
  134.   }
  135.   
  136. Return-Path: root@faster 
  137. Delivery-Date: Sun, 06 Sep 92 13:28:39 -0400
  138. Return-Path: root@faster
  139. Return-Path: <root@faster>
  140. Received: from faster by stemwinder (4.1/SMI-4.1)
  141.     id AA02174; Sun, 6 Sep 92 13:28:38 EDT
  142. Received: by faster (AA00143); Sun, 6 Sep 92 13:30:49 -0400
  143. Date: Sun, 6 Sep 92 13:30:49 -0400
  144. From: Charlie Root <root@faster>
  145. Message-Id: <9209061730.AA00143@faster>
  146. To: brad@stemwinder
  147.  
  148.  
  149. diff -c -r1.2 wd.c
  150. *** /tmp/,RCSt1000115    Sun Sep  6 13:27:01 1992
  151. --- wd.c    Sun Sep  6 10:22:41 1992
  152. ***************
  153. *** 54,59 ****
  154. --- 54,60 ----
  155.   #include "uio.h"
  156.   #include "malloc.h"
  157.   #include "machine/cpu.h"
  158. + #include "sys/dkstat.h"
  159.   #include "i386/isa/isa_device.h"
  160.   #include "i386/isa/icu.h"
  161.   #include "i386/isa/wdreg.h"
  162. ***************
  163. *** 430,435 ****
  164. --- 431,444 ----
  165.       wdtab.b_active = 1;        /* mark controller active */
  166.       wdc = du->dk_port;
  167.   
  168. +     /* instrumentation */
  169. +     if (du->dk_unit >= 0 && du->dk_skip == 0) {
  170. +         dk_busy |= 1 << du->dk_unit;
  171. +         ++dk_seek[du->dk_unit];
  172. +         ++dk_xfer[du->dk_unit];
  173. +         dk_wds[du->dk_unit] += bp->b_bcount >> 6;
  174. +     }
  175.       /* if starting a multisector transfer, or doing single transfers */
  176.       if (du->dk_skip == 0 || (du->dk_flags & DKFL_SINGLE)) {
  177.           if (wdtab.b_errcnt && (bp->b_flags & B_READ) == 0)
  178. ***************
  179. *** 598,603 ****
  180. --- 607,616 ----
  181.   
  182.       wdxfer[du->dk_unit]++;
  183.       if (wdtab.b_active) {
  184. +         if (du->dk_unit >= 0)
  185. +             dk_busy &=~ (1 << du->dk_unit);
  186.           if ((bp->b_flags & B_ERROR) == 0) {
  187.               du->dk_skip++;        /* Add to successful sectors. */
  188.               if (wdtab.b_errcnt && (du->dk_flags & DKFL_QUIET) == 0)
  189. diff -c -r1.1 iostat.c
  190. *** /tmp/,RCSt1000121    Sun Sep  6 13:27:50 1992
  191. --- iostat.c    Sun Sep  6 11:01:56 1992
  192. ***************
  193. *** 311,317 ****
  194.       (void)printf("         cpu\n tin tout");
  195.       for (i = 0; i < dk_ndrive; i++)
  196.           if (dr_select[i])
  197. !             (void)printf(" sps tps msps ");
  198.       (void)printf(" us ni sy id\n");
  199.   }
  200.   
  201. --- 311,317 ----
  202.       (void)printf("         cpu\n tin tout");
  203.       for (i = 0; i < dk_ndrive; i++)
  204.           if (dr_select[i])
  205. !             (void)printf(" bps tps msps ");
  206.       (void)printf(" us ni sy id\n");
  207.   }
  208.   
  209. ***************
  210. *** 324,333 ****
  211.       for (dn = 0; dn < dk_ndrive; ++dn) {
  212.           if (!dr_select[dn])
  213.               continue;
  214. !         words = cur.dk_wds[dn] * 32;        /* words xfer'd */
  215. !         (void)printf("%4.0f",            /* sectors */
  216. !             words / (DEV_BSIZE / 2) / etime);
  217.   
  218.           (void)printf("%4.0f", cur.dk_xfer[dn] / etime);
  219.   
  220.           if (dk_wpms[dn] && cur.dk_xfer[dn]) {
  221. --- 324,334 ----
  222.       for (dn = 0; dn < dk_ndrive; ++dn) {
  223.           if (!dr_select[dn])
  224.               continue;
  225. !         words = cur.dk_wds[dn] * 32;    /* words = 32*64 byte xfer's */
  226. !         (void)printf("%4.0f",        /* kbytes/second */
  227. !                  (words / 512) / etime);
  228.   
  229. +                         /* transfers/second */
  230.           (void)printf("%4.0f", cur.dk_xfer[dn] / etime);
  231.   
  232.           if (dk_wpms[dn] && cur.dk_xfer[dn]) {
  233. ***************
  234. *** 342,347 ****
  235. --- 343,357 ----
  236.           } else
  237.               msps = 0;
  238.           (void)printf("%5.1f ", msps);
  239. + #ifdef DEBUG
  240. +         if (dn == 1) {
  241. +             printf("\nwords %.2f, dk_wpms %d\n",
  242. +                    words, dk_wpms[dn]);
  243. +             printf("etime %.2f, atime %.2f, xtime %.2f, itime %.2f\n",
  244. +                    etime, atime, xtime, itime);
  245. +         }
  246. + #endif
  247.       }
  248.   }
  249.   
  250. --
  251. A metaphor is like a simile.
  252.  
  253. Brad Parker    Cayman Systems, Inc., Cambridge, Ma.    brad@cayman.com
  254.