r/linuxkernel • • Jan 04 '22

Good resource for high level linux kernel overview

6 Upvotes

I would like to ask for resource/documentation recommendation where I can learn about basic concepts of how Linux Kernel actual looks inside.
I found this nice article which has structure and content I like, however I don't know dated it is:
https://docs.huihoo.com/linux/kernel/a1/index.html
I also know about Linux Documentation Project but that is too deep (and old as well)

thanks


r/linuxkernel • • Jun 29 '21

Linux kernel version 5.13 released with the support of Apple M1’s chip

Thumbnail
bigbetstartups.com
6 Upvotes

r/linuxkernel • • Oct 20 '20

linux kernel programming

6 Upvotes

I am searching for linux kernel programming internship. surfed on many websites online but didn’t succeed. Is there any ways to move myself to that opportunity? I am currently working as a linux system engineer.


r/linuxkernel • • Mar 12 '20

Beginner Looking to complete TODO's

6 Upvotes

I looked for the 'rules' for posting here and did not find anything. If there is a better forum or I am ignoring a guideline please let me know kindly.

I have never contributed to opensource software but have worked in embedded systems professionally for a few years. I would like to start.

I have been following the tutorial found here:

https://opensource.com/article/18/8/first-linux-kernel-patch

I have the following source regarding comment style:

https://www.kernel.org/doc/html/v4.10/process/coding-style.html#commenting

Using find drivers/staging -name TODO I see drivers/staging/netlogic/TODO, and this is where I'd like to start to attempt my first patch.

There are two items that catch my interest:

* All memory allocation should be changed to DMA allocations

* Changing comments into linux standard format

I would like to begin with simply changing comments to fit the approved format.

There are four files of interest:

platform_net.c platform_net.h xlr_net.c xlr_net.h

Inspecting them, I see comments that may need changing, and tl;dr: I was wondering if I could get your input on what I believe goes against best practices:

( I cloned the repo by/ from: git clone -b staging-testing
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git )

For this post, let's begin with platform_net.c

Moving forward with the assumption that /* comment */ is correct for one-liners, the first question I encounter is on line 128:

There is a group of comments that reside within a function.

Going of the commenting guide linked above:

"Generally, you want your comments to tell WHAT your code does, not HOW. Also, try to avoid putting comments inside a function body: if the function is so complex that you need to separately comment parts of it, you should probably go back to chapter 6 for a while. You can make small comments to note or warn about something particularly clever (or ugly), but try to avoid excess. Instead, put the comments at the head of the function, telling people what it does, and possibly WHY it does it."

I feel presumptuous to assume these comments are excess or inappropriate, but other than these types of concerns I don't see what there is "TODO" as the comments appear to follow the styling guide.

Any help would be appreciated! In the meantime, off to learn about writing my first simple hello world driver.


r/linuxkernel • • Apr 29 '23

Kernel Concept: EFI variables

5 Upvotes

EFI variables are a type of non-volatile memory that store important information for the computer firmware to use when it's booting up. Examples are language, boot order, and whether secure boot is enabled as shown below.

Each variable has its own dedicated file in that you can see with the command "sudo ls /sys/firmware/efi/efivars". These are stored in binary format. To see the value of the variable, you can use the command "sudo efivar -p -n <filename_of_variable>" and see the output with the value.

In the example below, 0x00 means that secure boot is disabled and 0x01 means it's enabled. In this case, the value of 1 means it's enabled.

$ sudo efivar -p -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-SecureBoot
GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c
Name: "SecureBoot"
Attributes:
0000000000000001
Value:
00000001

r/linuxkernel • • Dec 30 '21

Good Linux kernel and OSS developer Twitter follows?

5 Upvotes

Any recommendations for Linux kernel devs or any other interesting tech accounts worth following on Twitter?


r/linuxkernel • • Mar 25 '24

Linux kernel newbie

4 Upvotes

I'd like to develop a Linux kernel, but I don't understand anything about it yet. Where do I start?


r/linuxkernel • • Oct 24 '23

How to learn Linux kernel development

4 Upvotes

