Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux-asahi: remove unnecessary kernel configuration #10

Closed
wants to merge 1 commit into from
Closed

linux-asahi: remove unnecessary kernel configuration #10

wants to merge 1 commit into from

Conversation

zzywysm
Copy link

@zzywysm zzywysm commented Apr 1, 2022

this removes various options from the Asahi kernel configuration that are very unlikely to ever be missed. This includes:

  • ancient filesystems
  • ancient USB devices
  • buggy networking code
  • a couple of types of kernel error injection (we have enough normal kernel errors, thanks)
  • CAN bus development
  • GPS support
  • SCSI jukebox support
  • USB tablet support
  • infrared

Additionally, we decrease the maximum number of sound cards from 32 to 8.

this removes various options from the Asahi kernel configuration that are very unlikely to ever be missed.   This includes:

- ancient filesystems
- ancient USB devices
- buggy networking code
- a couple of types of kernel error injection (we have enough normal kernel errors, thanks)
- CAN bus development
- GPS support
- SCSI jukebox support
- USB tablet support
- infrared

Additionally, we decrease the maximum number of sound cards from 32 to 8.
@goshhhy
Copy link

goshhhy commented Apr 1, 2022

...are you sure about all this?.

while there are some reasonable changes here, out of this, i personally use:

  • jfs
  • sgi partition tables (but i can work around this if nobody else cares)
  • SCTP (yes, i know, nobody else does. i won't actually fight this one)
  • USB CAN devices
  • SLIP
  • more than 8 sound devices (i do audio engineering on the side, and even if i ignore that equipment, the number of things in my fairly benign desktop setup that count as sound cards to linux totals to 7, which is cutting it very close)

and that's just skimming the list. this seems like a big chunk of stuff to just turn off, especially since you didn't really properly summarize what was disabled. there were a lot more SCSI things disabled than just jukebox support, for example.

@zzywysm
Copy link
Author

zzywysm commented Apr 1, 2022

...are you sure about all this?.

while there are some reasonable changes here, out of this, i personally use:

Every probability distribution has some interesting data points a few standard deviations out. 🤯

As this was targeted towards the default Asahi kernel, the focus was on things that were difficult/impossible to connect to an Apple Silicon Mac, things that are ancient and obscure, and things that constitute unnecessary kernel attack surface.

* jfs

This is over 30 years old and lightly maintained.

* sgi partition tables (but i can work around this if nobody else cares)

You use sgi partition tables on modern Linux systems?!

* SCTP (yes, i know, nobody else does. i won't actually fight this one)

This is a significant source of kernel CVEs.

* USB CAN devices

Either you are an automobile security researcher, or you are involved in unholy eldritch ceremonies.

* SLIP

I think I'm being trolled on April Fools' Day at this point.

* more than 8 sound devices (i do audio engineering on the side, and even if i ignore that equipment, the number of things in my _fairly benign_ desktop setup that count as sound cards to linux totals to 7, which is cutting it _very_ close)

Maybe I went too conservative here. As @marcan also does audio engineering, perhaps he also has a data point to share.

and that's just skimming the list. this seems like a big chunk of stuff to just turn off, especially since you didn't really properly summarize what was disabled. there were a lot more SCSI things disabled than just jukebox support, for example.

The SCSI things I turned off were because I deemed them unlikely to be plugged into an Apple Silicon Mac by the 99% of users who don't realize they could probably buy a Thunderbolt-to-PCIe adapter and negate a lot of my assumptions.

If you are in the 1% of users whose workflow is damaged by these changes, you are likely also in the 1% of users who know how to manually configure a Linux kernel and rebuild it yourself. 🤓

@Skirmisher
Copy link

Skirmisher commented Apr 1, 2022

I didn't know there was a usb/misc/appledisplay driver. Coincidentally, I was tinkering with an Apple Studio Display (17" LCD, ADC) recently, trying to figure out what sort of software support existed for controlling its brightness, only to discover that it and most other Apple USB displays are largely just standard Monitor Control Class devices, which are supported by ddcutil via standard HID commands. The appledisplay kernel driver seems a bit unloved and is lacking a lot of PIDs (acdcontrol has a somewhat more comprehensive list), but it does work and provides a backlight class device for all the usual consumers to make use of. Maybe at some point it could be reworked into a generic usb-mccs driver, to complement the likes of the ddcci module and its backlight controls.

Anyway, I'm typing this message on my M1 mini using that same monitor (first introduced to Asahi development at AsahiLinux/m1n1#159 (comment)), and now I can happily control the backlight from plasmashell. Thanks for tipping me off by removing the driver!

Seriously, though, these changes are spread across several different domains and don't strike me as necessarily considering that many niche, yet archetypal, usage patterns exist that you may not have knowledge of. Let me illustrate with some of the discussed examples:

  • sgi partition tables (but i can work around this if nobody else cares)

You use sgi partition tables on modern Linux systems?!

The SCSI2SD is a SCSI drive emulator commonly used by hobbyists in SGI MIPS systems. The SD card used with it can easily be removed, and I have manipulated such cards from Linux on a variety of occasions, even mounting the SGI XFS partition natively.

  • USB CAN devices

Either you are an automobile security researcher, or you are involved in unholy eldritch ceremonies.

CAN is well put to use in myriad embedded applications, both on hobbyist and professional scales. It's by no means limited to automotive use, or obtuse rituals.

I was also particularly struck by the device mapper target removals and similar, especially those that see use outside of testing (e.g. dm-cache, which I was considering for small-internal/large-external drive configuration on my 256G Mac mini), though the testing targets are just as important for filesystem developers, etc.

Anyway, I don't mean to harp on, but proposing a heterogeneous batch of config changes without even calculating a size/performance justification leaves a bad taste in my mouth. Obviously the choices are up to the project, and may depend on the goals of Asahi-the-distribution (is it intended to be a stable, general OS choice, or merely a jumping-off point? is being nearly identical to ALARM more important to present an upstream-like experience?). But for the moment, I wanted to share my perspective and make a few points I thought were salient.

Reducing kernel attack surface is noble though, and in some cases it does make sense, I'll give you that. Also, comprehensively configuring a distribution kernel is hell, and you have my sympathies.

@goshhhy
Copy link

goshhhy commented Apr 1, 2022

i don't do april fools.

i am an embedded software developer, both by trade and hobby. given that context, i think CAN and SLIP should make much more sense (on a constrained system, SLIP has a lot less overhead, and its downsides don't matter much). and yes, i have worked in the automotive space, but I currently do not. CAN is used outside of that space as well. GPS is also something that ends up in use in my industry, and was a central concern at a previous employer of mine.

my job is made quite convenient by the fact that most of what my coworkers and i require, the above items included, can already be found in distro kernels. on most distros, maintaining your own kernel config can be rather annoying, and some clients i work with cannot build their own kernels due to corporate restrictions (thankfully i usually am not under this restriction), so what they have in the distro kernel is all they get. this kernel configuration most certainly counts as a distro kernel. since my employer does sometimes purchase macs, it is not out of the question that my coworkers or I could at some point in the future be doing our work from M1 hardware running Asahi. it would be nice if the things we need are in it, should that happen.

my use of SGI partition tables is the same as that of @Skirmisher and my reason for JFS is similar (it's nice to be able to read ArcaOS partitions from other machines)

@zzywysm
Copy link
Author

zzywysm commented Apr 2, 2022

on most distros, maintaining your own kernel config can be rather annoying, and some clients i work with cannot build their own kernels due to corporate restrictions (thankfully i usually am not under this restriction), so what they have in the distro kernel is all they get. this kernel configuration most certainly counts as a distro kernel. since my employer does sometimes purchase macs, it is not out of the question that my coworkers or I could at some point in the future be doing our work from M1 hardware running Asahi. it would be nice if the things we need are in it, should that happen.

I am eager to apply to this corporation that doesn't allow you to replace the stock distro kernel, but does allow you to type curl | sh to install an entirely brand-new operating system on your company hardware. They sound pretty wild.

Anyway, count me chagrined. I'll leave this pull request open, in case Hector has a different philosophy towards this (seeing as he's the one of the people rebuilding the Asahi kernel the most and may appreciate build-time improvements).

@nekopsykose
Copy link

Additionally, we decrease the maximum number of sound cards from 32 to 8.

i'm confused- does this somehow make the kernel take half the time to build or something? what benefit is there to this?

@rockinrobstar
Copy link

To quote Spock “The Needs of the Many Outweigh the Needs of the Few”.

I have just compiled a custom kernel and it took almost 2 hours on an M1 Pro with the default config (no docs). I too would like to see a sensible .config file. I don't think its fair to collectively waste everyone's times compiling subsystems that are unlikely to ever get used by most users. If you need something special, I don't understand why you can't just turn it on. Obviously there will be some give and take finding a balance point.

@jannau
Copy link
Member

jannau commented Apr 2, 2022

I have just compiled a custom kernel and it took almost 2 hours on an M1 Pro with the default config (no docs). …

How did you compile the kernel? it should not take 2 hours. rebuilding linux-asahi with makepkg takes less than 4 minutes on a M1 Ultra. I would expect something around 10 minutes on a M1 Pro (with 6 performance cores). almost 2 hours seems too long even when just using a single make job.

@marcan
Copy link
Member

marcan commented Apr 12, 2022

Our job is not to ship cut-down kernels; we're using a kernel config derived from upstream ALARM intended to support as many users as possible without recompilation. For example, the only reason we don't have the entire world of PCI drivers compiled is because there is no Thunderbolt support yet. Once that's in, I will enable every PCI driver under the sun as most distros do.

If you would like to have a slimmed-down kernel you are certainly free to compile your own, but there is no "sane" slimmed-down config because invariably every person who wants that (which includes myself) has a different idea of what should go in and what shouldn't. That's why I compile my own kernels for my main systems, and you should too. The linux-asahi package will remain generic and with wide support for hardware, even weird stuff.

FWIW, compile times are 4-5 minutes on a 10-core M1 Pro for me. That's a non-issue.

@marcan marcan closed this Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants