151
submitted 10 months ago by [email protected] to c/[email protected]

I've seen people talking about it and experienced it myself with a server, but why does Linux run so well on ARM (especially compared to Windows)?

top 50 comments
sorted by: hot top controversial new old
[-] [email protected] 120 points 10 months ago

I don't think it's just Linux. I've been told MacOS also works very well on ARM. Maybe it's just Microsoft doing a bad job.

[-] [email protected] 80 points 10 months ago

Maybe it's just Microsoft doing a bad job.

The hell you say.

[-] [email protected] 54 points 10 months ago

I don't believe it.

You mean to tell me that Microsoft is doing a bad job with thier OS???

Preposterous. These 100 or so processes that its running to track my every breath are incredibly important to make sure im given the best ad experience.

load more comments (1 replies)
[-] [email protected] 50 points 10 months ago

They still struggle to make it work good on x86 ;D

[-] [email protected] 37 points 10 months ago* (last edited 10 months ago)

Mac OS was running on RISC processors back in the 90s, and Steve Jobs used them in his NeXT computers which used a variation of BSD, which was the basis for OS X which could run on PowerPC.

Apple’s had a ton of experience with RISC so it makes sense they’d do it well.

[-] [email protected] 7 points 10 months ago

It’s mainly due to PA Semi acquisition. These guys were the ones responsible of making excellent PowerPC processors, which were similar to what ARM has now.

These guys are probably happier now that they have more resources, target devices and tightly coupled software.

load more comments (3 replies)
[-] [email protected] 11 points 10 months ago* (last edited 10 months ago)

Well MacOS is because of a controlled ecosystem/hardware and a really good emulator, but IDK about Linux

Also yes Windows on ARM is a steaming pile of garbage

[-] [email protected] 13 points 10 months ago

Yeah. Linux is also optimized to run well. Has a capable community and a few good design choices. Many people use it to run it on servers so I wouldn't be surprised if it performed well well on servers.

Also there is a well known fork that is used on millions/billions(?) of ARM phones. So it'd better be a good choice for that use case.

[-] [email protected] 6 points 10 months ago* (last edited 10 months ago)

Microsoft absolutely could have made something comparable to Rosetta 2 for userspace if they were competent.

Rosetta 2 isn't an emulator, but a binary recompiler. It takes amd64 instructions, decodes them, and generates equivalent aarch64 instructions. The aarch64 instructions are then executed directly by the processor, performing the same tasks that the original binary would do on an Intel processor.

It's extremely difficult to do properly, but it's nothing inherently special to MacOS or Apple's ARM chips. ARMv8 has an attribute to enable strongly-ordered memory accesses, and it also supports native 4 KiB page sizes. Beyond those two solved concerns, there isn't any actual hardware barrier preventing binary translation. Individual amd64 instructions can be translated into one or more equivalent aarach64 instructions, and complex instructions or those using large registers like those in AVX-512 can be shimmed and implemented in software. An offset table can be used to deal with indirect jumps, and direct jumps can just be rewritten in the generated code. And as Apple has proven, it's even possible to support JIT-compiled code by intercepting jumps into executable pages and recompiling them before executing.

It's expensive in terms of time and engineering skills, but Microsoft had more than enough control over their own proprietary kernel to build something similar into Windows back when they first released it for ARM.

[-] [email protected] 7 points 10 months ago

Rosetta certainly does emulate* x86. It can dynamically recompile x86 instructions to ARM instructions, otherwise applications that include an x86 JIT wouldn't work at all on ARM Macs.

* I know people will be pedantic about this... but other emulators (Dolphin, PCSX2 etc) have included a recompiler for ages and no one seemed to have a problem calling them emulators.

load more comments (1 replies)
load more comments (2 replies)
[-] [email protected] 6 points 10 months ago

I have an M1 mbp for work and its honestly unbelievable. It's one of the nicest machines I've owned in years. The chip is a huge part of it.

