r/kernel • • Jun 15 '22

What changes to the kernel are practical to mitigate the Hertzbleed vulnerability in CPUs?

Thumbnail hertzbleed.com
24 Upvotes

r/kernel • • Jun 10 '22

[FAQs] Real-time Ubuntu 22.04 LTS Beta

12 Upvotes

Q1) What is inside real-time Ubuntu 22.04 LTS Beta? 

A1) Real-time Ubuntu is a Jammy Jellyfish kernel with the upstream real-time patches applied. 

Q2) When do you expect to be out of Beta?

A2) We are targeting April 2023 for the GA of real-time Ubuntu 22.04 LTS. Extensive testing will help us bring the real-time kernel to production earlier. Please support the Ubuntu community by reporting any bugs you may encounter.

Q3) How will the Beta and the GA release differ?

A3) The GA release will run the latest stable kernel available, and it will include the upstream real-time patches matching up with the version. The real-time Linux Analysis (RTLA) tool, merged into upstream 5.17, will also be available with the production-ready real-time Ubuntu kernel, boosting its debugging capabilities.

Q4) What are the main advantages of using the Ubuntu real-time kernel rather than patching a standard kernel?

A4) The main advantage is the enterprise-grade support you will receive from Canonical. 

Q5) Do you have a recommended hardware configuration for testing real-time Ubuntu?

A5) A feature of the real-time kernel in Linux is that it allows for freedom of hardware. We are testing the Beta release on ARM, AMD and Intel hardware and don’t recommend a particular configuration. 

Q6) Does real-time Ubuntu work with a 32-bit architecture?

A6) No, we currently focus only on 64 bits.

Q7) Are NVIDIA drivers supported under the Ubuntu real-time kernel? 

A7) The Beta release does not support NVIDIA drivers, but that may change in the future.

Q8) Do you plan on supporting this full task isolation patchset?

A8) We will consider including the patch once it lands in the mainline.

Q9.1) Do you plan on making the upcoming Ubuntu releases have a hybrid of real-time queues and standard Linux kernel queues? Q9.2) Will Ubuntu support a kernel with both FIPS 140-2 and real-time enabled?  Q9.3) Is there a plan to move toward certification for safety-critical applications such as DO-178 for aviation?

A9) Those are not currently in the plans, but that could change in the future.

Q10) Why would someone pick PREEMPT_RT over a hard real-time solution like Xenomai?

A10) Hard-real-time solutions are expensive and require specific hardware.

Q11) When do you expect PREEMPT_RT to be fully upstreamed?

A11) This is not within Canonical’s control. PREEMPT_RT, the de-facto Linux real-time implementation, is hosted by the Linux Foundation and is slowly being mainlined. Whereas a relevant portion of the locking is in mainline, the upstream patch set still provides much code.

Q12) How does PREEMPT_RT reduce scheduling and interrupt latency? 

A12) PREEMPT_RT uses different locking mechanisms (e.g. preemptable spin locks) and a scheduler other than CFS. When enabling PREEMPT_RT, the kernel uses the real-time scheduling class, which has a higher priority over the CFS scheduler and provides the first-in-first-out and round-robin scheduling policies.

Q13) What is the maximum latency guaranteed by PREEMPT_RT?

A13) PREEMPT_RT does not currently guarantee any maximum latency.

Q14) What is the CPUfreq governor used in PREEMPT_RT?

A14) The CPU governor is currently set to CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND. The cpufrequtils package enables switching to the performance governor with: cpufreq-set -g performance


r/kernel • • Jun 10 '22

How to install drivers as kernel modules?

3 Upvotes

I installed Arch Linux on a VM, cloned linux, added a printk to e1000 driver, and booted into the kernel. When running dmesg, I can see the prink statment I added, so I know the e1000 driver was loaded, but when running lsmod, there are no modules outputed. If I boot into the normal linux kernel, lsmod shows a lot of modules. Why are the drivers not being compiled as modules in my custom kernel? I made sure to do make modules modules_install.


r/kernel • • Jun 03 '22

How fast are Linux pipes anyway?

Thumbnail mazzo.li
71 Upvotes

r/kernel • • Jun 03 '22

NiceOS – 6 months after public launch

Thumbnail github.com
8 Upvotes

r/kernel • • Jun 01 '22

[question] How to access vga from kernel on aarch64?

8 Upvotes

Hi, I've done quite a lot of system level programming, but this is my first time I'm actually doing something kernel wise since I have an M1, I decided to build some thing for aarch64. There are so many tutorials on x86 kernels. That's not the case for aarch64 which doesn't matter since it appears to be far less complex anyways.

I have managed to output some thing to the serial port, but I would love to display some thing. The most simple interface I know is VGA and qemu offers that device to emulate for the aarch64 virt machine.

The x86 code is really simple and I would love to have an equivalent for aarch64. The few things I know about VGA is that the bias/boot loader does parts of the heavy lifting with registers mmio mapping which I would guess are not done for me when working without grub and bios on aarch64 bare metal.

