From nobody Tue Nov 24 17:11:06 2026
X-Original-To: freebsd-arch@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
	by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jYq8j4MW2z71YyS
	for <freebsd-arch@mlmmj.nyi.freebsd.org>; Tue, 24 Nov 2026 17:11:17 +0000 (UTC)
	(envelope-from crest@rlwinm.de)
Received: from mail.rlwinm.de (mail.rlwinm.de [138.201.35.217])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 4jYq8h1Tknz3GBm
	for <freebsd-arch@FreeBSD.org>; Tue, 24 Nov 2026 17:11:16 +0000 (UTC)
	(envelope-from crest@rlwinm.de)
Authentication-Results: mx1.freebsd.org;
	dkim=none;
	dmarc=none;
	spf=pass (mx1.freebsd.org: domain of crest@rlwinm.de designates 138.201.35.217 as permitted sender) smtp.mailfrom=crest@rlwinm.de
Received: from [IPV6:2003:fc:d722:c500:25a6:4ea3:78e1:a42e] (p200300fcd722c50025a64ea378e1a42e.dip0.t-ipconnect.de [IPv6:2003:fc:d722:c500:25a6:4ea3:78e1:a42e])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)
	(No client certificate requested)
	by mail.rlwinm.de (Postfix) with ESMTPSA id 1D76524948
	for <freebsd-arch@FreeBSD.org>; Tue, 24 Nov 2026 17:11:08 +0000 (UTC)
Content-Type: multipart/alternative;
 boundary="------------4MpI4Sb40nm0j5jjaqJUPgmW"
Message-ID: <51c2968a-3c31-4bf8-b824-ce66d36d2203@rlwinm.de>
Date: Tue, 24 Nov 2026 18:11:06 +0100
List-Archive: https://lists.freebsd.org/archives/freebsd-arch
List-Id: Discussion related to FreeBSD architecture <freebsd-arch.FreeBSD.org>
List-Post: <mailto:freebsd-arch@FreeBSD.org>
List-Help: <mailto:freebsd-arch+help@FreeBSD.org>
List-Subscribe: <mailto:freebsd-arch+subscribe@FreeBSD.org>
List-Unsubscribe: <mailto:freebsd-arch+unsubscribe@FreeBSD.org>
List-Owner: <mailto:freebsd-arch+owner@FreeBSD.org>
Precedence: list
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [RFC] Doors IPC for FreeBSD: kernel integration and API
 boundaries
To: freebsd-arch@FreeBSD.org
References: <CAL9BGba+iSo0kq91CA_ZLfk11xLPTME1DbfAZGmNJL8Pip5ysg@mail.gmail.com>
 <CAJ-VmokPvAvePwjYukdMq8n91EfUMwD_1gYnsqnQWDF+5Gr_Ww@mail.gmail.com>
 <CAK7dMtAoX9FWsVA8daanGH6rxr2k58Dxe6C9zzH1T9P5wSZZmQ@mail.gmail.com>
 <CANCZdfrR8nYeC5erKPenWsM_C1M0obE37nJn-h8N_eyM1KXw2A@mail.gmail.com>
Content-Language: en-US
From: Jan Bramkamp <crest@rlwinm.de>
In-Reply-To: <CANCZdfrR8nYeC5erKPenWsM_C1M0obE37nJn-h8N_eyM1KXw2A@mail.gmail.com>
X-Rspamd-Queue-Id: 4jYq8h1Tknz3GBm
X-Spamd-Bar: /
X-Spamd-Result: default: False [-0.30 / 15.00];
	R_SPF_ALLOW(-0.20)[+mx];
	MIME_GOOD(-0.10)[multipart/alternative,text/plain];
	MID_RHS_MATCH_FROM(0.00)[];
	RCVD_TLS_ALL(0.00)[];
	RCVD_VIA_SMTP_AUTH(0.00)[];
	ASN(0.00)[asn:24940, ipnet:138.201.0.0/16, country:DE];
	ARC_NA(0.00)[];
	RCVD_COUNT_ONE(0.00)[1];
	R_DKIM_NA(0.00)[];
	MLMMJ_DEST(0.00)[freebsd-arch@FreeBSD.org];
	DMARC_NA(0.00)[rlwinm.de];
	FROM_EQ_ENVFROM(0.00)[];
	FROM_HAS_DN(0.00)[];
	MIME_TRACE(0.00)[0:+,1:+,2:~];
	TO_DN_NONE(0.00)[];
	PREVIOUSLY_DELIVERED(0.00)[freebsd-arch@freebsd.org];
	TO_MATCH_ENVRCPT_ALL(0.00)[];
	RCPT_COUNT_ONE(0.00)[1]