[-] [email protected] 68 points 10 months ago

I mean… On Linux you’re going to be running a bunch of open source applications that have been compiled for ARM specifically. A huge problem with Windows on ARM is going to be running legacy x86 / x86_64 applications. You’re probably not contending with this problem at all on Linux, and I suspect if you were you would be similarly unimpressed (you can get Linux to transparently execute executables for different platforms using binfmt_misc and qemu but it’s slooooooow).

Honestly the better question might be why the Mac transition to Apple silicon has been so smooth. Part of this is that Apple cares a lot less about keeping legacy software working and companies will make native versions of their software ASAP. But Apple also has a good translation layer with Rosetta for this, and has custom silicon (which Microsoft does not) and I would not be surprised if part of this custom silicon involves extended instructions which make running x86 applications more feasible, but I don’t know the details and this is just speculation on my part.

[-] [email protected] 19 points 10 months ago

Apple designed the silicon to have an "x86 mode" for the memory model ordering, as well as an undocumented mode that makes certain arm instructions set flags similarly to x86. There's a good write up of the reasons here: https://dougallj.wordpress.com/2022/11/09/why-is-rosetta-2-fast/

[-] [email protected] 13 points 10 months ago

Apple hit a sweet spot with this. x86_64 applications run at acceptable speed (making the transition easy for people who buy the hardware) while not being SO good that there's zero reason for developers to start porting their software.

[-] [email protected] 11 points 10 months ago

Small correction: the flag setting modes aren't undocumented. They're standardized extensions. ARMv8.4 added FEAT_FlagM, and ARMv8.5 added FEAT_FlagM2.

https://developer.arm.com/downloads/-/exploration-tools/feature-names-for-a-profile

IIRC, the only nonstandard ARM extension used by Rosetta 2 in Apple's processors is TSO, and that's also implemented by other manufacturers. It's also not a hard requirement to run amd64 under ARM. You can emulate it very slowly or restrict the application to a single core.

Apologies for the tangent, but I needed to make sure nobody could defend Microsoft's prior failings by saying "but Apple has secret hardware sauce".

load more comments (1 replies)
[-] [email protected] 7 points 10 months ago

In 2011 Microsoft released Windows RT, and it was specifically designed to run on ARM hardware. Everyone hated it, and it never really became anything. Well, you can’t blame MS for not trying. Maybe the time just wasn’t right for that sort of radical transition. Everyone was complaining that you can’t even install anything other than the handful of applications available at the store.

[-] [email protected] 8 points 10 months ago

Windows 10 and 11 both have ARM versions. 11's ARM version has had some major updates recently.

load more comments (4 replies)
[-] [email protected] 6 points 10 months ago

This is overall very true but the transition even for Apple was anything but smooth. There was a long period of time during which app support for ARM was pretty hit or miss. Happily that period is just about over and now everything is built for all archs.

[-] [email protected] 12 points 10 months ago

I dunno, overall Rosetta 2 seems to be incredibly successful. It seems like most people were able to transition without worrying too much about whether their software would work at all or not, which I think is undoubtedly the smoothest an architecture transition like this has ever been.

load more comments (1 replies)
load more comments (1 replies)
[-] [email protected] 58 points 10 months ago

Windows’s achilles heel is arguably its chief benefit - legacy compatibility and being the de facto platform for applications.

Back when I had a Surface RT, I thought it was awfully neat, ARM-compiled versions of Office, IE, Windows 8.x bits ran well and it was fanless with fine battery life. (although I surely sound weird, I had a Windows Phone back then too and the syncing with IE on both was a nice feature) It’s just they were pushing the Store then and if you jailbroke it, ARM applications were rare.

Apple is a pro at architecture transitions and can steer the whole ship, MS can put Windows on ARM all they want but OEM’s will be reluctant since it’ll be a relatively big risk to sell a “Windows, buuut…” computer and the popular closed-source applications probably won’t bother with ARM for a while