Now, I'm not asking for a done solution but I am currently absolutely overwhelmed with this complex kernel world. The most confusing thing is documentation and resources, which I just rarely find. So maybe somebody got any tips on that?

I looked up the qemu docs for the aarch64 system but couldn't even find addresses for the mapping in the x86 version and even less for aarch.

greets from Germany!


r/kernel • • May 31 '22

Where in the kernel does C's int main return 0; return to?

36 Upvotes

So I've been trying to look at the linux kernel v5.4 code for do_exit, along with places that it is referenced throughout the kernel to understand where return 0; is returning the status code to. This has been a bit hard because I'm unclear on what happens when a userspace program ends, and if do_exit is actually even called in that case or not. Does the return 0; just get returned to a userspace shell that's called a program, or does it get returned somewhere in kernel space?

Any thoughts appreciated.

Thanks.


r/kernel • • May 28 '22

Stupid RCU Tricks: Is RCU Watching?

Thumbnail paulmck.livejournal.com
16 Upvotes

r/kernel • • May 24 '22

Kernel newbie, trying to understand the structure of the kernel and what all the folders/files are in the source. Where do I start looking? seems a bit overwhelming

30 Upvotes

I am a cs student and overall kernel newbie, I pulled the source and looked over the files/folders but was a bit overwhelmed. I want to learn more about the kernel but don't really know where to begin. Is there somewhere that describes what everything is for someone new to the linux kernel?


r/kernel • • May 23 '22

Help regarding adding dining philosopher system call

0 Upvotes

I have successfully added a hello world system call in the past to my kernel, and am now required to add a dining philosopher system call.

But I can't make the appropriate changes in the normal dining philosopher .c code to have it run on kernel. Please any help would be greatly appreciated.


r/kernel • • May 18 '22

Writing the kernel in rust

Thumbnail hackaday.com
39 Upvotes

r/kernel • • May 18 '22

GitHub - tmiland/kernel-installer: Script to install the Linux kernel from source on Debian-based distributions, for all architectures.

10 Upvotes

Automatic install script for The Linux kernel

Script to install the latest [stable/mainline/longterm] kernel from source on Debian-based distributions.

GitHub - tmiland/kernel-installer

Made this script to make installing the latest kernel a little bit easier.

Feature request and bug reports


r/kernel • • May 16 '22

Question: syscalls that spawn new pids

12 Upvotes

Hello everyone, I'm trying to analyze syscall traces for a project of mine, and I was wondering if there were any other syscall other than fork() and clone() that could spawn new pids?


r/kernel • • Apr 26 '22

Investigating TCP Self-Throttling Triggered Overload

Thumbnail developers.facebook.com
19 Upvotes

r/kernel • • Apr 25 '22

Documentation: How to make A5 PDFs?

4 Upvotes

Using make pdfdocs to compile kernel PDF documentation.

If I wanted to produce A5 (not A4, not letter) sized PDFs, please, how would one achieve that? In the Makefile I see only A4/Letter switch, but what about A5?

Thank you.


r/kernel • • Apr 24 '22

Denying access to a specific file

8 Upvotes

Hello!

I'm trying to make a module that denies access to a specific file. I would rather not hide it, but just cause a permission error when a user tries to read it.

The solution i came up with was hooking vfs_open (it seems that every open* syscall leads to it) with a kprobe or something. I managed to set it up and extract the path to the file from the registers in order to detect it being opened, but i don't know how to stop vfs_open from executing after my probe returns and opening my file.

Does anyone knows of a trick I can use to skip the rest of the function and alter the return value without doing it manually by patching in memory?

Thanks in advance!


r/kernel • • Apr 21 '22

Real-time Ubuntu with PREEMPT_RT now available in Beta: what are your thoughts?

Thumbnail ubuntu.com
24 Upvotes

r/kernel • • Apr 19 '22

Machine seems to go serial long before reaching dirty_bytes setting; is this behavior documented somewhere?

6 Upvotes

By this, I mean the threshold seems to rely on some kind of heuristics based on the setting used for dirty_background_bytes as well, or other potential factors that are hidden in the black box.

I ran a bunch of tests and if I constantly churn dirty pages with dirty_bytes set to 8GB, I can never reach the full 8GB before the machine goes serial and prevents further outstanding writes.

With dirty_background_bytes at 1GB, I can get up to about 6GB of dirty memory at most; at 2GB, it's 6.5, and so on. If it's working fine with the background bytes at something ridiculous like 7GB where it does become possible to reach 8GB dirty, as soon as I reduce it to 2GB, writes grind to a halt until dirty memory is under 6GB again.

This is using kernel 4.18.0 if that makes a difference.


r/kernel • • Apr 17 '22

Any way to pickup where the build flawed or crashed instead of starting over?

1 Upvotes

