	The enclosed files are an attempt to measure and profile the
kernel buffer cache and scsi disk access.  To do this, I have taken a
number of source code modules from the kernel, and usually with very
slight modifications I am able to run them as a user-mode program.
The advantage of doing this is that you can run gdb and gprof on
the code to determine what is going on.

	Currrently we start at the top level with bmark.c.  This
supplies a bunch of kernel functions which we do not normally have
available, and it sets things up.  We begin by simulating a 15Mb
buffer cache - each buffer header actually shares the same buffer, so
you do not need 15Mb of memory to run this.

	Next we set up the scsi disks.  The scsi_debug.c module was
designed for these sorts of applications because it simulates the
presence of two scsi disks.  For our purposes we only need one, but it
was easier to leave alone.  I modified the scsi_debug driver so that
all "access" to the scsi disks completes immediately without delay.
We are trying to measure delays and latencies that do not include
waiting for a scsi request to complete, so we are not interested in
simulating the actual time that a real scsi disk would take to
complete the request.  If someone wanted to get really fancy, you
could wire the srawread program into the scsi_debug program and
simulate the entire thing from stem to stern.

	At some point I would like to start including some modules
from ext2 and simulate file access.  This would require us to somehow
keep track of some dirty buffers for bitmaps, but it should be doable.

	Anyway, as currently configured, the program is set up to
simulate reading a scsi disk partition in 1024 byte increments.  The
clustering diffs are not included in this distribution, but could
easily be used because most of the relevant source files are in fact
direct copies of the actual kernel sources with very minor
modifications.  I have rigged the test in such a way that clustering
will not make much of a difference anyway, because it would appear
that most of the overhead is above the scsi code.  The srawread
results with real scsi disks seems to bear this out.

	To run the program type:

./bmark 10

to simulate reading a 10Mb file.

	One thing that I find interesting is that this program reports
datarates of approximately 7.5Mb/sec (my machine is a 486/33).  This would
be a theoretical maximum for a 486-33 that you could probably not surpass even
with the best VLB or EISA board.


	The current Makefile is set up to compile the program to do
profiling.  This in itself sounds like a reasonable thing to do but
the reports that gprof generates have really screwy numbers in them.
For one thing, it gets the total elapsed time wrong, by something like
a factor of 2 to 4.  Also, it reports execution times for functions
that it also reports (and I know) are never called.  This is true both
with and without optmization so I would tend to guess that there may
be problems with the profiling code somewhere.  Anyway, I would like a
profiling expert to look over the results and try and figure out why
the report looks so weird.


	I am enclosing a portion of the report for a 30Mb file.

	Also note that when profiling is in use, the program is
noticably slower - instead of 7.5 Mb/sec, I get something like
5.5Mb/sec.

-Eric

Note: I have noticed that the memset function is not well suited
towards zeroing large chunks of memory (i.e. buffers).  It zeroes the
buffer on a byte by byte basis - it is almost 4 times faster to zero on
a longword by longword basis.  This probably does not come up very
often, but it is helpful to keep in mind.


***************************
Here is the execution profile - note that wake_up gets 20% of the time - 
this does not make much sense since wake_up *always* returns immediately.

	Flat profile (explanation follows)

	Call graph is on the following page.

Each sample counts as 0.01 seconds.