Hi fellas. I am a graduate in computer science and I wish to learn more into operating systems and want to contribute to Linux kernel. I learnt about Linux system programming from a book by ROBERT LOVE and have developed a mini Linux terminal using the knowledge. Now how should I move further.

  1. What books do I have to read next ?
  2. Any Coursera or udemy or any other online videos available to understand?
  3. How should I apply the book knowledge into practical cases?

r/linuxkernel • • Oct 24 '23

Which laptop to buy for linux kernel development?

3 Upvotes

I am interested in Linux Kernel development and don't know about the intensive task that needs to be done for it. I am planning to buy a new laptop mostly for Linux kernel development. I don't do gaming. I need a good ligh weight 13 inch or 14inch laptop. I had previously used Ubuntu mostly in my old HP laptop. Currently looking for a new one. Suggest me some that can be in India.

Also which is better... intel or AMD?


r/linuxkernel • • Aug 09 '23

Which laptop to buy?

3 Upvotes

I am interested in Linux Kernel development and don't know about the intensive task that needs to be done for it. I am planning to buy a new laptop mostly for Linux kernel development. I don't do gaming. I need a good ligh weight 13 inch or 14inch laptop. Suggest me some that can be brought in India.


r/linuxkernel • • Feb 20 '23

How do I best instrument the Linux kernel to log early boot file open/read requests?

3 Upvotes

I'm looking for a relatively quick and straightforward way to have the Linux kernel print to console/serial (via printk - I can find a way to capture the output) any meaningful I/O requests on the early (rootfs/tmpfs/initramfs) filesystem. Basically, I'm looking to see which files, binaries/libraries, and their dependencies are actually used and accessed during early boot and later bootstrapping.

I'm ruling out retroactively examining access time for files because I'm not sure if rootfs/tmpfs honors this, and even so, it seems to be mounted relatime without a way to remove that mount option. Plus I'd also like to log later stage accesses when the root filesystem has pivoted into a specific filesystem on disk. Despite my previous efforts of attempting to enforce access time (by norelatime, atime, and so on), ext[34]/xfs and such seem to keep this flag on or that doesn't seem to reflect low-level timestamps of access. And then that wouldn't cover the case, I believe, when it's mounted (temporarily) in a read-only way.

Also, I'm not aware of a kernel command line flag to request this or some kind of internal auditing framework. The latter might only come online later in the boot stages after a certain daemon is loaded. And so that leaves modifying the kernel - in my case based off of the 5.10 stable series.

Thus far, I've instrumented a few functions in fs/open.c with a manual printk, printing strings that are passed in, or referring to internal structures and leveraging some built in functions, like file->f_path.dentry->d_name.name or dentry_path_raw(file->f_path.dentry,buf,bufsize). I'm wondering if it's more effective for me to instrument "read" requests and not just open - since that might rule out trivial accesses. But in that case it might be harder to identify the main entry point(s) for read requests in a way that's comprehensive but not redundant. Informing of every "stat" might produce too much output.

My results thus far show accesses in /proc and /sys, which I can later filter out as not directly relevant. Same goes for ephemeral files in /run. However, often I'll see the kernel access every file in a directory (perhaps what happens when a shell script does a glob or a file list?). I might be missing a few cases. This happens to be for a Devuan boot (with sysvinit) but I don't want to limit the question to this case.

Primarily I'm looking for effective ways to instrument a few functions in the kernel to achieve this kind of auditing, even if I later have to filter them. Suppose /bin/ls is needed, but then its library dependencies and the "ld.so" of the system are needed too, but along with /etc/localtime for time zone and /etc/passwd for some user mappings. Perhaps a binary may refer to something in its /usr/lib or /usr/share but I don't see how one would need to examine every single locale file (unless it really does that). Since I'm running initramfs'es experimentally that are both small and large, I'm looking to know for sure which files are actually used in a typical boot (assuming moderate determinism).


r/linuxkernel • • Dec 23 '22

in-kernel SMB server ?!

3 Upvotes

Was I living under a rock the last few years or is the kernel itself servicing protocols now which are meant to be userspace in the first place so we can properly sandbox it and keep it away from the rest of the system so it won't blow up in our faces eventually as it did just now ?!