This is a multi-part message in MIME format.
--------------4MpI4Sb40nm0j5jjaqJUPgmW
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 18.11.26 04:16, Warner Losh wrote:
>
>
> On Tue, Nov 17, 2026 at 12:24 PM Kevin Bowling 
> <kevin.bowling@kev009.com> wrote:
>
>     On Tue, Nov 17, 2026 at 10:22 AM Adrian Chadd <adrian@freebsd.org>
>     wrote:
>     >
>     > hi!
>     >
>     > So I've taken a quick look. I've never come across doors before
>     and I used Solaris in the early 2.x days!
>     >
>     > Whats the advantage of using this over other IPC models?
>
>     I would want to see a weighing of Doors against Mach IPC which has
>     also been ported various times. Even though they are completely
>     different models (sync vs async, kernel vs userspace heft) there is
>     enough overlap that you wouldn't really want both. The latter brings
>     some compatibility with a commercially relevant OS.  Kirk indicated
>     support for bringing in Mach IPC in the past.
>
>
> I have some difficult to deliver news. I know that the author spent a
> fair amount of time on this, but we've already rejected one doors
> implementation. We removed it from the suggested project list.
> There don't seem to be any compelling applications that need this
> feature. Without frequent exercise, it creates a liability for the project
> because it increases the exposure to security issues.

That argument only works if almost nobody uses it.

The way I understand the Solaris style doors mechanism is that it has 
two big advantages over UNIX sockets.

The first is a quality of life improvement by handling resources 
exchange (file descriptors and shared memory). You could implement a 
very similar API on top of UNIX sockets. FreeBSD has inherited rpcgen 
from Sun and OpenBSD imsg is available in ports. Afaik rpcgen is barely 
maintained and lacks support FD passing and shared memory support. The 
OpenBSD imsg API isn't in base, also lacks shared memory support, but 
does support FD passing. We also have the nvlist based IPC grown for 
Capsicum, but nvlists are slow, memory hungry, iirc the IPC code wasn't 
designed to be reused as a general purpose IPC framework. A low overhead 
IPC API that works with event loops and threads and supports both FD 
passing and shared memory would be useful to have in base even without 
any kernel changes to make it faster than unix sockets e.g. bhyve would 
really profit from such an API, then there are unloved parts of the 
system like nscd/nsswitch (which iirc was one of the examples Sun used 
to show the advantages of doors back in the day), the nvlist IPC used by 
Casper is limited by the nvlist API to be blocking (nvlist 
xmit/recv/xchg). Blocklistd also had implement its own fd passing code, 
and rcd is currently growing the next.

The second advantage is that doors are supposed to integrate better with 
the scheduler than our UNIX socket implementation. In its sync IPC call 
version it allows the calling thread to be shuttled from the caller to 
the callee. This fixes usual pitfalls of priority inversions, CPU 
accounting, and at least claims to improve latency, jitter, and CPU 
overhead per IPC call. How would you like to see those performance goals 
be met? Can we do it using UNIX sockets e.g. a hint to yield your 
scheduler tick to the receiver for async messages or a new socket type 
that forces a request-response pattern on clients and servers and 
handles the fd moves (copies are already solved), shared memory, and 
scheduler interaction?


