
How the ARM32 Kernel Starts - trulyrandom
https://people.kernel.org/linusw/how-the-arm32-kernel-starts
======
KMag
This article starts out talking about Linux address space layout. I've heard
Solaris sometimes allocated userspace pages in the upper half of 64-bit
address spaces. I'm guessing that by this point, it's too baked into Linux to
change.

But, if you ever find yourself writing an OS, consider running userspace as
much as possible near the top of a 64-bit address space. When the first 13
bits of a 64-bit pointer are set, a pointer interpreted as an IEEE-754 double
comes out as NaN. The NaNboxing an NuNboxing tricks used by many dynamically
typed programming languages become no-ops if all of your userspace pages are
in the top 2 petabytes of the address space.

~~~
hamstergene
On the other hand, if you ever find yourself writing a programming language,
consider making it statically typed.

In the world of mobile devices where CPU is battery life, why create a
language that is ~10x slower for no user benefit and makes people contemplate
about designing the whole OS around its performance issues?

~~~
KMag
Well, NaN boxing/NuN boxing would also allow you to more densely encode
algebraic data type variants in statically typed languages in the case where
at least one variant is a IEEE-754 double, some of the variants are
references/pointers, and none of the variants take more than 8 bytes.

Granted, it's not a common use case. Neither Rust nor OCaml use this space
optimization, but they could. OCaml (at least used to, back in the early
2000s) made the maximum tuple/object size smaller in other to have some bits
(8 bits, IIRC) to store the variant in the object header. I'm not actually
sure how Rust decides how many bits to dedicate to encoding the variant, and I
have very little knowledge of GHC internals.

I'm a big fan of Rust (and to some extent, C++), but there's a ton of CPU time
being spent on JavaScript execution worldwide.

------
liuyong
So, the 'linusw' in the link[1] means it's an article of Linus, or some people
else also named Linus?

[1] [https://people.kernel.org/linusw/how-the-arm32-kernel-
starts](https://people.kernel.org/linusw/how-the-arm32-kernel-starts)

~~~
throwaway8941
[https://github.com/linusw](https://github.com/linusw)

~~~
liuyong
You are right. Linus Walleij's name is on the list of kernel maintainers[1].

[1]
[https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS)

------
jagged-chisel
[Linux], no?

~~~
BanazirGalbasi
Yes, kernel.org is the archive for the Linux kernel. I didn't realize that
they publish articles though, which is pretty neat.

