this post was submitted on 20 Aug 2023
152 points (93.2% liked)

Linux

48329 readers
668 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
 

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)?

you are viewing a single comment's thread
view the rest of the comments
[–] h3ndrik@feddit.de 121 points 1 year ago (5 children)

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.

[–] seitanic@lemmy.sdf.org 81 points 1 year ago (2 children)

Maybe it's just Microsoft doing a bad job.

The hell you say.

[–] Bluefruit@lemmy.world 55 points 1 year 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.

[–] potpie@beehaw.org 1 points 1 year ago

Stephen's dad, is that you?

[–] Sinirlan@lemmy.world 51 points 1 year ago

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

[–] Semi-Hemi-Demigod@kbin.social 37 points 1 year ago* (last edited 1 year ago) (3 children)

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.

[–] darkghosthunter@lemmy.ml 7 points 1 year 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.

[–] LeFantome@programming.dev 5 points 1 year ago (1 children)

NeXT computers were based on Motorola 680x0 processors that were actually CISC ( not RISC ). Steve Jobs did run MacOS on RISC in the 90s though as that is what PowerPC was.

Modern Apple silicon is of course ARM64 so not the same architecture as PowerPC at all.

[–] Bene7rddso@feddit.de 1 points 1 year ago

NeXTStep ran on multiple architectures, some oft them RISC. They did some work on a PPC build too

[–] xusontha@ls.buckodr.ink 11 points 1 year ago* (last edited 1 year ago) (4 children)

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

[–] h3ndrik@feddit.de 13 points 1 year 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.

[–] pivot_root@lemmy.world 6 points 1 year ago* (last edited 1 year ago) (1 children)

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.

[–] orangeboats@lemmy.world 7 points 1 year ago (1 children)

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.

[–] pivot_root@lemmy.world 4 points 1 year ago

As far as people hypothetically being pedantic about it being an emulator, it does meet the dictionary definition of "hardware or software that permits programs written for one computer to be run on another computer." Personally, I don't see as one, though. It's more like WINE with a binary translator slapped onto it.

Dynamic recompilation is a part of modern emulators, but it's only a tiny piece. Software like Dolphin or Yuzu don't just provide a way to run non-native instruction sets, but provide a full environment mimicking the guest hardware. Things like low-level emulation of hardware components, high-level emulation (shims) of guest operating system APIs, and a virtual memory space for the programs to operate in.

The only significant thing Rosetta does is recompile the instructions of the guest program. All the APIs and abstractions the amd64-compiled program uses are available natively. If I recall correctly there are shims for bridging between the calling convention of the host and the recompiled-amd64 functions, but they don't do much more work than that.

Another one of my reasons for not considering it to be an emulator is because it primarily goes for ahead-of-time cached recompilation. It definitely does JIT translation as you mentioned, but as a way to support amd64 JIT-generated code. In contrast, Dolphin and other emulators* rely on cached JIT recompiling or interpreting for everything related to executing the guest instructions.

* Notable exceptions are Cxbx (Xbox -> Windows) and vita2hos (PS Vita -> Switch), which are emulators for platforms with compatible instructions sets. They work like WINE instead of JIT-recompiling or interpreting code, which is pretty cool.

[–] netchami@sh.itjust.works 3 points 1 year ago

Also yes Windows on ARM is a steaming pile of garbage

Not just on ARM. Windows is and will always be a proprietary steaming pile of shit, no matter what architecture. That will be the case as long as Microsoft develops it.

[–] Doombot1@beehaw.org 3 points 1 year ago

Windows ~~on ARM~~ is a steaming pile of garbage

[–] thelastknowngod@lemm.ee 6 points 1 year 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.