I vaguely remember that there have been previous attempts to before him, 
but didn't Bojan Novković (bnovkov@) also work on a doors implementation 
for FreeBSD around 5 or 6 years ago and got some tough feedback because 
the Solaris APIs don't map nicely on FreeBSD's threading? Do you 
remember how far that attempt got and why it was never imported?

> interesting applications there that use it.

Yes, but all of them would be new ports from macOS.

I have no real world experience using Mach IPC, but I remember it from 
my CS course work as a cautionary tale of what happens when your IPC 
primitive is overly general thereby effectively impossible to implement 
well. Mach IPC was supposed to be usable for remote virtual memory 
access in distributed systems in a time before ccNUMA hardware was 
available to most researchers. All the copies, access control, etc. 
added up to high fixed per message costs while doors are closer to an L4 
style sync IPC optimized for lots of small messages and the threads move 
between address spaces instead of copying everything.

Writing RPC and IPC frameworks is tedious, error prone, and mostly 
thankless work. I would like to see FreeBSD pick something that serves 
the needs of the base system (and ports) for fast local sync calls 
instead of supporting distributed systems and OS research. I don't care 
how it's called only that it works well, meets the performance and 
security requirements, and isn't too much of a PITA to program against.

What API do we want? Can it be implemented as a library in userspace 
today e.g. unix seqpacket sockets passing memfds holding shared 
condition variables? If it needs new kernel features wouldn't it be 
easier to implement a new unix socket type that enforces a 
request-response communication pattern, interacts with the scheduler as 
required, and maybe adding support for file descriptor move in addition 
to copy instead of implementing a completely new communication primitive?

--------------4MpI4Sb40nm0j5jjaqJUPgmW
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 18.11.26 04:16, Warner Losh wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANCZdfrR8nYeC5erKPenWsM_C1M0obE37nJn-h8N_eyM1KXw2A@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr"><br>
        </div>
        <br>
        <div class="gmail_quote gmail_quote_container">
          <div dir="ltr" class="gmail_attr">On Tue, Nov 17, 2026 at
            12:24 PM Kevin Bowling &lt;<a
              href="mailto:kevin.bowling@kev009.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">kevin.bowling@kev009.com</a>&gt;
            wrote:<br>
          </div>
          <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
            Tue, Nov 17, 2026 at 10:22 AM Adrian Chadd &lt;<a
              href="mailto:adrian@freebsd.org" target="_blank"
              moz-do-not-send="true" class="moz-txt-link-freetext">adrian@freebsd.org</a>&gt;
            wrote:<br>
            &gt;<br>
            &gt; hi!<br>
            &gt;<br>
            &gt; So I've taken a quick look. I've never come across
            doors before and I used Solaris in the early 2.x days!<br>
            &gt;<br>
            &gt; Whats the advantage of using this over other IPC
            models?<br>
            <br>
            I would want to see a weighing of Doors against Mach IPC
            which has<br>
            also been ported various times. Even though they are
            completely<br>
            different models (sync vs async, kernel vs userspace heft)
            there is<br>
            enough overlap that you wouldn't really want both. The
            latter brings<br>
            some compatibility with a commercially relevant OS.  Kirk
            indicated<br>
            support for bringing in Mach IPC in the past.<br>
          </blockquote>
          <div><br>
          </div>
          <div>I have some difficult to deliver news. I know that the
            author spent a</div>
          <div>fair amount of time on this, but w<span
              style="background-color:transparent">e've already rejected
              one doors</span></div>
          <div><span style="background-color:transparent">implementation.
              We removed it from the suggested project list. </span></div>
          <div>There don't seem to be any compelling applications that <span
              style="background-color:transparent">need this</span></div>
          <div><span style="background-color:transparent">feature.
              Without frequent exercise, it creates a liability for the
              project</span></div>
          <div><span style="background-color:transparent">because it
              increases the exposure to security issues. </span></div>
        </div>
      </div>
    </blockquote>
    <p>That argument only works if almost nobody uses it.</p>
    <p>The way I understand the Solaris style doors mechanism is that it
      has two big advantages over UNIX sockets.</p>
    <p>The first is a quality of life improvement by handling resources
      exchange (file descriptors and shared memory). You could implement
      a very similar API on top of UNIX sockets. FreeBSD has inherited
      rpcgen from Sun and OpenBSD imsg is available in ports. Afaik
      rpcgen is barely maintained and lacks support FD passing and
      shared memory support. The OpenBSD imsg API isn't in base, also
      lacks shared memory support, but does support FD passing. We also
      have the nvlist based IPC grown for Capsicum, but nvlists are
      slow, memory hungry, iirc the IPC code wasn't designed to be
      reused as a general purpose IPC framework. A low overhead IPC API
      that works with event loops and threads and supports both FD
      passing and shared memory would be useful to have in base even
      without any kernel changes to make it faster than unix sockets
      e.g. bhyve would really profit from such an API, then there are
      unloved parts of the system like nscd/nsswitch (which iirc was one
      of the examples Sun used to show the advantages of doors back in
      the day), the nvlist IPC used by Casper is limited by the nvlist
      API to be blocking (nvlist xmit/recv/xchg). Blocklistd also had
      implement its own fd passing code, and rcd is currently growing
      the next. </p>
    <p>The second advantage is that doors are supposed to integrate
      better with the scheduler than our UNIX socket implementation. In
      its sync IPC call version it allows the calling thread to be
      shuttled from the caller to the callee. This fixes usual pitfalls
      of priority inversions, CPU accounting, and at least claims to
      improve latency, jitter, and CPU overhead per IPC call. How would
      you like to see those performance goals be met? Can we do it using
      UNIX sockets e.g. a hint to yield your scheduler tick to the
      receiver for async messages or a new socket type that forces a
      request-response pattern on clients and servers and handles the fd
      moves (copies are already solved), shared memory, and scheduler
      interaction?</p>
    <p><br>
      I vaguely remember that there have been previous attempts to
      before him, but didn't Bojan Novković (bnovkov@) also work on a
      doors implementation for FreeBSD around 5 or 6 years ago and got
      some tough feedback because the Solaris APIs don't map nicely on
      FreeBSD's threading? Do you remember how far that attempt got and
      why it was never imported?</p>
    <blockquote type="cite"
