home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / arch / 8301 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  6.9 KB

  1. Path: sparky!uunet!sun-barr!west.West.Sun.COM!news2me.ebay.sun.com!exodus.Eng.Sun.COM!nonsequitur!narad
  2. From: narad@nonsequitur.Eng.Sun.COM (Chuck Narad)
  3. Newsgroups: comp.arch
  4. Subject: bcopy (was Re: CISC Microcode)
  5. Date: 25 Jul 1992 01:25:12 GMT
  6. Organization: Sun Microsystems
  7. Lines: 120
  8. Distribution: world
  9. Message-ID: <l71bboINN4en@exodus.Eng.Sun.COM>
  10. References: <1992Jul15.054020.1@eagle.wesleyan.edu>
  11. Reply-To: narad@nonsequitur.Eng.Sun.COM
  12. NNTP-Posting-Host: nonsequitur
  13.  
  14. Having stared at the issue of accelerating bcopy for many years, I
  15. think I have a few comments to contribute on this thread.
  16.  
  17. As Mr. Limes said, to a first order (UNIX == bcopy), so anything that can
  18. speed that up will free up more CPU cycles for important work like
  19. running emacs :-) There are two aspects to bcopy, that which happens in
  20. kernel space and that done in User-land.
  21.  
  22. An ideal bcopy engine would be cache consistent (gets the most recent
  23. copy of any block), realigning (to service misaligned
  24. source/destination w.r.t. block size), and selectably cache polluting
  25. or not (some copy operations want the data just copied for immediate
  26. reuse, others don't, so 'pollution' of the cache is not always a bad
  27. thing).  It would also move arbitrary-sized items, not just multiples
  28. of block-size.  It would also (most important!) be able to accelerate
  29. the actual move in terms of CPU cycles used.  Finally, it would be
  30. accessible to both user and kernel code.
  31.  
  32. From avg@rodan.UU.NET (Vadim Antonov):
  33.  
  34. >My point is that the required circuit is cheap enough to have a really
  35. >good price/benefit ratio and i see no reason why the modern machines 
  36. >lack it. You can always do small bcopy by CPU and bulk copy jobs offload
  37. >to the memory duplicator unit (a pair of mated DMA channels). Later, you
  38. >can add the third DMA channel and a DSP and get real good bang per buck
  39. >on array operations :-)
  40.  
  41. As described above the bcopy engine is not a simple thing.  But let's
  42. say that the hardware is simple, and supports only transfers that have
  43. the src/dest both block-aligned and an integer multiple of block
  44. sized.  Leading and trailing block fragments can be handled in the CPU,
  45. so this restriction is really that the src/dest are aligned
  46. modulo[blocksize].  Now our hardware is a simple device consisting of
  47. two address counters (for source and destination) and a block counter
  48. (number of blocks to transfer) plus some controlling state machines.
  49. On the face of it this is an ideal solution, both low cost and
  50. effective for the most common copies such as copy-on-write of a page.
  51. Why isn't it seen more often in computers?
  52.  
  53. The answer is that this sort of device has too much overhead associated
  54. with it.  A processor must contend for ownership of the DMA_COPY
  55. engine, set it up (possibly probing and prefaulting page mappings on
  56. the way), then either sit in a polling loop or switching contexts,
  57. planning to take an interrupt when the copy is done and re-awakening
  58. the requesting thread.
  59.  
  60. It turns out that in UNIX, at least, the overhead is generally greater
  61. than the benefit; polling occupies busses somewhat, cutting into the
  62. DMA_COPY efficiency, and the overhead of allocating a device tends to
  63. be high; while taking an interrupt and entering/exiting user-land plus
  64. interrupt overhead tend to dominate the copy time.  The device would
  65. only be useful for copies of many pages at a time, reducing its utility
  66. and thus making it unattractive.
  67.  
  68. This sort of device is only useful from kernel land anyway, because user
  69. code would have to include the overhead of a system call to get to the
  70. resource.
  71.  
  72. In my experience and analysis, the most useful general bcopy support is
  73. something that is tied closely to each processor, and can move one
  74. block at a time in a read-from-coherent-space, write-to-memory
  75. (coherently) pattern under block-by-block control of the processor.
  76. This can also be used to bfill/bzero pages efficiently.  This allows us
  77. to accelerate relatively- aligned copies in kernel space, which covers
  78. many of the interesting cases including page copy, copy-on-write,
  79. networking buffers, etc.  It doesn't help with userland bcopy,
  80. misaligned copies, or graphics copies including window fill, scrolling,
  81. or window movement; but it certainly helps at the system level.
  82.  
  83. The rest would be done by the CPU.  Many interesting things can be done
  84. in a fancy-enough CPU to help; for instance, a machine with
  85. non-blocking loads would allow for better pipelining between loads and
  86. stores.  A write-through cache (hisssssssss!) actually can perform CPU
  87. bcopy better than a copy-back cache, since victims (displaced blocks)
  88. that are modified don't require a copyback.  Etc.
  89.  
  90. That copyback cache note is one that is often missed in bcopy analysis; if a
  91. bcopy by a processor goes through the cache, then it takes a cache fill
  92. (one block movement across the memory system), a write-allocate (to get
  93. the block that receives the data, another movement of a block), a bunch
  94. of cache-to-cache moves of data by the CPU, and potentially a copyback
  95. of the victim, which is a third movement of a block to/from the memory
  96. system.  Eventually the destination will also get copied back, since it
  97. was modified by the processor; that means that this kind of data
  98. movement can cost up to 4 bus transits of a block, and in the steady
  99. state will require 3, meaning that the maximum copy bandwidth is 1/3 of
  100. the memory system bandwidth (approximately, ignoring a few factors).
  101.  
  102.  
  103. From amolitor@eagle.wesleyan.edu ():
  104.  
  105. >    Relevent to this is the question 'how much of the stuff you just
  106. >moved do you *want* in cache later?' I suspect the answer is 'very little'
  107. >but this might be an interesting study. Do typical programs generally
  108. >move data, and then forget about it for a while? Do kernels? If the answers
  109. >vary, perhaps MORE INSTRUCTIONS is a good idea ;)
  110. >
  111. >    Andrew "cisccisccisc" Molitor
  112.  
  113. From dfields@hydra.urbana.mcd.mot.com (David Fields):
  114.  
  115. >Take, for instance, the case of a copy-on-write fault.  The OS will
  116. >copy the c-o-w page to a private one that the process can write.  It
  117. >is distructive to have 2*PAGESIZE data flush out the primary cache.
  118.  
  119. Good questions.  The answer is that sometimes you want the data now, and sometimes 
  120. you don't.  For example, moving data through several layers of network protocol
  121. stacks, there could be several successive copies that benefit from having the
  122. data in the cache after the first time.  With a c-o-w the process that tried to 
  123. write the data wants some portion of that page in its cache image *right* *now*;
  124. unfortunately it may want only one byte, while it *could* want the entire page.
  125.  
  126. So in summary; with UNIX systems at least, it is easy and beneficial to accelerate aligned
  127. kernel copies; it is more difficult (but not impossible) to handle misaligned copies, if
  128. it is impossible for the HW guys (white hats) to convince the SW guys (black hats) to
  129. fix their d**n code; DMA engines are generally not a win for this problem due to the 
  130. management overhead involved; and user bcopy is difficult to acclerate due to the 
  131. overheads of requesting a kernel service.
  132.  
  133. chuck/
  134.