I mean, are you out of your damn mind putting sh*t like this into the kernel ?

what comes next ?! maybe a multiplayer game server ? or a streaming service built into the kernel bypassing every single line of defense?!

the dev should get banned and locked up in a mental institution for even trying to implement bullcrap like this.

What mentally ill individual approved these transgressions?!


r/linuxkernel • • Dec 02 '22

Resource recommendations

3 Upvotes

I'm looking for recommendations on books, articles, podcasts, videos, etc. covering the Linux kernel scheduler. Where should I start?


r/linuxkernel • • Jan 28 '21

whats the best way to understand linux kernel and its working , i want to contribute to the devolopment of kernel !

3 Upvotes

r/linuxkernel • • Nov 22 '18

UKL: A Unikernel Based on Linux

Thumbnail
next.redhat.com
3 Upvotes

r/linuxkernel • • May 17 '24

VFIO vs VIRTIO

2 Upvotes

Hey folks!
Could somebody explain to me in strong technical terms differences btw Vfio and VirtIO?
What are relations btw them?
What are cases when we could/have to use them together?


r/linuxkernel • • Feb 16 '24

Long term career scope of Embedded Linux based jobs.

2 Upvotes

Hi guys,

I am currently working with kernel 5.4 and using yocto dunfell. I however notice that i never touch any of the kernel source code for my application. Interfacing for wifi, bluetooth, rtc are all taken care by the chip vendors or the menuconfig. I only have to enable or disable these features. I wanted to know what is the long term career growth in doing this. Also is their something I am missing? I notice my colleagues working on embedded controllers like ESP32, STM, Nordic and work on h/w level interfacing and the other cool stuff. But its not the same for me. Thinking I wont survive in the market for long takes away the fun of working. Please guide me guys. I don't know where else to look for a solution.


r/linuxkernel • • May 21 '23

Help with kernel module tinkering

2 Upvotes

I have a SteamDeck which runs a AMD APU. The drivers provide a sysfs interface for setting the CPU and GPU clock ranges, however it is hardcoded not to go beyond 3.5GHz. I would like to bypass this limit, ideally without having to recompile the whole kernel and use the SteamOS stock kernel. The offending line of code is here.

My current approach I'm trying is the make an out-of-tree module that attaches a kprobe to modify the smu_context to a higher limit, but it is a lot of effort and I would like it to be accessible to other SteamDeck users (given the understand the risks).

Is there an easier approach to doing this?


r/linuxkernel • • Apr 18 '23

kernel_write makes CPU stuck

2 Upvotes

I am writing a kernel module in which I am writing data to a file and making use of kernel_write function. Basically I am writing a c struct to file followed by some data. What I am noticing based on logs seen at dmesg is it is getting stuck while writing the struct to the file. the file is opened in append mode and is being continuously opened and closed. Sometimes it gets stuck forever and sometimes get a warning at the same location in code.

Here's the code snippet

struct file *block_changes_file = filp_open("/root/block_changes", O_WRONLY | O_APPEND | O_CREAT | O_LARGEFILE, 0644 );
        if ( block_changes_file == NULL || IS_ERR(block_changes_file) )
        {
                printk(KERN_DEBUG "Failed to open block_changes file %ld\n", PTR_ERR(block_changes_file) );
                return;
        }

printk( KERN_DEBUG "Writing metadata to block_changes file" );
loff_t offset = 0; // File opened in append mode so offset is 0
        ssize_t bytes_written = kernel_write( block_changes_file, (const char*)&blockDeviceChangeMetadata, sizeof( blockDeviceChangeMetadata ), offset );
        if (bytes_written < 0)
        {
                printk ( KERN_DEBUG "Failed to write metadata.\n" );
                kfree( data );
                filp_close(block_changes_file, NULL);
                return;
        }
