9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Dan Cross <crossd@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] PDP11 (Was: Re: what heavy negativity!)
Date: Tue,  9 Oct 2018 18:42:46 -0400	[thread overview]
Message-ID: <CAEoi9W7pwHLGoGOZwZDXb9XDsWRzW0ur=yF2r=kXpvtWmvwD_A@mail.gmail.com> (raw)
In-Reply-To: <CAFSF3XOb5GW+XSYkMxXansuYRrLHeMq+hZvLr_gj7=tPQnxojA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4338 bytes --]

On Tue, Oct 9, 2018 at 5:28 PM hiro <23hiro@gmail.com> wrote:

> > E.g. right now Plan 9 suffers from a *lot* of data copying between
> > the kernel and processes, and between processes themselves.
>
> Huh? What exactly do you mean?


The current plan9 architecture relies heavily on copying data within a
process between userspace and the kernel for e.g. IO. This should be well
known to anyone who's rummaged around in the kernel, as it's pretty
evident. Because of the simple system call and VM interfaces, things like
scatter/gather IO or memory-mapped direct hardware access aren't really
options. `iowritev`, for example, coalesces its arguments into a single
buffer that it then pwrite()'s to its destination.

Can you describe the scenario and the
> measurements you made?
>

This is a different issue. I don't know if copying is as significant an
overhead as Lyndon suggested, but there are plenty of slow code paths in
plan9. For example, when we ported the plan9 network stack to Akaros, we
made a number of enhancements that combined sped things up by 50% or
greater. Most of these were pretty simple: optimizing checksum
calculations, alignment of IP and TCP headers on natural word boundaries
meaning that we could read an IP address with a 32-bit load (I think that
one netted a gigabit increase in throughput), using optimized memcpy
instead of memmove in performance critical code paths, etc. We went from
about 7Gbps on a 10Gbps interface to saturating the NIC. Those measurements
were made between dedicated test machines on a dedicated network using
netperf. Drew Gallatin, now at Netflix working on FreeBSD's network stack,
did most of the optimization work.

If that experience in that one section of the kernel is any indicator,
plan9 undoubtedly has lots of room for optimization in other parts of the
system. Lots of aspects of the system were optimized for much smaller
machines than are common now and many of those optimizations no longer make
much sense on modern machines; the allocator is slow, for example, though
very good at not wasting RAM. Compare to a vmem-style allocator, that can
allocate any requested size in constant-time, but with up-to a factor of
two waste of memory.

Lots of plan9 code is also buggy, or at least racy: consider the seemingly
random valued timeouts to "give other threads 5 seconds to get out" in
ipselffree() and iplinkfree() before "deallocating" an Iplink/Ipself.
Something like RCU, even a naive RCU, would be more robust here,
particularly under heavy load. Device drivers are atrophied and often
buggy, or at least susceptible to hardware bugs that are fixed by the
vendor-provided drivers. When I put in the plan9 networks to support Akaros
development, we ran into a bug in the i218 ethernet controller that caused
the NIC to wedge. We got Geoff Collyer to fix the i82563 driver and we sent
a patch to 9legacy, but it's symptomatic of an aging code base with a
shrinking developer population.

> If we could eliminate most of that copying, things would get a lot faster.
>
> Which things would get faster?
>

Presumably bulk data transfer between devices and the user portion of an
address space. If copying were eliminated (or just reduced) these would
certainly get fast*er*. Whether they would be sufficiently faster as to
make a perceptible performance different to a real workload is another
matter.

> Dealing with the security issues isn't trivial
>
> what security issues?
>

Presumably the bread-and-butter security issues that arise whenever the
user portion of an address space is being concurrently accessed by
hardware. As a trivial example, imagine scheduling a DMA transfer from some
device into a buffer in the user portion of an address space and then
exit()'ing the process. What do you do with the pages the device was
writing into? They had better be pinned in some way until the IO operation
completes before they're reallocated to something else that isn't expecting
it to be clobbered.

I wouldn't be surprised if the raft of currently popular speculative
execution bugs could be exacerbated by the kernel playing around with data
in the user address space in a naive way. It doesn't look like plan9 has
any serious mitigations for those.

        - Dan C.

