pipe - Make pipe r/w MPSAFE, add kern.pipe.mpsafe (disabled by default)
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 12 Jul 2009 22:42:43 +0000 (15:42 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 12 Jul 2009 22:42:43 +0000 (15:42 -0700)
commit1ae37239759b49870dcaae946fc436b7f9f53f73
treeb98c7dfdc7ec91924929c2f817efb2b0c3ee3d45
parentc600838ff28809acd3285f93d219d17fe138729d
pipe - Make pipe r/w MPSAFE, add kern.pipe.mpsafe (disabled by default)

* Make pipe_read and pipe_write MPSAFE.

* Add a sysctl kern.pipe.mpsafe which defaults to disabled.  Set to
  1 to test the MPSAFE pipe code.  The expectation is that it will be
  set to 1 for the release.  Currently only pipe_read and pipe_write
  is MPSAFE.

* The new code in mpsafe mode also implements a streaming optimization
  to avoid unnecessary tsleep/wakeup/IPIs.  If the reader and writer
  are operating on different cpus this feature results in more uniform
  performance across a wide swath of block sizes.

* The new code currently does not use any page mapping optimizations.
  Page table overhead is fairly nasty on SMP so for now we rely on cpu
  caches and do an extra copy.  This means the code is tuned better for
  more recent cpus and tuned worse for older cpus.  At least for now.

OLD pipe code:  dwe = dwrite_enable, sfb = dwrite_sfbuf mode
NEW pipe code:  mpsafe = 0 (gets bgl) or 1 (does not use bgl)

Using /usr/src/test/sysperf/pipe2.c to test, all results in MBytes/sec

  8K  16K  32K  64K 128K 256K
---- ---- ---- ---- ---- ----
OLD dwe=0 1193 1167 1555 1525 1473 1477
OLD dwe=1 sfb=0  856    1458 2307 2182 2275 2307
OLD dwe=1 sfb=1  955 1537 2300 2356 2363 2708
OLD dwe=1 sfb=2  939 1561 2367 2477 2379 2360

NEW mpsafe=0 1150 1369 1536 1591 1358 1270
NEW mpsafe=1 2133 2319 2375 2387 2396 2418
sys/kern/sys_pipe.c
sys/sys/pipe.h