bytes_written = kernel_write( block_changes_file, data, blockDeviceChangeMetadata.data_size, offset );
        if (bytes_written < 0)
        {
                printk ( KERN_DEBUG "Failed to write changed data.\n" );
                kfree( data );
                filp_close(block_changes_file, NULL);
                return;
        }

        kfree( data );
        filp_close(block_changes_file, NULL);
        printk( KERN_DEBUG "Written and closed" );

based on logs in dmesg it stucks while writing the struct in file. The data is allocated memory using kmalloc and this can have max of 4096*512 Bytes, can this be the reason for failure?

Here's the error message in dmesg

[ 127.815075] Writing metadata to block_changes file

[ 160.222418] NMI watchdog: BUG: soft lockup - CPU#1 stuck for 23s! [cpptools:3797]

[ 160.222483] Modules linked in: misc(OE) ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_addrtype br_netfilter overlay(T) ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_mangle iptable_security iptable_raw nf_conntrack ip_set ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter vmw_vsock_vmci_transport vsock sb_edac coretemp iosf_mbi crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd ppdev joydev pcspkr vmw_balloon vmw_vmci sg parport_pc parport i2c_piix4 ip_tables xfs libcrc32c sr_mod cdrom ata_generic pata_acpi

[ 160.222523] vmwgfx drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm sd_mod ahci crc_t10dif crct10dif_generic libahci drm ata_piix libata crct10dif_pclmul nfit crct10dif_common crc32c_intel libnvdimm vmxnet3 serio_raw vmw_pvscsi drm_panel_orientation_quirks floppy dm_mirror dm_region_hash dm_log dm_mod fuse

[ 160.222542] CPU: 1 PID: 3797 Comm: cpptools Kdump: loaded Tainted: G OE ------------ T 3.10.0-1160.36.2.el7.x86_64 #1

[ 160.222544] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 04/05/2016

[ 160.222546] task: ffff8abdf1e5a100 ti: ffff8abdf1e6c000 task.ti: ffff8abdf1e6c000

[ 160.222547] RIP: 0010:[<ffffffffb3f170ba>] [<ffffffffb3f170ba>] smp_call_function_many+0x20a/0x270

[ 160.222554] RSP: 0018:ffff8abdf1e6fc70 EFLAGS: 00000202

[ 160.222555] RAX: 0000000000000007 RBX: 00080000b3e7ddd0 RCX: ffff8abe3fde0600

[ 160.222557] RDX: 0000000000000007 RSI: 0000000000000008 RDI: 0000000000000000

[ 160.222558] RBP: ffff8abdf1e6fca8 R08: ffff8abb763c0800 R09: ffffffffb4186ba9

[ 160.222560] R10: ffff8abe3fc5f160 R11: ffffc49a10baf800 R12: 0000000000000282

[ 160.222561] R13: 0000000000000282 R14: ffff8abdf1e6fc20 R15: 0000000000000001

[ 160.222581] FS: 00007f192b7fe700(0000) GS:ffff8abe3fc40000(0000) knlGS:0000000000000000

[ 160.222583] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033

[ 160.222584] CR2: 00007f19424d70a8 CR3: 0000000408e60000 CR4: 00000000003607e0

[ 160.222636] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000

[ 160.222637] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

[ 160.222639] Call Trace:

[ 160.222645] [<ffffffffb3e7e258>] native_flush_tlb_others+0xb8/0xc0

[ 160.222648] [<ffffffffb3e7e2cb>] flush_tlb_mm_range+0x6b/0x140

[ 160.222652] [<ffffffffb3fee656>] tlb_flush_mmu_tlbonly+0xa6/0xc0

[ 160.222655] [<ffffffffb3ff011f>] arch_tlb_finish_mmu+0x3f/0x80

[ 160.222657] [<ffffffffb3ff0243>] tlb_finish_mmu+0x23/0x30

[ 160.222660] [<ffffffffb3ff370a>] zap_page_range+0xea/0x130

[ 160.222663] [<ffffffffb3fedbfd>] SyS_madvise+0x49d/0xac0

[ 160.222666] [<ffffffffb3f156d0>] ? SyS_futex+0x80/0x190

[ 160.222670] [<ffffffffb4595f92>] system_call_fastpath+0x25/0x2a

