<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Linux Kernel on ankit_kdev</title><link>https://ankitkdev.com/categories/linux-kernel/</link><description>Recent content in Linux Kernel on ankit_kdev</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 17 May 2026 17:00:31 +0530</lastBuildDate><atom:link href="https://ankitkdev.com/categories/linux-kernel/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding Forward Declarations in C</title><link>https://ankitkdev.com/blog/forward-declaration-in-c/</link><pubDate>Sun, 17 May 2026 17:00:31 +0530</pubDate><guid>https://ankitkdev.com/blog/forward-declaration-in-c/</guid><description>&lt;p>One of the best ways to learn systems programming is by reading real-world code. Recently, while reading the Linux kernel source, I noticed something interesting inside &lt;code>drivers/pinctrl/core.h&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-c" data-lang="c">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#include&lt;/span> &lt;span style="color:#75715e">&amp;lt;linux/kref.h&amp;gt;&lt;/span>&lt;span style="color:#75715e">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#include&lt;/span> &lt;span style="color:#75715e">&amp;lt;linux/list.h&amp;gt;&lt;/span>&lt;span style="color:#75715e">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#include&lt;/span> &lt;span style="color:#75715e">&amp;lt;linux/mutex.h&amp;gt;&lt;/span>&lt;span style="color:#75715e">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#include&lt;/span> &lt;span style="color:#75715e">&amp;lt;linux/radix-tree.h&amp;gt;&lt;/span>&lt;span style="color:#75715e">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#include&lt;/span> &lt;span style="color:#75715e">&amp;lt;linux/types.h&amp;gt;&lt;/span>&lt;span style="color:#75715e">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#include&lt;/span> &lt;span style="color:#75715e">&amp;lt;linux/pinctrl/machine.h&amp;gt;&lt;/span>&lt;span style="color:#75715e">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">struct&lt;/span> dentry;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">struct&lt;/span> device;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">struct&lt;/span> device_node;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">struct&lt;/span> module;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>At first glance, these lines seem incomplete. We see declarations like &lt;code>struct device;&lt;/code> but no actual definition. Where is the complete structure with all its members? Why didn&amp;rsquo;t file defining this structure isn&amp;rsquo;t included?&lt;/p></description></item><item><title>C Memory Layout: Structs, Unions, and a Linux Kernel Patch</title><link>https://ankitkdev.com/blog/c-memory-layout/</link><pubDate>Mon, 04 May 2026 13:30:05 +0530</pubDate><guid>https://ankitkdev.com/blog/c-memory-layout/</guid><description>&lt;h1 id="overview">Overview&lt;/h1>
&lt;p>C memory layout looks simple in isolation: structs store fields sequentially, unions overlap memory, and flexible array members allow variable-sized trailing storage. But combining these features can create subtle layout issues.&lt;/p>
&lt;p>While working on a Linux kernel selftest, I encountered a case where a union contained multiple structures, each ending with a flexible array member at different offsets. Although the code was functionally correct, this confused the compiler into treating the union as effectively variable-sized, triggering a layout warning.&lt;/p></description></item><item><title>Build and Install Linux Kernel For Beaglebone Black</title><link>https://ankitkdev.com/blog/build-linux-kernel-bbb/</link><pubDate>Wed, 08 Apr 2026 22:31:16 +0530</pubDate><guid>https://ankitkdev.com/blog/build-linux-kernel-bbb/</guid><description>&lt;h1 id="overview">Overview&lt;/h1>
&lt;p>The BeagleBone Black (BBB) uses an ARM Cortex-A8 32 bit processor, so the kernel must be cross-compiled on an x86 machine and then deployed to the board. This blog will assume that you already have a os[debian/ubuntu] installed on your sd card.&lt;/p>
&lt;p>We’ll:&lt;/p>
&lt;ul>
&lt;li>set up toolchain&lt;/li>
&lt;li>fetch kernel source&lt;/li>
&lt;li>configure for BBB&lt;/li>
&lt;li>build kernel + modules&lt;/li>
&lt;li>deploy to SD card / board&lt;/li>
&lt;/ul>
&lt;h2 id="1-prerequisites">1. Prerequisites&lt;/h2>
&lt;p>Make sure you have:&lt;/p>
&lt;ul>
&lt;li>Ubuntu (or any Linux host)&lt;/li>
&lt;li>Cross compiler for ARM (arm)&lt;/li>
&lt;/ul>
&lt;p>Install required tools:&lt;/p></description></item><item><title>Basics of debugging slab memory corruption via SLUB debug</title><link>https://ankitkdev.com/blog/debug-slub-memory/</link><pubDate>Wed, 04 Feb 2026 16:45:19 +0530</pubDate><guid>https://ankitkdev.com/blog/debug-slub-memory/</guid><description>&lt;h1 id="introduction">Introduction&lt;/h1>
&lt;p>Memory corruption can occur due to various bugs or defects: Uninitialized Memory
Reads (UMR), Use After Free (UAF), Use After Return (UAR), double-free, memory
leakage, or illegal Out Of Bounds (OOB) accesses that attempt to work upon (read/write/
execute) illegal memory regions.&lt;/p>
&lt;p>Since memory is dynamically allocated and freed via the kernel&amp;rsquo;s engine – the
page allocator. This can lead to serious wastage (internal fragmentation) of memory.
To mitigate this, the slab allocator (or slab cache) is layered upon it, serving two
primary tasks – providing fragments of pages efficiently (within the kernel, allocation
requests for small pieces of memory, from a few bytes to a couple of kilobytes), and serving as a cache for commonly used data structures.&lt;/p></description></item><item><title>Linux Kernel Mentorship Program</title><link>https://ankitkdev.com/blog/linux-kernel-mentorship-program/</link><pubDate>Mon, 08 Dec 2025 10:35:09 +0530</pubDate><guid>https://ankitkdev.com/blog/linux-kernel-mentorship-program/</guid><description>&lt;h3 id="introduction">Introduction&lt;/h3>
&lt;p>I have been using Linux for the last two years and gradually developed an interest in systems programming and C. The mentorship prerequisites includes tasks like building and booting the Linux kernel, writing a basic kernel module, decoding stack traces, and modifying and booting a custom kernel build.&lt;/p>
&lt;p>Somehow, my application was accepted ;-).
&lt;img alt="alt text" loading="lazy" src="https://ankitkdev.com/lfx-acceptance.png">&lt;/p>
&lt;p>At first, the Linux Kernel seemed quite difficult to understand what was going on. We were initially told to choose two subsystems to work on.&lt;/p></description></item></channel></rss>