๐
๐จ๐ซ ๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐ ๐ข๐ง ๐ญ๐ก๐ ๐๐๐ฅ๐จ๐ฐ ๐ฌ๐๐๐ง๐๐ซ๐ข๐จ:
1) Suppose a process is about to return to user mode after executing a system call, and it finds that it has no outstanding signals.
2) Immediately after checking, the kernel handles an interrupt and sends the process a signal. (For instance, a user hits the “break” key.)
3) What does the process do when the kernel returns from the interrupt?
_______________________________________________________________________________
๐๐ฑ๐ฉ๐ฅ๐๐ง๐๐ญ๐ข๐จ๐ง:
The key part is in the exit_to_user_mode_loop() function:
– The kernel explicitly checks for _TIF_SIGPENDING (pending signals)
– This check is part of a loop that continues processing until all work is done
– Each iteration enables interrupts while handling work (to allow new signals to arrive)
– Then it disables interrupts and rechecks the flags
– This loop structure ensures that even signals that arrive at the last moment get handled
This design effectively prevents the race condition , where a signal arrives just after checking but before returning to user mode. The kernel will see any such signals during the final check with interrupts disabled.
The complete flow through.
syscall_exit_to_user_mode()
โ exit_to_user_mode_prepare()
โ exit_to_user_mode_loop()
For more details check – kernel/entry/common.c
__________________________________________________________________
๐๐๐๐ซ๐ง๐ข๐ง๐ ๐๐ฉ๐ฉ๐จ๐ซ๐ญ๐ฎ๐ง๐ข๐ญ๐ข๐๐ฌ:
A) ๐๐๐ฅ๐-๐๐๐๐๐ ๐๐จ๐ฎ๐ซ๐ฌ๐:
Learn at your own pace
Structured kernel programming modules
Practical examples, bug study
Hands-on debugging experience
B) ๐๐ฅ๐๐ฌ๐ฌ๐ซ๐จ๐จ๐ฆ ๐๐ซ๐๐ข๐ง๐ข๐ง๐ ๐๐จ๐ซ ๐
๐ซ๐๐ฌ๐ก๐๐ซ๐ฌ:
5 Months intensive program
Placement support
Real-world bug analysis
Kernel development fundamentals
Live projects & case studies
C) ๐๐๐๐ค๐๐ง๐ ๐๐ง๐ฅ๐ข๐ง๐ ๐๐จ๐ฎ๐ซ๐ฌ๐ ๐๐จ๐ซ ๐๐จ๐ซ๐ค๐ข๐ง๐ ๐๐ซ๐จ๐๐๐ฌ๐ฌ๐ข๐จ๐ง๐๐ฅ๐ฌ:
180+ Hours of training
8 Months comprehensive program
Flexible for working professionals
๐ฝ ๐๐จ๐ฎ๐๐ฎ๐๐ ๐๐ก๐๐ง๐ง๐๐ฅ
https://lnkd.in/eYyNEqp
๐๐จ๐๐ฎ๐ฅ๐๐ฌ ๐๐จ๐ฏ๐๐ซ๐๐ –
1) System Programming
2) Linux kernel internals
3) Linux device driver
4) Linux socket programming
5) Linux network device driver, PCI, USB driver codeย walk through, Linux
crash analysis and Kdump
7) JTag debugging
– ๐๐ซ๐ข๐๐ข๐ง๐ :
https://lnkd.in/ePEK2pJh