cite="mid:CANCZdfrR8nYeC5erKPenWsM_C1M0obE37nJn-h8N_eyM1KXw2A@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote gmail_quote_container">
          <div>interesting applications there that use it.</div>
        </div>
      </div>
    </blockquote>
    <p>Yes, but all of them would be new ports from macOS. </p>
    <p>I have no real world experience using Mach IPC, but I remember it
      from my CS course work as a cautionary tale of what happens when
      your IPC primitive is overly general thereby effectively
      impossible to implement well. Mach IPC was supposed to be usable
      for remote virtual memory access in distributed systems in a time
      before ccNUMA hardware was available to most researchers. All the
      copies, access control, etc. added up to high fixed per message
      costs while doors are closer to an L4 style sync IPC optimized for
      lots of small messages and the threads move between address spaces
      instead of copying everything.</p>
    <p>Writing RPC and IPC frameworks is tedious, error prone, and
      mostly thankless work. I would like to see FreeBSD pick something
      that serves the needs of the base system (and ports) for fast
      local sync calls instead of supporting distributed systems and OS
      research. I don't care how it's called only that it works well,
      meets the performance and security requirements, and isn't too
      much of a PITA to program against.</p>
    <p>What API do we want? Can it be implemented as a library in
      userspace today e.g. unix seqpacket sockets passing memfds holding
      shared condition variables? If it needs new kernel features wouldn't
      it be easier to implement a new unix socket type that enforces a
      request-response communication pattern, interacts with the
      scheduler as required, and maybe adding support for file
      descriptor move in addition to copy instead of implementing a
      completely new communication primitive?</p>
  </body>
</html>

--------------4MpI4Sb40nm0j5jjaqJUPgmW--