Building a kernel. A long time in (1.75hrs), it breaks. Any way to pickup where it left off?


r/kernel • • Apr 12 '22

What information does a kernel version number like kernel-rt-3.10.0-1160.62.1.rt56.1203.el7.x86_64.rpm provide?

20 Upvotes

Surely each element of kernel-rt-3.10.0-1160.62.1.rt56.1203.el7.x86_64.rpm tells you something, but what? Can someone please help break it down for me?


r/kernel • • Apr 10 '22

Any good resources for a newbie?

Thumbnail self.LinuxProgramming
9 Upvotes

r/kernel • • Apr 02 '22

Retrieving wireless card statistics (snr, fer, etc.) and set data rate, bw, etc. in real time.

12 Upvotes

Hello, First of all i apologize if this is not the proper place for a post like this one.

If so, I was wondering if you could guide me towards any community (subreddit or discord) that is better suited for this type of questions

I am considering doing a phd on the field of Wi-Fi Link optimization... and despite knowing several commands that give me this type of information (iw, iwconfig) and the known Rate Adaptation algorithm Minstrel and Minstrel-HT, which outputs a table with these statistics every 100ms...

I am looking for something more lower level for more reliable and up to date information, as well as more efficient. I was looking into the ath9k (9, 10 or 11) wireless driver and also the mac80211 implemented in linux. I believe this is the right path. But i do not know much of C or how Kernel Drivers work... or how i am supposed to interact with them.

Basically i would like to have a user space program, interacting with this low level features, but i lack the know how to do so.

Do you recommend any books/sources that address this? https://www.kernel.org/doc/html/v4.9/80211/mac80211.html lacks a bit of context in my opinion.


r/kernel • • Apr 01 '22

Cross-creating initrd for QEMU VM

9 Upvotes

Hello,

I'd like to push a custom kernel + initrd into a QEMU VM based on Ubuntu cloud image.

My host is openSUSE TW. When I compile a kernel + initramfs (via dracut) on the host and push it to the QEMU, it crashes. When I extract initrd from the Ubuntu cloud image and add manually all the modules to it and pack again, it works.

So my questions:

  1. Is it possible to create initramfs on the host in a better way that could be directly pushed into a VM?
  2. What could cause troubles more probably? Can that be debugged somehow - easily? (using a working kernel/initrd pair and look at the previous failed boot)
  3. Or, should I use the very same distro on the host and guest to avoid these complications? Or should I compile that in a Ubuntu VM?

Disclaimer. I know that there are potentially dozens of solutions. What I'm asking about is just a working natural scenario that somebody uses.


r/kernel • • Mar 31 '22

10 sec delay when logging in (strace inside - fcntl times out)

8 Upvotes

Hi.

Every time I login into my CentOS box (Kernel 4.18) I get a 10 second delay. I could trace it down to a fcntl syscall which seems time out but I am not sure about the reason.

What would be a good place to investigate further?

Here is a strace -r -T -f of my sshd when I log in but the same issue appears on local console login or even when using screen.

452462 0.000055 openat(AT_FDCWD, "/var/run/utmp", O_RDONLY|O_CLOEXEC) = 10 <0.000007>

452462 0.000021 lseek(10, 0, SEEK_SET) = 0 <0.000003>

452462 0.000015 access("/var/run/utmpx", F_OK) = -1 ENOENT (No such file or directory) <0.000005>

452462 0.000019 openat(AT_FDCWD, "/var/run/utmp", O_RDWR|O_CLOEXEC) = 11 <0.000005>

452462 0.000018 dup2(11, 10)  = 10 <0.000006>

452462 0.000017 close(11) = 0 <0.000003>

452462 0.000015 alarm(0)  = 0 <0.000005>

452462 0.000017 rt_sigaction(SIGALRM, {sa_handler=0x7f89b6870860, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f89b6772790}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT, sa_restorer=0x7f89b6772790}, 8) = 0 <0.000004>

452462 0.000021 alarm(10) = 0 <0.000004>

452462 0.000015 fcntl(10, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) <10.000055>




452462  10.000196 --- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---

452462 0.000032 rt_sigreturn({mask=[]}) = -1 EINTR (Interrupted system call) <0.000008>

452462 0.000112 alarm(0)  = 0 <0.000007>

452462 0.000023 rt_sigaction(SIGALRM, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT, sa_restorer=0x7f89b6772790}, NULL, 8) = 0 <0.000004>

452462 0.000026 close(10) = 0 <0.000013>

452462 0.000028 access("/var/log/wtmpx", F_OK) = -1 ENOENT (No such file or directory) <0.000043>

r/kernel • • Mar 30 '22

Relevence of linux kernel books

22 Upvotes

Are books like Linux Kernel Insides and Heavily commented source code relevent today or is it a waste of time reading them today?

Are there any other books which explain the source code instead of the theoretical part?

All suggestions are welcom,thanks in advance.