% time  seconds   cumsec   calls  function
 20.19     0.64     0.64   93557  wake_up
 13.56     0.43     1.07          _entry
  6.31     0.20     1.27          block_write
  5.99     0.19     1.46   88246  find_buffer
  5.99     0.19     1.65   58240  getblk
  4.10     0.13     1.78   58240  brelse
  3.79     0.12     1.90    3532  requeue_sd_request
  3.15     0.10     2.00   58240  get_hash_table
  3.15     0.10     2.10   30000  block_read
  2.52     0.08     2.18       1  scan_scsis
  2.21     0.07     2.25   30006  make_request
  2.21     0.07     2.32    5297  do_sd_request
  1.89     0.06     2.38    1777  scsi_done
  1.58     0.05     2.43       2  sd_init_onedisk
  1.26     0.04     2.47    1768  allocate_device
  0.95     0.03     2.50   15000  insert_into_queues
  0.95     0.03     2.53    1766  rw_intr
  0.95     0.03     2.56          check_sense
  0.95     0.03     2.59          scsi_times_out
  0.95     0.03     2.62          set_blocksize
  0.95     0.03     2.65          try_to_load_aligned
  0.63     0.02     2.67   15242  malloc
  0.63     0.02     2.69    1777  scsi_do_cmd
  0.63     0.02     2.71    1767  scsi_malloc
  0.63     0.02     2.73    1766  end_scsi_request
  0.63     0.02     2.75    1766  ll_rw_block
  0.63     0.02     2.77       1  scsi_dev_init
  0.63     0.02     2.79       1  sd_geninit
  0.63     0.02     2.81          breada
  0.63     0.02     2.83          try_to_free
  0.32     0.01     2.84    3554  update_timeout
  0.32     0.01     2.85    1767  scsi_free
  0.32     0.01     2.86    1766  add_request
  0.32     0.01     2.87       9  scan_scsis_done
  0.32     0.01     2.88       2  sd_init_done
  0.32     0.01     2.89       1  sd_init
  0.32     0.01     2.90       1  setup
  0.32     0.01     2.91          bread_page
  0.32     0.01     2.92          check_aligned
  0.32     0.01     2.93          create_buffers
  0.32     0.01     2.94          fake_disk_fn
  0.32     0.01     2.95          file_fsync
  0.32     0.01     2.96          init_cw
  0.32     0.01     2.97          internal_cmnd
  0.32     0.01     2.98          invalidate_buffers
  0.32     0.01     2.99          is_read_only
  0.32     0.01     3.00          ll_rw_page
  0.32     0.01     3.01          ll_rw_swap_file
  0.32     0.01     3.02          panic
  0.32     0.01     3.03          put_last_free
  0.32     0.01     3.04          rd_init
  0.32     0.01     3.05          remove_from_free_list
  0.32     0.01     3.06          remove_from_hash_queue
  0.32     0.01     3.07          remove_from_queues
  0.32     0.01     3.08          request_queueable
  0.32     0.01     3.09          reset
  0.32     0.01     3.10          scsi_abort
  0.32     0.01     3.11          scsi_device_types
  0.32     0.01     3.12          scsi_main_timeout
  0.32     0.01     3.13          scsi_request_sense
  0.32     0.01     3.14          sd_open
  0.32     0.01     3.15          sd_release
  0.32     0.01     3.16          set_device_ro
  0.32     0.01     3.17          sync_supers
  0.00     0.00     3.17    1777  scsi_debug_queuecommand
  0.00     0.00     3.17     240  __default_morecore
  0.00     0.00     3.17     240  __sbrk
  0.00     0.00     3.17     239  align
  0.00     0.00     3.17     238  morecore
  0.00     0.00     3.17     192  padn__9streambufci
  0.00     0.00     3.17     181  vform__9streambufPCcPv
  0.00     0.00     3.17     173  xsputn__7filebufPCci
  0.00     0.00     3.17     130  do_write__7filebufPCci
  0.00     0.00     3.17     105  xsputn__9streambufPCci
  0.00     0.00     3.17     100  __9streambufi
  0.00     0.00     3.17      83  printf
  0.00     0.00     3.17      69  __overflow
  0.00     0.00     3.17      69  overflow__7filebufi
  0.00     0.00     3.17      64  sys_write__7filebufPCvl
  0.00     0.00     3.17      49  fprintf
  0.00     0.00     3.17      49  help_vform__FP9streambufPCcPv
  0.00     0.00     3.17      49  overflow__14help_streambufi
  0.00     0.00     3.17       6  scsi_debug_intr_handle
  0.00     0.00     3.17       5  memcpy
  0.00     0.00     3.17       4  Balloc__Fi
  0.00     0.00     3.17       3  Bfree__FP6Bigint
  0.00     0.00     3.17       3  setb__9streambufPcT1i
  0.00     0.00     3.17       2  _outfloat(double, streambuf *, char, int, int, unsigned long, char, char)
  0.00     0.00     3.17       2  blacklisted
  0.00     0.00     3.17       2  d2b__FdPiT1
  0.00     0.00     3.17       2  doallocbuf__9streambuf
  0.00     0.00     3.17       2  dtoa
  0.00     0.00     3.17       2  init_static__12strstreambufPciT1
  0.00     0.00     3.17       2  lo0bits__FPUl
  0.00     0.00     3.17       2  print_inquiry
  0.00     0.00     3.17       2  sd_attach
  0.00     0.00     3.17       2  sg_attach
  0.00     0.00     3.17       2  time_so_far
  0.00     0.00     3.17       1  __isatty
  0.00     0.00     3.17       1  __new_exitfn
  0.00     0.00     3.17       1  __sigaction
  0.00     0.00     3.17       1  __tcgetattr
  0.00     0.00     3.17       1  __underflow
  0.00     0.00     3.17       1  atexit
  0.00     0.00     3.17       1  blk_dev_init
  0.00     0.00     3.17       1  doallocate__7filebuf
  0.00     0.00     3.17       1  exit
  0.00     0.00     3.17       1  initialize
  0.00     0.00     3.17       1  main
  0.00     0.00     3.17       1  memset
  0.00     0.00     3.17       1  register_blkdev
  0.00     0.00     3.17       1  scsi_debug_detect
  0.00     0.00     3.17       1  scsi_init
  0.00     0.00     3.17       1  scsi_register
  0.00     0.00     3.17       1  sd_init1
  0.00     0.00     3.17       1  sg_init
  0.00     0.00     3.17       1  sg_init1
  0.00     0.00     3.17       1  sr_init
  0.00     0.00     3.17       1  sr_init1
  0.00     0.00     3.17       1  sscanf
  0.00     0.00     3.17       1  st_init
  0.00     0.00     3.17       1  st_init1
  0.00     0.00     3.17       1  strtol
  0.00     0.00     3.17       1  underflow__12strstreambuf
  0.00     0.00     3.17       1  vscan__9streambufPCcPvP3ios