#define IS_VALID (type, x) ({ \
type **z; \
typeof(x) **z2; \
(void)(&z == &z2); \ โฌ
๏ธ โโโ ๐ฅ๐ข๐ง๐ 4
1; \
})
int main(int argc, char* argv[])
{
char tt = ‘c’;
float f = 10.56 ;
printf(“%d\n”, IS_VALID(int, f));
printf(“%d\n”, IS_VALID(char, tt));
return 0;
}
(void)(&z == &z2); ->
1) Is it to compare memory addresses of z and z2 at runtime ๐๐
2) to force the compiler to check type compatibility ( if z and z2 are of same type) during compilation ๐๐
3) to allocate memory for both variables in the same memory block ๐๐
4) to check the value of z and z2.
The typeof keyword emerged from fundamental limitations in the C language that became apparent as systems programs grew more complex. Here’s the story behind why it came into existence:
๐๐ก๐ ๐๐ซ๐จ๐๐ฅ๐๐ฆ ๐ฐ๐ข๐ญ๐ก ๐’๐ฌ ๐๐ฒ๐ฉ๐ ๐๐ฒ๐ฌ๐ญ๐๐ฆ :
_______________________________________
1) No Generic Programming Suppport
2) Write the same code multiple times for different types
3) Use void pointers and sacrifice type safety
4) Resort to dangerous preprocessor macros
๐๐ง๐ฌ๐๐๐ ๐๐๐๐ซ๐จ๐ฌ: C macros are simple text substitutions with no type awareness, leading to infamous problems:
๐๐ฒ๐ฉ๐ ๐๐ง๐๐จ๐ซ๐ฆ๐๐ญ๐ข๐จ๐ง ๐๐จ๐ฌ๐ฌ:ย ย Operations like alignment, bit manipulation, and atomic access required casting to and from types, losing type information
๐๐จ ๐๐ฒ๐ฉ๐ ๐๐ง๐๐๐ซ๐๐ง๐๐: Every variable and expression needed explicit typing, leading to verbose, error-prone code, especially with complex pointer types.
๐๐ก๐ ๐๐๐ ๐๐๐ฏ๐๐ฅ๐จ๐ฉ๐๐ซ๐ฌ ๐๐ข๐ฆ๐๐ ๐ญ๐จ:
_________________________________________________________
๐ข Enable Type-Safe Generic Programming: Create a mechanism to write generic code that retained full type safety without sacrificing performance
๐ข Improve Macro Safety: Allow macros to preserve type information and avoid double-evaluation bugs
๐ข Support Systems Programming: Address the needs of low-level code like the kernel that manipulated types in ways standard C couldn’t handle
๐๐ก๐๐ญ ๐ญ๐ฒ๐ฉ๐๐จ๐ ๐๐จ๐ฅ๐ฏ๐๐ ๐๐จ๐ซย ๐๐๐ซ๐ง๐๐ฅ ๐๐๐ฏ๐๐ฅ๐จ๐ฉ๐๐ซ๐ฌ
______________________________________________________
1) Architecture Portability
2) Avoiding Fragile Casts
3) Safe List Traversal
4) Atomic Operation Safety
container_of` macro allows you to find the parent structure from a pointer to one of its members. One of the most ingenious pieces of C programming in the Linux kernel.
Here’s the definition:
hashtag#define container_of(ptr, type, member) ({ย ย ย \
const typeof(((type *)0)->member) *__mptr = (ptr); \
(type *)((char *)__mptr – offsetof(type, member)); })
Let’s break down:
1. Takes a pointer to a member (`ptr`)
2. The type of the container structure (`type`)
3. The name of the member within the structure (`member`)
4. Returns a pointer to the container structure
The most interesting part of the macro is:
const typeof(((type *)0)->member) *__mptr = (ptr);
Fascinating trick using a null pointer cast. Let’s analyze why this works:
– `(type *)0` casts the value 0 (NULL) to a pointer of type `type*`
– `((type *)0)->member` accesses the `member` field of this null pointer
– This doesn’t actually dereference memory (which would cause a crash), but instead lets the compiler determine the type of `member`
– `typeof()` extracts this type information
– `__mptr` is then declared as a pointer to this type and assigned the value of `ptr`
Why is This Implementation Valuable?
1. Enables C Object-Oriented Patterns
Consider this example:
struct device {
int id;ย ย ย ย ย ย ย // Offset 0
char name[8];ย ย ย ย // Offset 4
struct list_head list; // Offset 12
};
When a function receives a `list_head` pointer, it can find the containing `device` structure:
void some_list_function(struct list_head *list_ptr) {
struct device *dev;
dev = container_of(list_ptr, struct device, list);
printf(“Device ID: %d\n”, dev->id);
printf(“Device Name: %s\n”, dev->name);
}
2. Type Safety
The use of `typeof` ensures that `ptr` is of the correct type expected for the member. This provides compile-time type checking.
3. Zero Runtime Overhead
The entire macro resolves to simple pointer arithmetic. There’s no function call overhead, dynamic type checking, or any other runtime cost.
4. Maintains Encapsulation
Exposes only the necessary structures while keeping their containing structures private, enhancing modularity.
Understanding the Null Pointer Cast
The line `const typeof( ((๐ญ๐ฒ๐ฉ๐ *)0)->member) *__mptr = (ptr);` often confuses developers new to kernel code. The null pointer (0) is specifically chosen because it’s a safe way to access type information without risking memory access.
Practical Applications
The `container_of` macro is used extensively throughout the kernel:
1. ๐๐๐ฏ๐ข๐๐ ๐๐ซ๐ข๐ฏ๐๐ซ ๐๐จ๐๐๐ฅ: Finding device structures from their embedded kobjects
2. ๐๐ข๐ง๐ค๐๐ ๐๐ข๐ฌ๐ญ๐ฌ: Retrieving the containing structure from a list entry
3. ๐๐๐: Accessing container structures in lock-free code
4. ๐๐ฎ๐๐ฌ๐ฒ๐ฌ๐ญ๐๐ฆ ๐๐ง๐ญ๐๐ซ๐๐๐๐๐ฌ: Extending core functionality through composition

Two embedded engineers with identical experience sit in the same interview. Both have 2-3 years experience (applicable for freshers also), strong Linux/C skills, solid DSA knowledge.
๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ ๐๐ฎ๐๐ฌ๐ญ๐ข๐จ๐ง: “๐๐จ๐ฐ ๐๐จ ๐ฒ๐จ๐ฎ ๐ฏ๐๐ฅ๐ข๐๐๐ญ๐ ๐๐ฆ๐๐๐๐๐๐ ๐๐ข๐ซ๐ฆ๐ฐ๐๐ซ๐ ๐ช๐ฎ๐๐ฅ๐ข๐ญ๐ฒ?”
โ Candidate A: “I do thorough testing and code reviews.”
โ๏ธ Candidate B: “I use GCOV for coverage analysis. gcc –coverage revealed
untested error paths in our SPI driver that could have caused field failures. I target 80%+ coverage for production code.”
Result: Candidate B gets the offer.
๐๐ก๐ฒ ๐๐จ๐จ๐ฅ ๐๐ง๐จ๐ฐ๐ฅ๐๐๐ ๐ ๐๐ข๐ง๐ฌ
๐๐จ๐จ๐ฅ-๐๐๐ฏ๐ฏ๐ฒ ๐๐๐ฌ๐ฉ๐จ๐ง๐ฌ๐ ๐ฌ๐ข๐ ๐ง๐๐ฅ๐ฌ:
โ
Production quality experience
โ
Industry-standard practices
โ
Systematic development approach
โ
Can prevent costly field failures
๐๐ก๐ ๐๐๐ฌ๐ฒ ๐๐ข๐ง
Complex Skills: 6+ months each (kernel internals, advanced DSA) Professional Tools: 2-3 weeks to master โก
Impact: Same resume + tool knowledge = 15-25% higher salary
๐๐จ๐ฎ๐ซ ๐๐๐ฏ๐๐ง๐ญ๐๐ ๐ ๐๐ฅ๐๐ง
# Learn GCOV basics (1 weekend): ->
gcc –coverage -o program source.c
gcov source.c
๐๐ฅ๐ข๐๐ค ๐๐๐ฅ๐จ๐ฐ ๐๐จ๐ซ ๐๐๐ญ๐๐ข๐ฅ๐ฌ :
https://lnkd.in/g4T_RcMq
๐๐๐๐ฅ๐ ๐จ๐ ๐๐จ๐ง๐ญ๐๐ง๐ญ๐ฌ-
[What is GCOV?]
[Why Use GCOV?]
[When to Use GCOV?]
[Understanding GCOV Output]
[Expert vs Novice Analysis]
[Advanced Techniques]
[Industry Best Practices]
[Practical Implementation]
๐๐๐๐ซ๐ง ๐ฆ๐จ๐ซ๐ -> https://lnkd.in/g4T_RcMq
# Build portfolio examples
# Prepare tool-focused interview talking points
๐๐จ๐ญ๐ญ๐จ๐ฆ ๐๐ข๐ง๐
While others study algorithms for months, you can master professional tools in weeks and immediately stand out in interviews.
Tool knowledge shows professional maturity that hiring managers need.
๐ข Coming Next:
More embedded development tools that create interview advantagesโstatic analysis, debugging utilities, profiling tools. Follow for weekly insights!

A production server hang completely because of one “atomic” operation? Here’s a real Linux kernel bug that brought down enterprise systems worldwide – A Perfect case study for understanding multi-CPU concurrency challenges!
The Linux block layer had this code in the blk-mq (multi-queue block I/O) subsystem:
// ๐๐จ๐ฎ๐ง๐ญ ๐ง๐๐ฌ๐ญ๐๐ ๐๐ซ๐๐๐ณ๐ ๐จ๐ฉ๐๐ซ๐๐ญ๐ข๐จ๐ง๐ฌ
freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
if (freeze_depth == 1) {
percpu_ref_kill(&q->q_usage_counter); // Stop I/O
}
๐๐ก๐๐ญ ๐๐จ๐ฎ๐ฅ๐ ๐ ๐จ ๐ฐ๐ซ๐จ๐ง๐ ?
This bug affected ALL multi-core systems running Linux 4.19+ with blk-mq enabled, including:
Intel Xeon servers with NVMe storage
AMD EPYC systems with SATA SSDs in RAID
ARM64 servers with shared storage controllers
Enterprise systems with multipath storage configurations
what happened when two CPUs tried to freeze the same I/O queue is shown in images attached.
The solution was elegantly simple but required mainline kernel changes:
// ๐๐๐
๐๐๐: ๐๐๐๐-๐ฉ๐ซ๐จ๐ง๐ ๐๐ญ๐จ๐ฆ๐ข๐ ๐จ๐ฉ๐๐ซ๐๐ญ๐ข๐จ๐ง๐ฌ
freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
if (freeze_depth == 1) percpu_ref_kill();
// AFTER: Mutex-protected critical section
mutex_lock(&q->mq_freeze_lock);
if (++q->mq_freeze_depth == 1) {
percpu_ref_kill(&q->q_usage_counter);
}
mutex_unlock(&q->mq_freeze_lock);
๐๐ก๐ข๐ฌ ๐ซ๐๐๐ ๐๐จ๐ง๐๐ข๐ญ๐ข๐จ๐ง ๐๐๐ฎ๐ฌ๐๐ ๐ฐ๐ข๐๐๐ฌ๐ฉ๐ซ๐๐๐ ๐ฉ๐ซ๐จ๐๐ฎ๐๐ญ๐ข๐จ๐ง ๐๐๐ข๐ฅ๐ฎ๐ซ๐๐ฌ:
RAID arrays stuck in recovery
Journal threads unable to commit
Applications frozen during file writes
System requiring reboot
Key Lessons for System Design
1. Per-CPU Data Isn’t Always the Answer
2. Atomic Operations Have Limits
3. Critical Sections Must Be Identified
Questions for Discussion
1) How do you handle race conditions in your multi-threaded applications?
2) What debugging tools do you use for concurrency issues?
3) Have you encountered similar production issues with “atomic” operations?
๐ ๐๐๐๐ซ๐ง๐ข๐ง๐ ๐๐ฉ๐ฉ๐จ๐ซ๐ญ๐ฎ๐ง๐ข๐ญ๐ข๐๐ฌ:
A) ๐๐๐ฅ๐-๐๐๐๐๐ ๐๐จ๐ฎ๐ซ๐ฌ๐:
๐๐ฅ๐๐๐๐ฆ๐๐ง๐ญ ๐ฌ๐ฎ๐ฉ๐ฉ๐จ๐ซ๐ญ
Learn at your own pace
Structured kernel programming modules
Practical examples, bug studies like this one
Hands-on debugging experience
B) ๐๐๐๐ค๐๐ง๐ ๐๐ง๐ฅ๐ข๐ง๐ ๐๐จ๐ฎ๐ซ๐ฌ๐ ๐๐จ๐ซ ๐๐จ๐ซ๐ค๐ข๐ง๐ ๐๐ซ๐จ๐๐๐ฌ๐ฌ๐ข๐จ๐ง๐๐ฅ๐ฌ:
180+ Hours of comprehensive training
8 Months structured program
Flexible scheduling for working professionals
๐๐จ๐๐ฎ๐ฅ๐๐ฌ ๐๐จ๐ฏ๐๐ซ๐๐:
System Programming
Linux kernel internals
Linux device driver development
Linux socket programming
Network device drivers, PCI, USB driver walkthrough
Linux crash analysis and Kdump
JTAG debugging

Ftrace is a powerful tracing utility built directly into the Linux kernel that allows developers to trace kernel function calls with minimal overhead. It lives in the kernel’s debugfs, typically mounted at
/๐ฌ๐ฒ๐ฌ/๐ค๐๐ซ๐ง๐๐ฅ/๐๐๐๐ฎ๐ /๐ญ๐ซ๐๐๐ข๐ง๐ /
๐๐๐ญ๐ญ๐ข๐ง๐ ๐๐ฉ ๐
๐ญ๐ซ๐๐๐
The provided example shows how to configure Ftrace:
mount -t debugfs nodev /sys/kernel/debug
cd /sys/kernel/debug/tracing
# Set function graph tracer
echo function_graph > current_tracer
# Filter for specific functions
echo ‘__x64_sys_brk’ >> set_ftrace_filter
echo ‘do_brk_flags’ >> set_ftrace_filter
echo ‘__x64_sys_mmap’ >> set_ftrace_filter
echo ‘__x64_sys_mmap_pgoff’ >> set_ftrace_filter
echo ‘do_mmap’ >> set_ftrace_filter
echo ‘vm_mmap’ >> set_ftrace_filter
echo ‘vm_mmap_pgoff’ >> set_ftrace_filter
echo ‘get_unmapped_area’ >> set_ftrace_filter
echo ‘vm_unmapped_area’ >> set_ftrace_filter
# Enable tracing
echo 1 > tracing_on
๐
๐ญ๐ซ๐๐๐ ๐ข๐ง ๐๐๐ญ๐ข๐จ๐ง: ๐๐๐ฆ๐จ๐ซ๐ฒ ๐๐๐ง๐๐ ๐๐ฆ๐๐ง๐ญ ๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐
Let’s analyze the output from a memory test program calling brk, mmap etc:
— Testing brk() syscall —
Initial program break: 0x425000
Program break increased by 1MB: 0x525000
Successfully wrote to the allocated memory
Program break restored: 0x425000
— Testing mmap() syscall —
Anonymous mapping at: 0x7f95fc9f2000
Wrote to anonymous mapping: Testing anonymous mapping
Anonymous mapping unmapped
File mapping at: 0x7f95fc9f2000
First 20 bytes of /etc/passwd: root:x:0:0:root:/roo
File mapping unmapped
Fixed mapping at requested address 0x600000000000
Map with – linux/v6.14.5/source/mm/mmap.c
๐
๐ญ๐ซ๐๐๐ ๐ซ๐๐ฏ๐๐๐ฅ๐ฌ ๐ญ๐ก๐ ๐๐ฑ๐๐๐ฎ๐ญ๐ข๐จ๐ง ๐ฉ๐๐ญ๐ก ๐ฐ๐ข๐ญ๐ก ๐ญ๐ข๐ฆ๐ข๐ง๐ ๐๐๐ญ๐๐ข๐ฅ๐ฌ:
4) __x64_sys_mmap() {
4) vm_mmap_pgoff() {
4) do_mmap() {
4) get_unmapped_area() {
4) vm_unmapped_area();
4) }
4) }
4) }
4) }
๐๐๐ซ๐๐จ๐ซ๐ฆ๐๐ง๐๐ ๐ข๐ง๐ฌ๐ข๐ ๐ก๐ญ๐ฌ:
14) __x64_sys_mmap() {
14) 4.440 us | do_mmap();
14) 4.881 us | }
๐
๐จ๐ซ ๐๐ข๐ฑ๐๐ ๐ฆ๐๐ฉ๐ฉ๐ข๐ง๐ ๐ฌ:
6) __x64_sys_mmap() {
6) 1.794 us | do_mmap();
6) ! 409.690 us | } <— exclamation mark indicates a long execution time
๐๐๐ง๐๐๐ข๐ญ๐ฌ ๐๐จ๐ซ ๐๐๐๐ฎ๐ ๐ ๐ข๐ง๐
– Function call hierarchy: Seeing what functions are called in what order
– Performance measurement: Precise timing of each function
– Bottleneck identification: Finding unexpectedly slow operations
– System understanding: Revealing implementation details of system calls
๐๐ข๐ฆ๐ข๐ญ๐๐ญ๐ข๐จ๐ง๐ฌ ๐๐ง๐ ๐๐ก๐๐ฅ๐ฅ๐๐ง๐ ๐๐ฌ
– Kernel-only visibility: Limited to kernel space, doesn’t show userspace activities
– Buffer constraints: Trace buffers can overflow during extended tracing
– Security implications: May expose sensitive kernel information
Linux does not immediately recycle process identifiers (PIDs) for new processes after a process exits. Instead, PIDs are allocated sequentially up to a maximum and only reused after the range wraps around.
๐๐๐ฒ ๐๐๐๐ฌ๐จ๐ง๐ฌ ๐๐จ๐ซ ๐๐ฏ๐จ๐ข๐๐ข๐ง๐ ๐๐ฆ๐ฆ๐๐๐ข๐๐ญ๐ ๐๐๐ ๐๐๐ฎ๐ฌ๐:
๐๐ก๐ฐ๐๐ซ๐ญ๐ข๐ง๐ ๐๐ข๐ฆ๐ข๐ง๐ -๐๐๐ฌ๐๐ ๐๐ญ๐ญ๐๐๐ค๐ฌ:
Prevents attackers from predicting when a PID will be free and immediately acquiring it. This blocks attackers from spawning malicious processes with the same PID as just-terminated privileged processes.
๐๐ซ๐๐ฏ๐๐ง๐ญ๐ข๐ง๐ ๐๐ซ๐๐๐๐ง๐ญ๐ข๐๐ฅ/๐๐๐ฌ๐จ๐ฎ๐ซ๐๐ ๐๐ข๐ฃ๐๐๐ค๐ข๐ง๐ :
Blocks impersonation attacks where a new process might inherit security tokens or permissions from a recently terminated process with the same PID.
๐๐๐ข๐ง๐ญ๐๐ข๐ง๐ข๐ง๐ ๐๐๐๐ฎ๐ซ๐๐ญ๐ ๐๐จ๐ง๐ข๐ญ๐จ๐ซ๐ข๐ง๐ & ๐๐ฎ๐๐ข๐ญ๐ข๐ง๐ :
Ensures that system monitors, loggers, and auditing tools can accurately track processes without confusion. At any given moment, each PID refers to only one specific process.
๐๐ฏ๐จ๐ข๐๐ข๐ง๐ ๐๐๐๐ ๐๐จ๐ง๐๐ข๐ญ๐ข๐จ๐ง๐ฌ:
Eliminates dangerous race conditions where system operations (signals, /proc access, etc.) might accidentally target a new process that inherited a PID instead of the intended original process.
๐๐ก๐๐๐ค ๐๐๐ฌ๐ข๐ ๐ง ๐๐ก๐๐ง๐ ๐๐ฌ-
linux.git/commit/?id=5fdee8c4a5e1800489ce61963208f8cc55e42ea1
linux/v4.14.336/source/kernel/pid.c
linux/v6.15-rc4/source/kernel/pid.c
1) ๐๐จ๐ซ๐ ๐๐ฅ๐ฅ๐จ๐๐๐ญ๐ข๐จ๐ง ๐๐๐๐ก๐๐ง๐ข๐ฌ๐ฆ
nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min, pid_max, GFP_ATOMIC);
2) ๐๐๐ ๐๐๐ง๐ ๐ ๐๐๐ง๐๐ ๐๐ฆ๐๐ง๐ญ
// Determine minimum PID value for allocation
int pid_min =1;
if(idr_get_cursor(&tmp->idr)> RESERVED_PIDS)
pid_min = RESERVED_PIDS;
3) ๐๐๐ซ๐ ๐ ๐๐๐ ๐๐ฉ๐๐๐ ๐๐จ๐ง๐๐ข๐ ๐ฎ๐ซ๐๐ญ๐ข๐จ๐ง
init_pid_ns.pid_max =min(pid_max_max,max_t(int, init_pid_ns.pid_max, PIDS_PER_CPU_DEFAULT *num_possible_cpus()));
pid_max_min =max_t(int, pid_max_min, PIDS_PER_CPU_MIN *num_possible_cpus());
4) ๐๐๐ฆ๐๐ฌ๐ฉ๐๐๐ ๐๐ฌ๐จ๐ฅ๐๐ญ๐ข๐จ๐ง
struct pid_namespace init_pid_ns = {
.ns.count =REFCOUNT_INIT(2),
.idr =IDR_INIT(init_pid_ns.idr),
// …
};
๐๐ก๐ ๐ฌ๐ฒ๐ฌ๐ญ๐๐ฆ ๐ฉ๐ซ๐๐ฏ๐๐ง๐ญ๐ฌ ๐ข๐ฆ๐ฆ๐๐๐ข๐๐ญ๐ ๐๐๐ ๐ซ๐๐ฎ๐ฌ๐ ๐๐ฒ:
– Using cursor-based sequential, cyclic PID allocation
– Maintaining a large PID space.
– Ensuring PIDs are not reused until the entire PID space is exhausted
– Providing namespace isolation for container environments
๐๐จ๐ฎ๐ซ๐๐๐ฌ:
Stack Overflow โ Linux PID recycling behavior
GitHub Issue โ Kernel avoids quick PID reassignments to prevent issues
Exploit-DB (Polkit) โ Timing attack & auth hijack via PID reuse
Security StackExchange โ PID uniquely identifies an active process
Superuser โ Quick PID reuse seen as a security hazard

Walking through a real-world Linux kernel bug resolution process. The case study focused on a regression where Silicon Motion NVMe controllers stopped being detected after a kernel update.
The complete lifecycle of kernel bug handling through bugzilla.kernel.org
How NVMe’s architecture provides superior performance over traditional SATA (64K command queues vs. just a mere 32 commands!)
The intricate relationship between PCIe subsystems and storage drivers
Source code analysis of the NVMe driver’s device detection and initialization process
The actual bug fix was elegantly simple but required deep understanding:
The issue was in how the driver handled the DNR (Do Not Retry) status bit.
The original code had the logic backward – it was:
if (status > 0 && !(status & NVME_SC_DNR))
But it should have been:
if (status > 0 && (status & NVME_SC_DNR))
This seemingly small change fixed critical detection issues with Silicon Motion controllers, ensuring that non-retryable errors are properly ignored while retryable errors are correctly propagated.
Are you interested in developing these advanced Linux kernel debugging skills? Our next Linux Kernel and Device Driver Development course starts soon!
๐๐๐ญ ๐ก๐๐ง๐๐ฌ-๐จ๐ง ๐๐ฑ๐ฉ๐๐ซ๐ข๐๐ง๐๐ ๐ฐ๐ข๐ญ๐ก:
Linux kernel module structure and initialization
PCIe device enumeration and driver binding
Storage subsystem architecture
Reading technical specifications and applying them to code
Understanding kernel patch submission workflow
๐๐ฌ๐๐๐ฎ๐ฅ ๐ซ๐๐ฌ๐จ๐ฎ๐ซ๐๐๐ฌ:
Kernel.org Bugzilla: https://lnkd.in/gBvyD_f4
Bug 208583 – Regression – nvme not detected
_____________________________
๐ฝ ๐๐จ๐ฎ๐๐ฎ๐๐ ๐๐ก๐๐ง๐ง๐๐ฅ
https://lnkd.in/eYyNEqp
๐๐จ๐๐ฎ๐ฅ๐๐ฌ ๐๐จ๐ฏ๐๐ซ๐๐ –
1) System Programming
2) Linux kernel internals
3) Linux device driver
4) Linux socket programming
5) Linux network device driver, PCI, USB driver codeย walk through, Linux
crash analysis and Kdump
7) JTag debugging
– ๐๐ซ๐ข๐๐ข๐ง๐ :
https://lnkd.in/ePEK2pJh
๐๐๐๐ซ๐ง๐ข๐ง๐ ๐๐ฉ๐ฉ๐จ๐ซ๐ญ๐ฎ๐ง๐ข๐ญ๐ข๐๐ฌ:
A) ๐๐๐ฅ๐-๐๐๐๐๐ ๐๐จ๐ฎ๐ซ๐ฌ๐:
Learn at your own pace
Structured kernel programming modules
Practical examples, bug study
Hands-on debugging experience
B) ๐๐ฅ๐๐ฌ๐ฌ๐ซ๐จ๐จ๐ฆ ๐๐ซ๐๐ข๐ง๐ข๐ง๐ ๐๐จ๐ซ ๐
๐ซ๐๐ฌ๐ก๐๐ซ๐ฌ:
5 Months intensive program
Placement support
Real-world bug analysis
Kernel development fundamentals
Live projects & case studies
C) ๐๐๐๐ค๐๐ง๐ ๐๐ง๐ฅ๐ข๐ง๐ ๐๐จ๐ฎ๐ซ๐ฌ๐ ๐๐จ๐ซ ๐๐จ๐ซ๐ค๐ข๐ง๐ ๐๐ซ๐จ๐๐๐ฌ๐ฌ๐ข๐จ๐ง๐๐ฅ๐ฌ:
180+ Hours of training
8 Months comprehensive program
Flexible for working professionals
We offer live online classes (โน85,000) on weekends and recorded video lectures (โน35,000 with lifetime access) - no offline classes currently.
struct generic_struct {
int id;
float value;
char name[20];
int m;
};
hashtag#define GENERIC_STRUCT_STAT(m)ย ย sizeof(((struct generic_struct *)0)->m)
int main() {
int x = GENERIC_STRUCT_STAT(m); <———-
return0;
}
๐๐ก๐๐ญ ๐ฐ๐ข๐ฅ๐ฅ ๐ก๐๐ฉ๐ฉ๐๐ง ๐ฐ๐ก๐๐ง ๐ญ๐ก๐ ๐ฆ๐๐๐ซ๐จ ๐๐๐๐๐๐๐_๐๐๐๐๐๐_๐๐๐๐(๐ฆ) ๐ข๐ฌ ๐ฎ๐ฌ๐๐?
______________________________________________________________
A) The program will crash due to dereferencing a null pointer.
B) Compilation error.
C) The size of the member m (int) will be calculated, which is typically 4 bytes on most systems.
D) The size of the entire structure generic_struct will be calculated.