[-] [email protected] 40 points 10 months ago

Apple is a "pro" because it is a forced-migration, the eventual upgrade path is forced so the vendors have to follow if they want to support Mac. This is the reason there is vendor adoption on Mac, and not on Windows. I think until ARM has a significant market share on Windows the vendors will not port their software.

[-] [email protected] 22 points 10 months ago

I know the cool thing is to hate on Apple for being Apple, but they have actually done a solid job with their transitions between instruction set architectures.

Ultimately, software developers and end users are forced to use the newer architecture, yes. But credit where credit is due, Apple chose to take the path of providing both hardware and software level facilities to make the transitions as seamless as possible over years-long timespans. They could have simply refused to support older architectures to force a migration down our throats, and indoctrinated fanboys would have opened their wallets anyway.

What they actually did was create compatibility layers, a multi-architecture executable file format, and binary translation frameworks built into the operating system. I fucking despise them for creating a walled-garden ecosystem and cult around their products, but I genuinely have to respect them for Rosetta and Rosetta 2. Developing a binary translation layer is a whole different beast than high-level emulation, and it's significantly more difficult to pull off correctly. The fact that they managed to do it twice, and do it damn-near seamlessly is impressive. Rosetta 2 even supports translating just-in-time compiled code, which is a huge pain point for that kind of thing.

[-] [email protected] 10 points 10 months ago

If you follow the history of the Mac, it went through a number of major architecture transitions from 680x0 -> PowerPC -> Intel -> ARM. Each time, Apple supplied a decent emulator to support applications during the transition.

From a developer perspective, these were huge upheavals that came with a lot of drama but also offered some opportunities. The latter came from the fact that the bar was in some way set higher on the new platform and you could count on any code you compiled for it supporting certain base features. Every PowerPC, for example, had hardware floating-point. Before that, some CPUs did, some didn't. The Intel transition happened at the time when dual core had become standard and SIMD had become serviceable (with SSE2). The ARM transition has set the bar at 64-bit architecture for every CPU (since Apple had earlier dumped 32-bit on the iPhone side).

Windows/Intel has developed in a more evolutionary than revolutionary manner, which is easy to see if you look, for example, at all the legacy cruft in the Intel ISA. It's a sad sight. Supporting all that makes instruction decoding a nightmare. In theory, Intel/AMD could reinvent a new sleeker ISA if they could get Microsoft to commit to supplying a performant emulator for the old one? But I'm not holding my breath.

load more comments (1 replies)
[-] [email protected] 57 points 10 months ago

Linux, and much of the open-source software that goes with it, has been multi-architecture for a long time. If you take something that already runs pretty decently on x86, x86_64, PA-RISC, Motorola 68000, PowerPC, MIPS, SPARC, and Intel Itanium CPUs, porting it to yet another architecture is, while not trivial, at least mostly a known problem.

Windows, by contrast, was built for descendants of the Intel 8088, period. It's unsurprising that porting it is a hard problem and that results aren't always satisfactory.

(Apple built on top of a modified BSD kernel, and BSD has also been ported around quite a bit, so they also have a ports-are-a-known-problem advantage.)

[-] [email protected] 6 points 10 months ago

Windows, by contrast, was built for descendants of the Intel 8088, period.

This is not quite true. Windows NT was built to support multiple architectures from the start.

[-] [email protected] 18 points 10 months ago

NT is not the majority of windows code though; for windows to be multi architecture, all of windows needs to work with the new architecture; NT, drivers & userspace.

For Linux, if an existing userspace application doesn't work in aarch64, somebody somewhere will build a port. For windows, so much of their stuff is proprietary that Microsoft are the only ones able to build that port.

Not because "windows bad", just a consequence of such a locked down system which doesn't have anything open source to inherit.

load more comments (1 replies)
load more comments (5 replies)
[-] [email protected] 43 points 10 months ago

Why does Linux run so well everywhere?