[-- Attachment #2: Type: text/html, Size: 5200 bytes --]

  parent reply	other threads:[~2018-10-09 22:42 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08  3:38 Lucio De Re
2018-10-08  4:29 ` Digby R.S. Tarvin
2018-10-08  7:20   ` hiro
2018-10-08 12:03     ` Charles Forsyth
2018-10-08 17:20       ` hiro
2018-10-08 21:55         ` Digby R.S. Tarvin
2018-10-08 23:03           ` Dan Cross
2018-10-09  0:14             ` Bakul Shah
2018-10-09  1:34               ` Christopher Nielsen
2018-10-09  3:28               ` Lucio De Re
2018-10-09  8:23                 ` hiro
2018-10-09  9:45                 ` Ethan Gardener
2018-10-09 17:50                   ` Bakul Shah
2018-10-09 18:57                     ` Ori Bernstein
2018-10-10  7:32                 ` Giacomo Tesio
2018-10-09 17:45               ` Lyndon Nerenberg
2018-10-09 18:49                 ` hiro
2018-10-09 19:14                   ` Lyndon Nerenberg
2018-10-09 22:05                     ` erik quanstrom
2018-10-11 17:54                       ` Lyndon Nerenberg
2018-10-11 18:04                         ` Kurt H Maier
2018-10-11 19:23                         ` hiro
2018-10-11 19:24                           ` hiro
2018-10-11 19:25                             ` hiro
2018-10-11 19:26                         ` Skip Tavakkolian
2018-10-11 19:39                           ` Lyndon Nerenberg
2018-10-11 19:44                             ` Skip Tavakkolian
2018-10-11 19:47                               ` Lyndon Nerenberg
2018-10-11 19:57                                 ` hiro
2018-10-11 20:23                                   ` Lyndon Nerenberg
2018-10-10 10:42                     ` Ethan Gardener
2018-10-09 19:23                   ` Lyndon Nerenberg
2018-10-09 19:34                     ` hiro
2018-10-09 19:36                       ` hiro
2018-10-09 19:40                       ` Lyndon Nerenberg
2018-10-10  0:18                       ` Dan Cross
2018-10-10  5:45                         ` hiro
2018-10-09 22:06                     ` erik quanstrom
2018-10-10  6:24                       ` Bakul Shah
2018-10-10 13:58                         ` erik quanstrom
2018-10-09 22:42                   ` Dan Cross [this message]
2018-10-09 19:09                 ` Bakul Shah
2018-10-09 19:30                   ` Lyndon Nerenberg
2018-10-09  3:08             ` Digby R.S. Tarvin
2018-10-09  3:16               ` [9fans] PDP11 David Arnold
2018-10-09  4:52                 ` Digby R.S. Tarvin
2018-10-09 11:58               ` [9fans] PDP11 (Was: Re: what heavy negativity!) Ethan Gardener
2018-10-09 13:59                 ` erik quanstrom
2018-10-09 22:22                 ` Digby R.S. Tarvin
2018-10-10 10:38                   ` Ethan Gardener
2018-10-10 23:15                     ` Digby R.S. Tarvin
2018-10-11 18:10                       ` Lyndon Nerenberg
2018-10-11 20:55                         ` Digby R.S. Tarvin
2018-10-11 21:03                           ` Lyndon Nerenberg
2018-10-09 14:02               ` erik quanstrom
2018-10-08  8:12   ` Nils M Holm
2018-10-08  9:12     ` Digby R.S. Tarvin
2018-10-08  8:09 ` Nils M Holm
2018-10-09 19:47 cinap_lenrek
2018-10-09 22:01 ` erik quanstrom
2018-10-09 23:43 ` Lyndon Nerenberg
2018-10-10  5:52   ` hiro
2018-10-10  8:13     ` Digby R.S. Tarvin
2018-10-10  9:14       ` hiro
2018-10-10 13:59         ` Steve Simon
2018-10-10 21:32         ` Digby R.S. Tarvin
2018-10-11 17:43     ` Lyndon Nerenberg
2018-10-11 19:11       ` hiro
2018-10-11 19:27         ` Lyndon Nerenberg
2018-10-11 19:56           ` hiro
2018-10-10  5:57   ` hiro
2018-10-09 19:49 cinap_lenrek
2018-10-09 19:56 ` hiro
2018-10-10  0:15 cinap_lenrek
2018-10-10  0:22 ` Lyndon Nerenberg
2018-10-10 16:14 cinap_lenrek
2018-10-10 17:34 cinap_lenrek
2018-10-10 21:54 ` Steven Stallion
2018-10-10 22:29   ` Kurt H Maier
2018-10-10 22:55     ` Steven Stallion
2018-10-11 11:19       ` Aram Hăvărneanu
2018-10-11  0:26   ` Skip Tavakkolian
2018-10-11  1:03     ` Steven Stallion
2018-10-14  9:46   ` Ole-Hjalmar Kristensen
2018-10-14 10:37     ` hiro
2018-10-14 17:34       ` Ole-Hjalmar Kristensen
2018-10-14 19:17         ` hiro
2018-10-15  9:29         ` Giacomo Tesio
2018-10-10 22:19 cinap_lenrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEoi9W7pwHLGoGOZwZDXb9XDsWRzW0ur=yF2r=kXpvtWmvwD_A@mail.gmail.com' \
    --to=crossd@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).