home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / bsd / 4797 < prev    next >
Encoding:
Text File  |  1992-08-27  |  2.9 KB  |  74 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!barsoom!barsoom!tih
  3. From: tih@barsoom.nhh.no (Tom Ivar Helbekkmo)
  4. Subject: 386BSD: buffer space allocation -- a small bugfix.
  5. Message-ID: <tih.714982908@barsoom>
  6. Sender: news@barsoom.nhh.no (USENET News System)
  7. Organization: Norwegian School of Economics
  8. Date: Fri, 28 Aug 1992 06:21:48 GMT
  9. Lines: 63
  10.  
  11. Well, I guess it's my turn!  :-)  I'm now seeing the "kmem_map too
  12. small" panic here, when I try to copy a large file (a 1.44Mb floppy
  13. image) from an NFS-mounted device to a local hard disk.  I've tried
  14. making the changes that have been suggested, but that didn't help.
  15. (Sanity check in machdep.c, 500 to 1000 increase in vm_map.h.)
  16.  
  17. However, while looking at /sys/i386/i386/machdep.c, I discovered a
  18. little bug in it.  (Fixing it hasn't solved my problem, either, but
  19. at least it's a bug!)  Here's what I was looking at:
  20.  
  21.     /*
  22.      * Determine how many buffers to allocate.
  23.      * Use 10% of memory for the first 2 Meg, 5% of the remaining
  24.      * memory. Insure a minimum of 16 buffers.
  25.      * We allocate 1/2 as many swap buffer headers as file i/o buffers.
  26.      */
  27.     if (bufpages == 0)
  28.             if (physmem < (2 * 1024 * 1024))
  29.                     bufpages = physmem / 10 / CLSIZE;
  30.             else
  31.                     bufpages = ((2 * 1024 * 1024 + physmem) / 20) / CLSIZE;
  32.     if (nbuf == 0) {
  33.             nbuf = bufpages / 2;
  34.             if (nbuf < 16)
  35.                     nbuf = 16;
  36.     }
  37.     freebufspace = bufpages * NBPG;
  38.     if (nswbuf == 0) {
  39.             nswbuf = (nbuf / 2) &~ 1;       /* force even */
  40.             if (nswbuf > 256)
  41.                     nswbuf = 256;           /* sanity */
  42.     }
  43.     valloc(swbuf, struct buf, nswbuf);
  44.     valloc(buf, struct buf, nbuf);
  45.  
  46. Bill Jolitz suggests a sanity check on the calculation of bufpages,
  47. keeping it at a max of NKMEMCLUSTERS/2.  In my case, that's not the
  48. problem, since the calculation doesn't come out higher than that.
  49. (I only have 8Mb of RAM.)
  50.  
  51. However:  The comment in the above code says to allocate 10% of the
  52. first 2 Meg, then 5% of whatever remains.  This is *not* what the
  53. code itself does.  Since physmem et al do not count bytes, we're
  54. sort of mixing apples and oranges here, and end up with 10% of the
  55. entire physical memory, no matter what.  The following calculation,
  56. however, does do what the comment says:
  57.  
  58.     if (bufpages == 0) {
  59.             bufpages = min(physmem, btoc(2*1024*1024)) / 10 / CLSIZE;
  60.             if (physmem > btoc(2*1024*1024))
  61.                     bufpages += (physmem - btoc(2*1024*1024)) / 20 / CLSIZE;
  62.     }
  63.  
  64. (Actually, I'm not too sure about the "/ CLSIZE", but since CLSIZE is
  65. equal to 1, at least on my machine, it doesn't really matter...  :-))
  66.  
  67. I still can't copy large files from NFS to UFS disks -- but what the
  68. heck, I'm sure that will come in due time!  :-)
  69.  
  70. -tih
  71. --
  72. Tom Ivar Helbekkmo, NHH, Bergen, Norway.  Telephone: +47-5-959205
  73. Postmaster for domain nhh.no.   Internet mail: tih@barsoom.nhh.no
  74.