News for hackers. Stuff that matters.
Re:HelenOS: portable microkernel-based multiserver operating... by aidenn0 on Friday August 18, 2017 @01:09PM (#15047934)
There are, and always will be, performance disadvantages to a microkernel. However, for many many tasks the difference is negligible.

X11 has IPC, this has performance overhead, but nobody seriously suggests that all X11 applications run in the same process.

I work regularly with a microkernel that allows threads (including device driver threads) either in their own separate address space, or in the supervisor address space. The difference in debugability between "there was memory corruption in the kernel" and "there was memory corruptoin in this specific device driver" is huge.

The throughput overhead of message passing versus not on a data-heavy driver tends to be ~20%, though just like IPC in userspace multiprocessing systems you can reduce that somewhat with shared memory, batching and other tricks if needed.

But seriously when people worry about message-passing overhead, I feel like it's 1990 again and we are debating whether the context switch overhead of processes on UNIX is worth it. I'm not sure why the userspace battle was decided so long ago while the kernel debate still goes on.

[edit]

Also sometimes the natural design for a microkernel yields better performance than the natural design for a monlithic kernel. When you are pushing the envelope for performance, sometimes some very counterintuitive things can give you benefits. I have seen cases where a single copy was faster than zero-copy, and cases where the safety of no-shared memory allowed easier parallelization of the work.

Re:HelenOS: portable microkernel-based multiserver operating... by gue5t on Friday August 18, 2017 @01:49PM (#15048257)
+1 on single-copy frequently being faster than zero-copy. See https://lwn.net/Articles/580194/ for a real-world example from the Linux kernel.

On the topic at large, I think microkernel vs monolithic is not actually the important distinction in kernel design; robustness could improved vastly if the business logic of a kernel were implemented in a memory-safe language instead of C or C++. Register bashing and system setup won't ever be effectively captured by a typesystem (knowing what the semantics of hardware are is the hard problem, and GIGO applies to typesystems as much as anything), but most vulnerabilities are in code that doesn't directly interact with hardware (even if they're in a driver for some obscure hardware, it's generally the syscall-facing side that gets exploited).

I'd like to see more OS development look at non-UNIX designs, rather than trying a million different ways to implementa UNIX-like interface.

Re:HelenOS: portable microkernel-based multiserver operating... by aidenn0 on Friday August 18, 2017 @02:15PM (#15048474)
Also, as a note, high-reliability microkernels disallow direct access to DMA registers (as, absent an I/O MMU, being able to write to a DMA register is the same as being able to write to any physical memory), and instead provide an API for programming them that can be verified on its own. This is often just dozens of lines of code, so can be as correct as the hardware.

So the separation of register-bashing vs. the rest of the software already exists, but it solves the memory safety problem by just moving the unsafe code out of the kernel.

I agree that memory-safe languages need to come into low-level systems programming, but garbage-collection is a non-starter for many many reasons, and the various academic languages (e.g. cyclone) have not made any inroads to industry that I'm aware of.

Rust is very interesting to me in this field because the simple fact that it originated outside of academia may make it more palatable to many people; time will tell.

[edit]

I still think a microkernel is a good idea even with a memory-safe language just for defense in depth if nothing else (memory-safe runtimes tend to be complicated, and complicated code tends to have bugs).

Re:HelenOS: portable microkernel-based multiserver operating... by pjmlp on Saturday August 19, 2017 @02:18AM (#15051969)
> I agree that memory-safe languages need to come into low-level systems programming, but garbage-collection is a non-starter for many many reasons, and the various academic languages (e.g. cyclone) have not made any inroads to industry that I'm aware of.

Yet it was proven to work with:

- Mesa/Cedar at Xerox PARC

- Oberon, Oberon-2, Active Oberon at ETHZ

- Modula-2+, Modula-3 at DEC/Olivetti

- Sing# and System C# at MSR

Apparently we can only get it properly done if a big company bullies the developers to adopt such an approach.

Which is why I see as positive Apple, Google, Microsoft bullying devs to use mostly Swift, Java/Kotlin/Dart and .NET on their platforms, with C and C++'s role reduced to a few use cases.

It really annoys me when I need to use the NDK on Google's case, but somehow it makes sense from security point of view.

Re:HelenOS: portable microkernel-based multiserver operating... by wolfgke on Saturday August 19, 2017 @08:34AM (#15053023)
> Which is why I see as positive Apple, Google, Microsoft bullying devs to use mostly Swift, Java/Kotlin/Dart and .NET on their platforms, with C and C++'s role reduced to a few use cases.

Microsoft is actively encouraging developers to use C++ for development on Windows. The phase when Microsoft was trying to push (or as you call it "bully") developers into ".net for everything" is long gone.

Re:HelenOS: portable microkernel-based multiserver operating... by pjmlp on Saturday August 19, 2017 @08:57AM (#15053098)
Try to find C++ talks for Windows development on BUILD 2016 and 2017 archives.

Check how many C++ samples exist on the Windows 10 SDK samples.

See the blog about the new Windows UI Composition engine and which languages are being used on the demos.

Then let us know where is this active encouragement you are speaking about.

C++ is being driven down the stack as the implementation language for the UWP COM layer, kernel programming, graphics and audio.

Everything else is .NET Native.

Re:HelenOS: portable microkernel-based multiserver operating... by wolfgke on Saturday August 19, 2017 @02:35PM (#15054872)
> Try to find C++ talks for Windows development on BUILD 2016 and 2017 archives.

See the talks at CppCon 2016:

> https://channel9.msdn.com/Events/CPP/CppCon-2016

Re:HelenOS: portable microkernel-based multiserver operating... by pjmlp on Saturday August 19, 2017 @02:54PM (#15054972)
I watched those talks live.

Since October 2016 there is radio silence on the actual state of C++/WinRT, including the status of feature parity with C++/CX for XAML, Blend and creation of UWP components.

VS 2017 already had two releases since those presentations.

The only Microsoft talk at CppCon 2017 are about VS Code support for C++ and ANSI C++ compliance, nothing relevant to actual Windows 10 application development.

Any long time Windows developer is recognising the signs that UWP is turning into what Longhorn aspired to be, just remains to be seen how willing Microsoft is to keep pushing it.

[0] https://cppcon2017.sched.com/

Re:HelenOS: portable microkernel-based multiserver operating... by aidenn0 on Saturday August 19, 2017 @08:51PM (#15056404)
None of Swift/Java/Kotlin/Dart/.NET are serious challengers for low-level systems work.

It's those "few use cases" you are talking about that interest me.

Cedar had a GC-free, type-safe subset that used the typesystem for memory safety.

Re:HelenOS: portable microkernel-based multiserver operating... by pjmlp on Sunday August 20, 2017 @02:13AM (#15057176)
Depends, using Swift as an example.

"Swift is intended as a replacement for C-based languages (C, C++, and Objective-C)."

https://swift.org/about/

"Swift is a successor to both the C and Objective-C languages."

https://developer.apple.com/swift/

So while Swift might not be yet there, if Apple tomorrow releases a system that according to those statements, the only available SDK language is Swift, anyone that wants to be on that system will use Swift, regardless how serious challenger it might be.

As another example, are you aware that Brillo was supposed to be a pure C++ based variant of Android, before they pivoted it into Android Things? Now you can even write user space device drivers in Java.

Microsoft has also adding been adding low level features of System C# into C# roadmap, and UWP model (which they really want to be the future) only uses .NET Native. How far they will push it, who knows.

Windows 10 has a new UI composition engine, naturally it is programmed in DirectX with C++, however all the APIs are exposed as UWP projections and so far, every single demo I have seen used C#.

The big difference between OS companies and the FOSS world regarding systems programming, is that regardless how we think a given language is fitted for a given purpose, they can make it into the only door to the system.

But you are right they are clearly not yet there, and it remains to be seen how far they would actually bully devs into using only those languages.

Re:HelenOS: portable microkernel-based multiserver operating... by snvzz on Friday August 18, 2017 @01:30PM (#15048108)
>I feel like it's 1990 again and we are debating whether the context switch overhead of processes on UNIX is worth it.

Worth noting are modern (gen2/3, L4 onwards) microkernel context switch costs.

This article has a neat table in it. Third page.

http://sigops.org/sosp/sosp13/papers/p133-elphinstone.pdf

In contrast, Linux takes whole microseconds. This should be carefully considered when thinking about multiserver architecture overhead.

Re:HelenOS: portable microkernel-based multiserver operating... by aidenn0 on Friday August 18, 2017 @01:53PM (#15048302)
I'm guessing those are uncontended timings. I haven't been able to think of a good way to do it, but I'd like to see contended timings compared as well. Having a fast fast-path is great for many reasons (a fast fast-path will reduce contention all on its own, and systems can be designed to minimize contention), but the contended case can be much slower on some microkernels, and I have no idea what the overhead is on linux.
Re:HelenOS: portable microkernel-based multiserver operating... by gue5t on Friday August 18, 2017 @02:01PM (#15048378)
See this presentation about Google's scheduler patches, which claims the major overhead is logic in the scheduler (pg16): http://www.linuxplumbersconf.org/2013/ocw/system/presentatio...
Re:HelenOS: portable microkernel-based multiserver operating... by snvzz on Friday August 18, 2017 @02:09PM (#15048436)
This is interesting. I wonder what's keeping this kind of work from being mainlined. The present (as shown in the slides) Linux context switch times are painfully long.
Re:HelenOS: portable microkernel-based multiserver operating... by gue5t on Friday August 18, 2017 @02:33PM (#15048625)
Unless I'm mistaken, Google isn't interested in upstreaming these changes. A quick search of lmkl.org doesn't show any hits for the switchto_... APIs.

I'd love to hear otherwise or in more detail from someone at Google. It's frustrating to have to do archaeology just to guess what the state of the art is. Isn't sharing your findings part of "organizing the world's information"?

Re:HelenOS: portable microkernel-based multiserver operating... by noir_lord on Friday August 18, 2017 @08:06PM (#15050712)
"organizing the world's information" (when it's to our competitive advantage).

It's the bit on the end that sounds a lot less noble.

Re:HelenOS: portable microkernel-based multiserver operating... by appleflaxen on Sunday August 20, 2017 @10:57AM (#15058633)
wow; that's a good example of why GLP v3 has value to end users of free software: the GPL2 allows them not to share improvements. The GPL3 requires the source code to be available, if those machines are used to serve results to users.
Re:HelenOS: portable microkernel-based multiserver operating... by snvzz on Wednesday August 23, 2017 @12:32AM (#15078544)
Wouldn't that be the Affero license?
Re:HelenOS: portable microkernel-based multiserver operating... by snvzz on Friday August 18, 2017 @02:03PM (#15048394)
>uncontended timings

In the case of seL4, they are WCET (Worst Case Execution Time). That's as "contended" as it can possibly get.

They do provide formal proof of WCET, so these numbers are solid.

Re:HelenOS: portable microkernel-based multiserver operating... by aidenn0 on Friday August 18, 2017 @02:24PM (#15048543)
Are those really WCET? A L3 miss on an i7 4770 is ~60ns and they show 90ns total execution time. If that's true it's incredibly impressive.

[edit]

Also formal WCET analysis for various IPCs is really great and not something you can "bolt on" to a kernel not designed for it.

Re:HelenOS: portable microkernel-based multiserver operating... by snvzz on Friday August 18, 2017 @02:45PM (#15048718)
You might want to look into: http://ts.data61.csiro.au/projects/seL4/

Specifically:

Bernard Blackham, Yao Shi, Sudipta Chattopadhyay, Abhik Roychoudhury and Gernot Heiser

Timing analysis of a protected operating system kernel

IEEE Real-Time Systems Symposium, pp. 339-348, Vienna, Austria, November, 2011

---

TL;DR: They assume worst case for cache misses.

e.g.: "The latency of a read or write to physical memory on this platform was measured to be 80–100 cycles; in the static analysis we assume a 100-cycle penalty for all cache misses."

Re:HelenOS: portable microkernel-based multiserver operating... by aidenn0 on Sunday August 20, 2017 @04:59PM (#15060230)
That would mean ~2 cache lines are accessed for an IPC call, plus another 130 cycles for instructions. That's very impressive.