[-] [email protected] 42 points 10 months ago

Linux runs well on practically every CPU architecture.

[-] [email protected] 10 points 10 months ago* (last edited 10 months ago)
[-] [email protected] 35 points 10 months ago

Because it's open source and most of the applications for it are open source. That means you can compile it and the applications specifically for the hardware you have.

Windows does kind of support ARM on its specific hardware, but it can't be adjusted for other hardware and they have to translate most applications to work. Apple has done much of that work for their hardware to work well, as well as very good translation for x86, and because they leaned hard into the transition, developers were mostly forced to compile for ARM going forward. Microsoft hasn't done the same, and ARM is a tiny target, so it doesn't happen with any regularity there.

[-] [email protected] 20 points 10 months ago

Because people have been doing so for a long time and have ironed out most of the quirks. The software is also generally quite simple, meaning there are just fewer quirks that need to be ironed out. And the ecosystem is largely open source, meaning everything can be recompiled to target the relevant architecture, so while translation layers are still useful, they're not the essential tool they are in proprietary ecosystems. The main headaches that plague windows on arm mostly just don't exist on the Linux side.

[-] [email protected] 16 points 10 months ago

Because it's not developed by some corporate fuckers whose only goal it is to make as much money as possible, it's developed by individual skilled people in their free time, because they're passionate. They don't want to sell some garbage, they genuinely want to make a good operating system for themselves and everyone else to freely use without any restrictions. FOSS is not about the money, it's about actually creating something good.

[-] [email protected] 11 points 10 months ago

Because you can try compile it on arm, and if something doesn't work you can report it or fix it yourself. That said windows worked fine on arm years ago. Many gps, medical, and such devices used to use windows ce on arm, mips. (Windows phone too, arm)

[-] [email protected] 8 points 10 months ago

ARM the company as well as industry partners contribute code & resources to the linux kernel...so that would be one reason why linux on ARM runs well.

Unsure how we are tracking Microsoft ARM as worse than Linux arm, what benchmarks did we see?

[-] [email protected] 29 points 10 months ago

Linux has been on ARM since the 90s and Acorn days. Russell King is a large name to thank for the maturity of Linux on ARM.

http://www.home.armlinux.org.uk/~rmk/personal/

[-] [email protected] 20 points 10 months ago

Many ARM boards (including raspberry pis) are designed to run with linux. So the manufacturers can customize the kernel and firmware for the boards.

[-] [email protected] 14 points 10 months ago

*laughs to the tune of "I bet this mf has never even heard of a devicetree" *

load more comments (4 replies)
[-] [email protected] 14 points 10 months ago* (last edited 10 months ago)

I've run Linux on a Rockchip Chromebook, several Pi boards, and an M1 Macbook Pro, all with good results. I think that it helps that Linux comes from a long lineage of highly portable operating systems. One of the early victories of Unix was its ease of portability to new types of processor, due (at least in part) to being programmed in C. The BSDs and Linux have always had developers who took joy in getting the operating system up and running on more than one type of architecture. Debian, for instance, has run on one sort of ARM chip or another since around 2000. Windows has a core business that thrives on X86-based chip designs and they have had very little pressure to branch out over the years. Computer companies build around their operating system, rather than the other way around.

load more comments (6 replies)
[-] [email protected] 12 points 10 months ago

Having tried a Surface X back in the day, I don't know what you mean. Windows runs on ARM just fine. In fact, Windows 8 was an excellent OS for tablets that only sucked because Microsoft had to push the tabllet UI to deskrops without touch screen. The only reason it doesn't run on all boards is the exclusivity deal they signed with Qualcom and Microsoft's lack of interest. The bargain bin devices that do run Windows on ARM have terrible hardware that would probably run slowly if you installed ChromeOS or Linux too.