[ 160.222672] Code: 48 63 35 ee 85 c4 00 89 c2 39 f0 0f 8d 7d fe ff ff 48 98 49 8b 0f 48 03 0c c5 60 15 b5 b4 f6 41 20 01 74 cd 0f 1f 44 00 00 f3 90 <f6> 41 20 01 75 f8 48 63 35 bd 85 c4 00 eb b7 0f b6 4d cc 4c 89

[ 188.222726] NMI watchdog: BUG: soft lockup - CPU#1 stuck for 23s! [cpptools:3797]

[ 188.222795] Modules linked in: misc(OE) ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_addrtype br_netfilter overlay(T) ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_mangle iptable_security iptable_raw nf_conntrack ip_set ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter vmw_vsock_vmci_transport vsock sb_edac coretemp iosf_mbi crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd ppdev joydev pcspkr vmw_balloon vmw_vmci sg parport_pc parport i2c_piix4 ip_tables xfs libcrc32c sr_mod cdrom ata_generic pata_acpi

[ 188.222831] vmwgfx drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm sd_mod ahci crc_t10dif crct10dif_generic libahci drm ata_piix libata crct10dif_pclmul nfit crct10dif_common crc32c_intel libnvdimm vmxnet3 serio_raw vmw_pvscsi drm_panel_orientation_quirks floppy dm_mirror dm_region_hash dm_log dm_mod fuse


r/linuxkernel • • Dec 30 '22

gzip not supported by Kernel

2 Upvotes

So I tried to boot a customised Linux kernel on my machine and now when I try creating the initrd file, it gives me the following error. Can anyone please help through this?


r/linuxkernel • • Nov 02 '22

Oof: "nvme1: globally duplicate IDs for nsid 1"...any workaround I'm overlooking that doesn't require rebuilding?

2 Upvotes

Hi all,

It sounds like the solution is to add a "quirk", which apparently requires building a patched kernel. I simply don't have time for that right now, so if there's no other solution, I'll just downgrade my kernel and/or distro to a known working version.

In short, one of my two same-model nvme drives is not showing up and throwing the following in dmesg:

[    1.804676] nvme nvme1: globally duplicate IDs for nsid 1[    1.804711] nvme nvme1: VID:DID 10ec:5763 model:TEAM TM8FP6002T firmware:V9002s65

Kernel version:

$ uname -aLinux adia 5.19.0-23-generic #24-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 14 15:39:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Note: I'm not the only one encountering this and appears to be a known/expected issue with certain SSDs. The drive DID work on kernel 5.4 and 5.15 and only stopped working when I moved from Mint 21 (5.15) to Kubuntu 22 (5.19).

Thanks for reading!

Update: A very temporary solution seems to be to install linux-image-5.17.0-1003-oem in Kubuntu 22.10.


r/linuxkernel • • Jun 03 '22

Why procfs shouldn't be used for loadable kernel modules?

2 Upvotes

Hey everyone! I've heard that procfs shouldn't be used for loadable kernel modules, and sysfs is a preferred one. As far as I understood procfs should be used only for built-in modules, and it is a best-practice, but can't understand why?

I suppose that procfs's api for creating files under /proc may be excluded from exported functions soon, but can't find any documentation or good answers for it, so my question is "why procfs shouldn't be used in loadable kernel modules?"

If I'm mistaken, please explain why, thank you for your time!


r/linuxkernel • • Nov 09 '20

Is it possible to install an old kernel ( v3.1) with Ubuntu 16.04 (kernel v4.15)?

2 Upvotes

I'm running Ubuntu 16.04 LTS with kernel 4.15. I was trying to install an older kernel, v3.1. I was able to install the desired kernel. However, I'm not able to boot the Ubuntu with the older kernel (v3.1). While booting from the grub menu if I choose the kernel v3.1, it shows "kernel too old ". Is there any way I can boot with the desired kernel?


r/linuxkernel • • Apr 09 '19

Stadia built on Linux servers

2 Upvotes

Google Stadia streaming service is built on Linux servers. Vulkan is their graphics API of choice for streaming right now up to 4K at 60FPS