In fact, Microsoft actually has the sway necessary to force manufacturers to cut their stupid uBoot crap. Running Linux on an ARM board absolutely sucks ass. Many drivers are lacking, kernels need to be built specifically for your hardware as if you're running Gentoo in 2005, or you'll need the custom kernel the manufacturer made five years ago and never updated. Some manufacturers (Raspberry etc.) publish their own kernels, but those are rarely up to date with upstream.

Windows doesn't have generic ARM drivers to run om anything and getting Linux to work on ARM sucks. Unlike x64, ARM doesn't have a standard boot method (it has uefi but only on Windows devices really) so running anything custom is a terrible experience.

The only thing making Linux remotely usable on ARM is the Android kernel that can be used as a reference to write decent drivers for upstreaming (see: postmarketos). Android devices are usually stuck with whatever major+minor (LTS) version they shipped with, only receiving security updates (occasionally) unless volunteers toil at porting the alterations to something upstreamable. I suppose there are more people writing Linux drivers in their free time than there are people writing Windows drivers for free, but that's got little to do with the technical design of either kernel.

Microsoft has launched an ARM devkit and I haven't seen any major complaints other than that Apple's CPUs are much faster in comparison. That thing would probably run Linux just as fine.

[-] [email protected] 7 points 10 months ago

Raspberry pi works fine with linux, cutiePi also. my iomega nas is an arm board running debian...i don't see the issue

[-] [email protected] 8 points 10 months ago

The Raspberry Pi is an exception. It has taken until 2021-2022 for things like video acceleration to work using the normal Linux kernel (not the Raspberry Pi customised one with patches that only that kernel uses). For at least half a decade, you needed a custom kernel with device specific patches or the darn thing just wouldn't work.

Now it mostly works, though the RPi people do keep a separate kernel around with a few patches that they consider better than the ones the Linux kernel has merged.

If you take any other device with a similar board (like RPi clones with an m.2 slot) you'll have to mess with special drivers yet again.

Pi-like devices also use a special configuration setup (a fat32 partition with some hardcoded file paths) that normal ARM boards don't use. That's because you need the closed source Raspberry Pi bootloader to actually get the device to boot.

Imagine having to install grub-msi-gaming-laptops-2021 instead of grub in your desktop. Yes, it works, ut It's all custom with special code and tricks. This is also why you can just insert a USB drive and install Linux on PC but need to deal with special images you flash to the SD card for Pi-likes.

load more comments (6 replies)
load more comments (2 replies)
[-] [email protected] 11 points 10 months ago

Windows is LLP64 which is dumb while Linux is LP64.

Ok. That only impacts C/C++ porting but still it's a silly choice by windows.

[-] [email protected] 9 points 10 months ago

Linux has a low footprint, similar to ARM, so the two were naturally combined for low footprint platforms like Android and Raspberry Pis.

The open-source ecosystem also helped. If proprietary software is compiled only for x86, then the best you can do, is to try to run them with a translation layer.
With open-source, you can compile them for ARM yourself. No guarantees that that will just work, but devs can contribute fixes and eventually the original software package can be officially released with an ARM package.

[-] [email protected] 8 points 10 months ago

Relative to what? Relative to LINUX on Intel? Relative to Windows on ARM?

[-] [email protected] 7 points 10 months ago

Just in general, Linux on ARM more often than not just... works. Compared to Windows on ARM, that's an anomaly (yes I know part of the reason is Microsoft is just bad at making it, but there's got to be more to the Linux side for it to be that good)

[-] [email protected] 9 points 10 months ago* (last edited 10 months ago)

A key factor is LINUX has been available for ARM since nearly "the beginning". Unlike Windows, which was basically Intel only for well over a decade, LINUX has had strong support for multiple architectures throughout its lifecycle. As a result, software that grew up within that ecosystem tended to be more agnostic in design which helps porting efforts.

[-] [email protected] 6 points 10 months ago

so well

What do you mean?

load more comments
view more: next ›
this post was submitted on 20 Aug 2023
151 points (93.1% liked)

Linux

45352 readers
1157 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS