Linux Device Driver Interview Questions Complete Roadmap

1. Linux & Kernel Fundamentals

Basic

  1. What is Linux?
  2. What is the Linux kernel?
  3. What is the difference between Linux and the Linux kernel?
  4. What is the kernel space and user space?
  5. Why is user space separated from kernel space?
  6. What happens when a user-space application calls a system call?
  7. What is a system call?
  8. What is the difference between system call and library call?
  9. What is a kernel module?
  10. What is a loadable kernel module (LKM)?
  11. Why do we use kernel modules?
  12. What is the difference between built-in driver and loadable driver?
  13. What is insmod?
  14. What is rmmod?
  15. What is modprobe?
  16. Difference between insmod and modprobe.
  17. What is lsmod?
  18. What is modinfo?
  19. What is /lib/modules?
  20. What is sysfs?
  21. What is procfs?
  22. Difference between /proc and /sys.

2. Linux Device Driver Fundamentals

  1. What is a device driver?
  2. Why do we need device drivers?
  3. What are the different types of Linux drivers?
  4. What is a character driver?
  5. What is a block driver?
  6. What is a network driver?
  7. Difference between character and block drivers.
  8. What is a device?
  9. What is a device number?
  10. What is a major number?
  11. What is a minor number?
  12. Why are major and minor numbers required?
  13. What is dev_t?
  14. What is MAJOR()?
  15. What is MINOR()?
  16. What is MKDEV()?
  17. What is dynamic device number allocation?
  18. Difference between static and dynamic major number allocation.

Important APIs

alloc_chrdev_region()
register_chrdev_region()
unregister_chrdev_region()

Know why, when and how each is used.

3. Character Device Driver

This is one of the highest-priority interview areas.

Questions

  1. How do you write a basic character driver?
  2. What are the steps to create a character driver?
  3. What is struct file_operations?
  4. What is struct file?
  5. What is struct inode?
  6. What is struct cdev?
  7. Difference between inode and file.
  8. What is file_operations?
  9. Explain:
    • open()
    • read()
    • write()
    • close()
    • ioctl()
    • poll()
    • mmap()
    • llseek()
  10. How does a user-space read() reach the driver’s read() function?
  11. How does a user-space write() reach the driver’s write() function?
  12. What is private_data?
  13. How do you store driver-specific information in private_data?
  14. What is copy_to_user()?
  15. What is copy_from_user()?
  16. Why can’t we directly dereference a user-space pointer from kernel space?
  17. Difference between copy_to_user() and memcpy().
  18. What does copy_to_user() return?
  19. What does copy_from_user() return?
  20. What happens if user-space passes an invalid pointer?

4. Device Driver Registration

Know the complete sequence.

Character driver

alloc_chrdev_region()
        ↓
cdev_init()
        ↓
cdev_add()
        ↓
class_create()
        ↓
device_create()
        ↓
/dev/mydevice

Interview questions:

  1. Explain this entire flow.
  2. What does cdev_init() do?
  3. What does cdev_add() do?
  4. What is a Linux device class?
  5. What does class_create() do?
  6. What does device_create() do?
  7. Who creates /dev/mydevice?
  8. What is udev?
  9. Difference between device_create() and class_create().
  10. How do you remove a character device cleanly?

5. Kernel Module Programming

Prepare these very well.

  1. What is a kernel module?
  2. What is module_init()?
  3. What is module_exit()?
  4. What happens during module insertion?
  5. What happens during module removal?
  6. What is MODULE_LICENSE()?
  7. What is MODULE_AUTHOR()?
  8. What is MODULE_DESCRIPTION()?
  9. What is MODULE_DEVICE_TABLE()?
  10. What is EXPORT_SYMBOL()?
  11. Difference between:
  • EXPORT_SYMBOL
  • EXPORT_SYMBOL_GPL
  1. Can a kernel module call user-space functions?
  2. Can kernel code use printf()?
  3. Why do we use printk() / pr_info()?
  4. What is dmesg?
  5. How do you debug a module that fails to load?
  6. What does “Unknown symbol” mean?
  7. What is symbol resolution?

6. Kernel Memory Management

Very important for experienced Embedded Linux interviews.

  1. How does kernel memory allocation work?
  2. Difference between user-space malloc() and kernel kmalloc().
  3. What is kmalloc()?
  4. What is kzalloc()?
  5. What is kcalloc()?
  6. What is vmalloc()?
  7. Difference between kmalloc() and vmalloc().
  8. What is kfree()?
  9. What is vfree()?
  10. What are GFP flags?
  11. What is GFP_KERNEL?
  12. What is GFP_ATOMIC?
  13. Difference between GFP_KERNEL and GFP_ATOMIC.
  14. Why can’t you sleep in atomic context?
  15. What is physically contiguous memory?
  16. What is virtually contiguous memory?
  17. What is DMA?
  18. What is DMA-coherent memory?
  19. What is a memory leak?
  20. How can you detect kernel memory leaks?

7. Kernel Virtual Memory

  1. What is virtual memory?
  2. Virtual address vs physical address.
  3. What is kernel virtual address?
  4. What is physical address?
  5. What is virt_to_phys()?
  6. What is phys_to_virt()?
  7. What is ioremap()?
  8. Why do we need ioremap()?
  9. Difference between normal RAM and I/O memory.
  10. What is readl()?
  11. What is writel()?
  12. Difference between:
*ptr = value;

and

writel(value, ptr);

8. Device Tree

For modern Embedded Linux, this is extremely important.

  1. What is Device Tree?
  2. Why do we need Device Tree?
  3. What problem does Device Tree solve?
  4. What is DTS?
  5. What is DTSI?
  6. What is DTB?
  7. What is DTBO?
  8. How does Linux use Device Tree?
  9. What is a Device Tree node?
  10. What is a Device Tree property?
  11. What is compatible?
  12. What is reg?
  13. What is interrupts?
  14. What is clocks?
  15. What is gpio?
  16. What is gpios?
  17. What is status = "okay"?
  18. What does status = "disabled" mean?
  19. What is #address-cells?
  20. What is #size-cells?
  21. What are phandles?
  22. What is &label?
  23. What is Device Tree overlay?
  24. How does driver match with Device Tree?
  25. Explain of_match_table.
  26. What is MODULE_DEVICE_TABLE(of, ...)?
  27. What happens when compatible matches?
  28. How do you read a Device Tree property from a driver?
  29. What is of_property_read_u32()?
  30. What is of_get_named_gpio()?
  31. What is devm_*?

Very common interview question

How does a Device Tree node get connected to a driver?

Know this flow:

Device Tree
     ↓
compatible
     ↓
Driver of_match_table
     ↓
Kernel matching
     ↓
probe()
     ↓
Device initialized

9. Platform Driver

Extremely important.

  1. What is a platform driver?
  2. What is a platform device?
  3. Why are platform drivers used?
  4. What is struct platform_driver?
  5. What is probe()?
  6. What is remove()?
  7. When is probe() called?
  8. When is remove() called?
  9. What is platform_device?
  10. Difference between platform driver and platform device.
  11. What is platform driver matching?
  12. How does Device Tree match with platform driver?
  13. What is platform_get_resource()?
  14. What is platform_get_irq()?
  15. What is devm_ioremap_resource()?
  16. What is devm_kzalloc()?
  17. Why are devm_* APIs useful?
  18. What happens automatically when a device is removed?

10. Interrupts

Very high priority.

  1. What is an interrupt?
  2. Hardware interrupt vs software interrupt.
  3. What is IRQ?
  4. What is ISR?
  5. What is interrupt context?
  6. What is request_irq()?
  7. What is free_irq()?
  8. Explain interrupt handler.
  9. What is irqreturn_t?
  10. What is IRQ_HANDLED?
  11. What is IRQ_NONE?
  12. What is shared IRQ?
  13. What is IRQF_SHARED?
  14. Why can’t you sleep inside an ISR?
  15. Can you call kmalloc(GFP_KERNEL) inside ISR?
  16. Why do we use GFP_ATOMIC in interrupt context?
  17. What is top half?
  18. What is bottom half?
  19. Why do we need bottom halves?
  20. What is a tasklet?
  21. What is a workqueue?
  22. Difference between tasklet and workqueue.
  23. What is threaded IRQ?
  24. Difference between hard IRQ and threaded IRQ.
  25. What is request_threaded_irq()?
  26. Which operations are allowed in interrupt context?
  27. How do you handle a long interrupt operation?

11. Synchronization

One of the most frequently tested areas.

  1. Why do we need synchronization?
  2. What is a race condition?
  3. What is a critical section?
  4. What is a mutex?
  5. What is a spinlock?
  6. Difference between mutex and spinlock.
  7. When should you use a mutex?
  8. When should you use a spinlock?
  9. Can you sleep while holding a spinlock?
  10. Can you sleep while holding a mutex?
  11. Can mutex be used inside ISR?
  12. Can spinlock be used inside ISR?
  13. What is semaphore?
  14. Mutex vs semaphore.
  15. What is completion?
  16. What is atomic operation?
  17. What is atomic_t?
  18. What is atomic_inc()?
  19. What is atomic_dec()?
  20. What is deadlock?
  21. What is priority inversion?
  22. What is lock ordering?
  23. What is recursive locking?
  24. What happens if the same spinlock is acquired twice?

12. Wait Queues

  1. What is a wait queue?
  2. Why are wait queues used?
  3. What is wait_event()?
  4. What is wait_event_interruptible()?
  5. What is wake_up()?
  6. Difference between wake_up() and wake_up_interruptible().
  7. Why should a driver put a process to sleep?
  8. What is blocking I/O?
  9. What is non-blocking I/O?
  10. What does O_NONBLOCK mean?
  11. How do you implement blocking read()?
  12. How do you wake up a blocked process?

Example concept:

Application
     ↓
read()
     ↓
No data available
     ↓
Process sleeps
     ↓
Hardware interrupt
     ↓
Data available
     ↓
wake_up()
     ↓
Process resumes

13. Poll / Select / Epoll

  1. What is poll()?
  2. Why do drivers implement poll()?
  3. What is select()?
  4. What is epoll()?
  5. How does application know that device data is available?
  6. What is poll_wait()?
  7. Difference between blocking read() and poll().
  8. How do you implement poll() in a driver?

14. I/O Control – ioctl

Very common.

  1. What is ioctl()?
  2. Why do we use ioctl?
  3. When should you use read/write vs ioctl?
  4. How do you implement ioctl?
  5. What is _IO()?
  6. What is _IOR()?
  7. What is _IOW()?
  8. What is _IOWR()?
  9. Why are ioctl command numbers required?
  10. How do you pass a structure from user space to kernel?
  11. How do you safely copy ioctl data?
  12. What security problems can ioctl introduce?

15. I2C Driver

For embedded interviews, very important.

  1. What is I2C?
  2. How does I2C work?
  3. What are SDA and SCL?
  4. What is I2C slave address?
  5. What is ACK/NACK?
  6. What is repeated START?
  7. What is an I2C adapter?
  8. What is an I2C client?
  9. What is struct i2c_driver?
  10. What is struct i2c_client?
  11. What is struct i2c_adapter?
  12. What is probe() in an I2C driver?
  13. What is remove()?
  14. What is i2c_transfer()?
  15. What is i2c_master_send()?
  16. What is i2c_master_recv()?
  17. What is SMBus?
  18. I2C vs SMBus.
  19. How does Device Tree describe an I2C device?
  20. How does an I2C driver bind to a device?

16. SPI Driver

  1. What is SPI?
  2. SPI signals:
    • MOSI
    • MISO
    • CLK
    • CS
  3. SPI master vs slave.
  4. What is SPI mode?
  5. What are CPOL and CPHA?
  6. What is struct spi_driver?
  7. What is struct spi_device?
  8. What is spi_transfer?
  9. What is spi_message?
  10. Difference between I2C and SPI.
  11. How does SPI driver communicate with hardware?
  12. How is SPI device represented in Device Tree?
  13. How does SPI driver matching happen?

17. GPIO Driver

  1. What is GPIO?
  2. Input vs output GPIO.
  3. What is GPIO descriptor?
  4. What is the GPIO subsystem?
  5. How do you request a GPIO?
  6. How do you configure GPIO direction?
  7. How do you read GPIO?
  8. How do you write GPIO?
  9. What is gpiod_get()?
  10. What is gpiod_set_value()?
  11. What is gpiod_get_value()?
  12. Why is descriptor-based GPIO preferred over legacy GPIO APIs?
  13. How do you define GPIO in Device Tree?

18. Pin Control

  1. What is pinctrl?
  2. Why is pinctrl required?
  3. What is pin multiplexing?
  4. What is pin configuration?
  5. What is pinctrl-0?
  6. What is pinctrl-names?
  7. What happens if pinmux is incorrectly configured?
  8. How does Device Tree configure pins?

19. DMA

Important for high-performance embedded systems.

  1. What is DMA?
  2. Why do we need DMA?
  3. CPU vs DMA data transfer.
  4. What is DMA buffer?
  5. What is DMA mapping?
  6. What is dma_map_single()?
  7. What is dma_unmap_single()?
  8. What is dma_alloc_coherent()?
  9. What is cache coherency?
  10. What is DMA streaming mapping?
  11. What is coherent DMA?
  12. What happens if CPU cache and DMA memory are inconsistent?
  13. What is DMA mask?
  14. What is dma_set_mask_and_coherent()?

20. Device Model

  1. What is Linux device model?
  2. What is struct device?
  3. What is a bus?
  4. What is a driver?
  5. What is a device?
  6. What is a class?
  7. What is kobject?
  8. What is sysfs?
  9. What is bus-driver-device relationship?
  10. Explain:
Bus
 ├── Device
 └── Driver
  1. What is device binding?
  2. What is driver binding?
  3. What is bind/unbind?

21. Kernel Threads

  1. What is a kernel thread?
  2. Why do we need kernel threads?
  3. How do you create a kernel thread?
  4. What is kthread_run()?
  5. What is kthread_stop()?
  6. Difference between kernel thread and user-space thread.
  7. Can a kernel thread sleep?
  8. How do you stop a kernel thread safely?

22. Workqueues

  1. What is a workqueue?
  2. Why use workqueues?
  3. What is deferred work?
  4. What is work_struct?
  5. What is INIT_WORK()?
  6. What is schedule_work()?
  7. What is flush_work()?
  8. Workqueue vs kernel thread.
  9. Workqueue vs tasklet.

23. Timers

  1. What is a kernel timer?
  2. Why are timers used?
  3. What is struct timer_list?
  4. What is timer_setup()?
  5. What is mod_timer()?
  6. What is del_timer()?
  7. Can timer callback sleep?
  8. Timer vs delayed work.
  9. How do you implement periodic work?

24. Power Management

Important for automotive/embedded.

  1. What is Linux power management?
  2. What is suspend/resume?
  3. What is runtime PM?
  4. What is system suspend?
  5. What are:
    • suspend()
    • resume()
  6. What is runtime suspend?
  7. What is runtime resume?
  8. What is pm_runtime_get_sync()?
  9. What is pm_runtime_put()?
  10. Why is runtime PM important in embedded systems?
  11. How do you handle device state during suspend/resume?

25. Error Handling

  1. How do you handle errors in kernel drivers?
  2. What are kernel error codes?
  3. Why do kernel functions return negative values?
  4. What is PTR_ERR()?
  5. What is IS_ERR()?
  6. What is ERR_PTR()?
  7. Difference between NULL pointer and ERR_PTR.
  8. What is dev_err()?
  9. What is dev_warn()?
  10. What is dev_info()?
  11. How do you clean up resources if probe fails halfway?

Very important pattern

Resource 1 acquired
        ↓
Resource 2 acquired
        ↓
Resource 3 fails
        ↓
Release Resource 2
        ↓
Release Resource 1
        ↓
Return error

26. Device-Managed Resources

  1. What is devm_kzalloc()?
  2. What is devm_ioremap_resource()?
  3. What is devm_request_irq()?
  4. Why use devm_* functions?
  5. When are managed resources automatically released?
  6. Difference between kzalloc() and devm_kzalloc().

27. Memory-Mapped I/O

  1. What is MMIO?
  2. What is a memory-mapped register?
  3. How does CPU access hardware registers?
  4. What is ioremap()?
  5. What are readb/readw/readl?
  6. What are writeb/writew/writel?
  7. Why shouldn’t normal pointer dereferencing be used for MMIO?
  8. What is register polling?
  9. What is register masking?
  10. How do you set/clear a register bit safely?

28. C Concepts for Driver Interviews

Because Linux drivers are heavily based on C, prepare:

  1. Pointer
  2. Pointer to pointer
  3. Function pointer
  4. Callback function
  5. Structure
  6. Union
  7. Structure padding
  8. Bit fields
  9. Bit manipulation
  10. volatile
  11. const
  12. static
  13. extern
  14. inline
  15. typedef
  16. Macro
  17. Preprocessor
  18. Memory alignment
  19. Endianness
  20. Signed vs unsigned
  21. Race conditions
  22. Stack vs heap
  23. Function pointers
  24. Linked lists
  25. Circular buffers

Especially know:

volatile
const
static

and:

struct
union
enum
typedef

29. Linked Lists in Kernel

  1. Why does Linux use linked lists?
  2. What is struct list_head?
  3. What is an intrusive linked list?
  4. What is INIT_LIST_HEAD()?
  5. What is list_add()?
  6. What is list_del()?
  7. What is list_for_each()?
  8. What is container_of()?
  9. Why is container_of() important?
  10. Explain how Linux retrieves a parent structure from list_head.

30. container_of()

This is a favorite interview question.

struct device_data {
    int value;
    struct list_head list;
};

Question:

If you have a pointer to list, how do you get device_data?

Answer:

container_of()

Know how offsetof() works as well.

31. Concurrency & Race Conditions

Prepare real scenarios:

  1. What is a race condition?
  2. How can two processes access the same driver?
  3. How can interrupt and process context race?
  4. How do you protect shared data?
  5. Mutex vs spinlock.
  6. Atomic variables.
  7. Memory barriers.
  8. What is smp_mb()?
  9. What is READ_ONCE()?
  10. What is WRITE_ONCE()?
  11. What is lock contention?
  12. What is deadlock?
  13. How do you debug deadlock?

32. Atomic Context vs Process Context

Very important.

Process context

Can generally:

Sleep
Schedule
Acquire mutex
kmalloc(GFP_KERNEL)
Wait for resources

Interrupt/atomic context

Cannot sleep.

Generally use:

Spinlock
GFP_ATOMIC
Atomic operations

Interview question:

Why can’t an interrupt handler sleep?

You should be able to explain this clearly.

33. Debugging Linux Drivers

  1. How do you debug a kernel driver?
  2. What is dmesg?
  3. What is printk?
  4. What is dynamic debug?
  5. What is ftrace?
  6. What is tracepoint?
  7. What is debugfs?
  8. What is sysfs?
  9. How do you debug kernel panic?
  10. What is Oops?
  11. What is kernel panic?
  12. Difference between Oops and kernel panic.
  13. What is NULL pointer dereference?
  14. How do you find the source line of a crash?
  15. What is addr2line?
  16. What is gdb?
  17. What is KGDB?
  18. What is KASAN?
  19. What is lockdep?
  20. What is kmemleak?

34. Kernel Crash Scenarios

Interviewers may give scenarios.

Example

Driver crashes with NULL pointer dereference. What will you do?

Expected approach:

Check dmesg
   ↓
Find faulting address
   ↓
Find call stack
   ↓
Identify source line
   ↓
Check pointer initialization
   ↓
Check probe/remove sequence
   ↓
Fix and reproduce

Other scenarios:

  1. Kernel panic during module insertion.
  2. Driver probe is never called.
  3. read() blocks forever.
  4. Interrupt never occurs.
  5. I2C device isn’t detected.
  6. SPI communication fails.
  7. /dev/mydevice isn’t created.
  8. Driver loads but doesn’t bind.
  9. DMA data is corrupted.
  10. System freezes when driver is unloaded.

35. Sysfs

  1. What is sysfs?
  2. Why does sysfs exist?
  3. How does driver expose attributes?
  4. What is struct device_attribute?
  5. What are show() and store()?
  6. What is DEVICE_ATTR()?
  7. Difference between sysfs and procfs.
  8. When should you use sysfs?
  9. Why shouldn’t sysfs be used for large data transfers?

36. Procfs

  1. What is /proc?
  2. What information does /proc provide?
  3. Can a driver create /proc entries?
  4. Difference between /proc and /sys.
  5. When would you use procfs?

37. Debugfs

  1. What is debugfs?
  2. Why is debugfs used?
  3. Difference between sysfs and debugfs.
  4. Should production applications depend on debugfs?
  5. How can a driver expose debugging information through debugfs?

38. User Space ↔ Kernel Space

Very important.

Know these mechanisms:

System calls
     ↓
ioctl
     ↓
read/write
     ↓
mmap
     ↓
poll/select/epoll

Questions:

  1. How does user space communicate with driver?
  2. Why can’t user space directly access kernel memory?
  3. What is a system call?
  4. What happens during read()?
  5. What happens during write()?
  6. What happens during ioctl()?
  7. What is mmap()?
  8. Why use mmap()?
  9. What is zero-copy?

39. mmap in Device Drivers

  1. What is mmap()?
  2. Why map kernel/device memory to user space?
  3. How does driver implement mmap?
  4. What is zero-copy?
  5. What are the security risks of mmap?
  6. Difference between read/write and mmap.

40. Block Drivers

For advanced interviews:

  1. What is a block device?
  2. Character vs block device.
  3. What is a block layer?
  4. What is a request queue?
  5. What is bio?
  6. What is I/O scheduler?
  7. What is /dev/sda?
  8. What is /dev/mmcblk0?
  9. What is NVMe?
  10. Basic Linux storage stack.

41. Network Drivers

If the job requires networking:

  1. What is a network driver?
  2. What is struct net_device?
  3. What is NAPI?
  4. What is interrupt-driven packet reception?
  5. Why is NAPI used?
  6. What is sk_buff?
  7. What is TX/RX ring?
  8. What is DMA in network drivers?
  9. What happens when an Ethernet packet arrives?
  10. Explain Linux network stack.

42. Boot Process + Driver

Very common in Embedded Linux.

Know:

Power ON
   ↓
Boot ROM
   ↓
Bootloader
   ↓
Kernel
   ↓
Device Tree
   ↓
Kernel initialization
   ↓
Driver initialization
   ↓
Root filesystem
   ↓
init/systemd
   ↓
User application

Questions:

  1. What happens after power-on?
  2. What is BootROM?
  3. What is U-Boot?
  4. What does U-Boot do?
  5. How does U-Boot load Device Tree?
  6. How does kernel start?
  7. When are drivers initialized?
  8. What is initcall?
  9. What is root filesystem?
  10. What happens if the driver is built into the kernel?

43. Kernel Build System

  1. What is Kconfig?
  2. What is Makefile in kernel?
  3. What is .config?
  4. What is menuconfig?
  5. What is defconfig?
  6. What is CONFIG_*?
  7. Built-in vs module:
CONFIG_DRIVER=y
CONFIG_DRIVER=m
CONFIG_DRIVER=n
  1. Difference between y, m, and n.
  2. How do you enable a driver?
  3. How do you build an external module?

44. Cross Compilation

For Embedded Linux:

  1. What is cross compilation?
  2. Why do we cross compile?
  3. Host vs target.
  4. What is cross compiler?
  5. What is ARCH?
  6. What is CROSS_COMPILE?
  7. How do you build a kernel for ARM?
  8. How do you build an external driver for another architecture?
  9. What is kernel build directory?
  10. Why must module and kernel versions/configuration match?

45. Linux Driver + Yocto

Since Embedded Linux jobs often combine these skills:

  1. What is Yocto?
  2. What is BitBake?
  3. How do you add a kernel driver to Yocto?
  4. What is a recipe?
  5. What is a layer?
  6. What is SRC_URI?
  7. What is inherit module?
  8. How do you compile an external kernel module using Yocto?
  9. How do you add a Device Tree change?
  10. How do you enable a kernel configuration?
  11. What is KERNEL_MODULE_AUTOLOAD?
  12. What is IMAGE_INSTALL?
  13. Difference between built-in driver and module in Yocto.
  14. How do you debug a driver build failure in BitBake?

46. Real-Time / Automotive Driver Questions

For automotive Embedded Linux, prepare:

  1. What is PREEMPT?
  2. What is PREEMPT_RT?
  3. What is real-time Linux?
  4. What is interrupt latency?
  5. What is scheduling latency?
  6. What is priority inversion?
  7. What is CPU affinity?
  8. What is SCHED_FIFO?
  9. What is SCHED_RR?
  10. What is SCHED_OTHER?
  11. How do you reduce driver latency?
  12. How do you handle high-frequency interrupts?
  13. How do you handle DMA buffers?
  14. How do you debug intermittent audio/data loss?

47. Most Important Scenario Questions

These are particularly useful for interviews:

Scenario 1

Driver is loaded but probe() isn’t called. Why?

Possible areas:

compatible mismatch
Device Tree disabled
driver not registered
wrong bus
missing device
module not loaded

Scenario 2

/dev/mydevice doesn’t exist. What do you check?

Driver loaded?
       ↓
Major/minor allocated?
       ↓
cdev_add() successful?
       ↓
class_create()?
       ↓
device_create()?
       ↓
udev?

Scenario 3

Interrupt isn’t coming.

Check:

Device Tree IRQ
      ↓
IRQ number
      ↓
request_irq()
      ↓
Hardware interrupt enable
      ↓
GPIO/pinmux
      ↓
Interrupt controller
      ↓
ISR

Scenario 4

I2C device doesn’t respond.

Check:

Power
 ↓
SDA/SCL
 ↓
Pull-ups
 ↓
Pinmux
 ↓
I2C address
 ↓
Bus speed
 ↓
Device Tree
 ↓
I2C controller
 ↓
Driver

Scenario 5

System freezes randomly.

Think about:

Deadlock
Race condition
Spinlock issue
Interrupt storm
Memory corruption
Use-after-free
NULL pointer
DMA corruption

48. Must-Know Kernel APIs

Try to recognize these immediately:

kmalloc()
kzalloc()
kfree()

copy_to_user()
copy_from_user()

mutex_lock()
mutex_unlock()

spin_lock()
spin_unlock()

wait_event()
wake_up()

request_irq()
free_irq()

ioremap()
iounmap()

readl()
writel()

alloc_chrdev_region()
cdev_init()
cdev_add()

class_create()
device_create()

platform_driver_register()
platform_driver_unregister()

devm_kzalloc()
devm_request_irq()

request_threaded_irq()

schedule_work()

kthread_run()
kthread_stop()

dma_alloc_coherent()
dma_map_single()
dma_unmap_single()

49. Top 30 Questions You MUST Prepare

If your interview is soon, prioritize these:

  1. What is a Linux device driver?
  2. Kernel space vs user space.
  3. Character vs block driver.
  4. Major/minor number.
  5. file_operations.
  6. inode vs file.
  7. cdev.
  8. alloc_chrdev_region().
  9. cdev_add().
  10. class_create() and device_create().
  11. copy_to_user() / copy_from_user().
  12. Kernel module lifecycle.
  13. Device Tree.
  14. compatible property.
  15. Device Tree → driver → probe().
  16. Platform driver.
  17. probe() and remove().
  18. Interrupt handling.
  19. Top half vs bottom half.
  20. Workqueue vs tasklet.
  21. Mutex vs spinlock.
  22. Process context vs interrupt context.
  23. Wait queue.
  24. kmalloc() vs vmalloc().
  25. GFP_KERNEL vs GFP_ATOMIC.
  26. MMIO and ioremap().
  27. I2C driver architecture.
  28. SPI driver architecture.
  29. DMA.
  30. Driver debugging using dmesg, ftrace, debugfs, etc.

Recommended interview preparation order

C fundamentals
      ↓
Linux fundamentals
      ↓
Kernel/User space
      ↓
Kernel modules
      ↓
Character drivers
      ↓
Device model
      ↓
Device Tree
      ↓
Platform drivers
      ↓
Interrupts
      ↓
Synchronization
      ↓
Wait queues
      ↓
Memory management
      ↓
I2C
      ↓
SPI
      ↓
GPIO
      ↓
DMA
      ↓
Power management
      ↓
Debugging
      ↓
Yocto + Driver
      ↓
Real-world scenarios

Linux Internals Interview Questions – Complete A-Z

1. Linux Architecture

  1. What is Linux?
  2. What is the Linux kernel?
  3. Explain Linux architecture.
  4. What are the major components of Linux?
  5. What is kernel space?
  6. What is user space?
  7. Why are user space and kernel space separated?
  8. What happens when a user application starts?
  9. What happens when a Linux command is executed?
  10. What happens when you execute ./a.out?
  11. What is the role of the shell?
  12. What is the role of the kernel?
  13. What is GNU/Linux?
  14. What is monolithic kernel?
  15. Is Linux a monolithic kernel?
  16. What is a modular monolithic kernel?
  17. Monolithic vs microkernel.
  18. What are the advantages of Linux’s architecture?
  19. What are kernel subsystems?
  20. Explain the Linux kernel at a high level.

Know this architecture

User Applications
       ↓
Libraries
       ↓
System Calls
       ↓
Linux Kernel
 ┌───────────────┐
 │ Process Mgmt  │
 │ Memory Mgmt   │
 │ VFS           │
 │ Networking    │
 │ IPC           │
 │ Drivers       │
 │ Scheduler     │
 └───────────────┘
       ↓
Hardware

2. Boot Process

  1. What happens when a Linux system powers ON?
  2. What is Boot ROM?
  3. What is firmware?
  4. What is a bootloader?
  5. What is U-Boot?
  6. What does U-Boot do?
  7. How does bootloader load the kernel?
  8. How does bootloader load Device Tree?
  9. What is Image?
  10. What is zImage?
  11. What is uImage?
  12. What is FIT image?
  13. What is initramfs?
  14. What is root filesystem?
  15. What is /sbin/init?
  16. What is systemd?
  17. What happens after kernel decompression?
  18. What is start_kernel()?
  19. What happens inside start_kernel()?
  20. How does Linux initialize devices?
  21. What are initcalls?
  22. What is early_initcall()?
  23. What is subsys_initcall()?
  24. What is module_init()?
  25. How does Linux finally start user space?

Embedded Linux boot flow

Power ON
   ↓
Boot ROM
   ↓
Bootloader
   ↓
DRAM Initialization
   ↓
Load Kernel
   ↓
Load Device Tree
   ↓
Kernel
   ↓
start_kernel()
   ↓
Kernel Initialization
   ↓
Root Filesystem
   ↓
init/systemd
   ↓
User Applications

3. Process Internals

This is one of the most important Linux Internal topics.

  1. What is a process?
  2. What is a program?
  3. Program vs process.
  4. What happens when a process is created?
  5. What is PCB?
  6. What is task_struct?
  7. What information is stored in task_struct?
  8. What is PID?
  9. What is PPID?
  10. What is TGID?
  11. What is TID?
  12. What is a process ID namespace?
  13. What is process state?
  14. Explain:
  • Running
  • Runnable
  • Sleeping
  • Stopped
  • Zombie
  1. What is a zombie process?
  2. What is an orphan process?
  3. What happens to an orphan process?
  4. What is init/PID 1?
  5. What is fork()?
  6. What is vfork()?
  7. Difference between fork() and vfork().
  8. What is clone()?
  9. How does Linux create a process?
  10. What happens internally during fork()?
  11. What is exec()?
  12. Difference between fork() and exec().
  13. What is wait()?
  14. What is waitpid()?
  15. Why does a parent call wait()?
  16. What is process termination?
  17. What happens when exit() is called?
  18. What is _exit()?
  19. exit() vs _exit().
  20. What is process hierarchy?
  21. What is a process tree?
  22. What is pstree?
  23. What is process context?

4. Threads

  1. What is a thread?
  2. Process vs thread.
  3. Why use threads?
  4. What resources are shared between threads?
  5. What resources are private to each thread?
  6. Do threads have separate address spaces?
  7. What is a kernel thread?
  8. User thread vs kernel thread.
  9. What is pthread_create()?
  10. What is pthread_join()?
  11. What is thread cancellation?
  12. What is thread-local storage?
  13. What is TLS?
  14. How does Linux implement threads?
  15. What is clone()?
  16. Why are Linux threads often described as tasks?
  17. What is a thread group?
  18. What is TGID?
  19. What is TID?

5. CPU Scheduling

Very frequently asked.

  1. What is process scheduling?
  2. Why do we need a scheduler?
  3. What is the Linux scheduler?
  4. What is context switching?
  5. What happens during a context switch?
  6. Process context vs interrupt context.
  7. What is preemptive scheduling?
  8. What is cooperative scheduling?
  9. What is scheduling latency?
  10. What is time slice?
  11. What is priority?
  12. What is nice value?
  13. What is nice?
  14. What is renice?
  15. What is CFS?
  16. What is the Completely Fair Scheduler?
  17. What is SCHED_NORMAL?
  18. What is SCHED_FIFO?
  19. What is SCHED_RR?
  20. What is SCHED_DEADLINE?
  21. FIFO vs Round Robin.
  22. Real-time scheduling vs normal scheduling.
  23. What is starvation?
  24. What is priority inversion?
  25. How is priority inversion handled?
  26. What is CPU affinity?
  27. What is taskset?
  28. What is CPU isolation?
  29. What is load balancing?
  30. How does Linux select the next task?
  31. What is a runqueue?
  32. What is scheduler tick?
  33. What is tickless Linux?
  34. What is CONFIG_NO_HZ?

6. Context Switching

  1. What is context switching?
  2. Why does context switching happen?
  3. What is saved during context switch?
  4. What is restored?
  5. Process context switch vs thread context switch.
  6. What is register context?
  7. What is stack context?
  8. What is address-space switching?
  9. Why is context switching expensive?
  10. What happens to CPU cache during context switching?
  11. What is TLB?
  12. Does every context switch flush the TLB?
  13. How does ASID/PCID help?
  14. What is voluntary context switching?
  15. What is involuntary context switching?
  16. How can you measure context switches?

7. System Calls

One of the most important Linux internals topics.

  1. What is a system call?
  2. Why are system calls needed?
  3. User function vs system call.
  4. Library call vs system call.
  5. What happens internally when read() is called?
  6. What happens when write() is called?
  7. What happens when open() is called?
  8. What happens when fork() is called?
  9. What happens when execve() is called?
  10. What is system call number?
  11. How does kernel identify a system call?
  12. What is syscall entry?
  13. What is syscall return?
  14. What is trap instruction?
  15. What is privilege-level transition?
  16. What happens to CPU registers during syscall?
  17. How does user space return from kernel space?
  18. What is strace?
  19. How can strace help debug applications?
  20. Can user space directly call kernel functions?
  21. Why can’t user space access kernel memory directly?

8. CPU Privilege Levels

  1. What is privilege?
  2. User mode vs kernel mode.
  3. What is ring 0?
  4. What is ring 3?
  5. Why does Linux use different privilege levels?
  6. What happens during user → kernel transition?
  7. What happens during kernel → user transition?
  8. What is a trap?
  9. What is an exception?
  10. What is an interrupt?
  11. Interrupt vs exception vs trap.

9. Virtual Memory

Extremely important.

  1. What is virtual memory?
  2. Why does Linux use virtual memory?
  3. Virtual address vs physical address.
  4. What is address space?
  5. What is process address space?
  6. What is virtual address space?
  7. What is page?
  8. What is page frame?
  9. What is page table?
  10. What is multi-level page table?
  11. Why are multi-level page tables used?
  12. What is MMU?
  13. What is TLB?
  14. Why do we need TLB?
  15. What is page fault?
  16. Minor vs major page fault.
  17. What happens during a page fault?
  18. What is demand paging?
  19. What is lazy allocation?
  20. What is copy-on-write?
  21. How does fork() use copy-on-write?
  22. What is memory mapping?
  23. What is mmap()?
  24. What is anonymous memory?
  25. What is file-backed memory?
  26. What is shared memory?
  27. What is private memory?
  28. What is memory overcommit?
  29. What is ASLR?
  30. What is memory protection?

10. Process Address Space

Know this diagram:

High Address
+------------------+
| Kernel Space     |
+------------------+
| Stack            |
|        ↓         |
|                  |
|        ↑         |
| Heap             |
+------------------+
| BSS              |
| Data             |
| Text             |
+------------------+
Low Address

Questions:

  1. What is text segment?
  2. What is data segment?
  3. What is BSS?
  4. What is heap?
  5. What is stack?
  6. Heap vs stack.
  7. Where are global variables stored?
  8. Where are static variables stored?
  9. Where are local variables stored?
  10. Where are string literals stored?
  11. What causes stack overflow?
  12. What is stack frame?
  13. What is function call stack?
  14. What is ASLR?
  15. How does shared library memory appear in process address space?

11. Memory Allocation

  1. What is malloc()?
  2. What happens internally during malloc()?
  3. malloc() vs calloc().
  4. malloc() vs realloc().
  5. What is brk()?
  6. What is sbrk()?
  7. What is mmap() used for in memory allocation?
  8. How does glibc allocate memory?
  9. What is memory fragmentation?
  10. Internal vs external fragmentation.
  11. What is memory leak?
  12. How do you find memory leaks?
  13. What is valgrind?
  14. What is AddressSanitizer?
  15. What is double free?
  16. What is use-after-free?
  17. What is dangling pointer?

12. Kernel Memory Management

  1. What is kmalloc()?
  2. What is kzalloc()?
  3. What is vmalloc()?
  4. kmalloc() vs vmalloc().
  5. What is GFP_KERNEL?
  6. What is GFP_ATOMIC?
  7. Why can’t GFP_KERNEL be used in interrupt context?
  8. What is the buddy allocator?
  9. What is SLAB?
  10. What is SLUB?
  11. What is SLOB?
  12. Why does Linux use slab allocation?
  13. What is an object cache?
  14. What is page allocator?
  15. What is high memory?
  16. What is low memory?
  17. What is physically contiguous memory?
  18. What is virtually contiguous memory?

13. Buddy Allocator

  1. What is buddy system?
  2. Why is buddy allocator used?
  3. What is an order?
  4. What is an order-0 page?
  5. How does buddy splitting work?
  6. How does buddy merging work?
  7. What is external fragmentation?
  8. Why can’t large physically contiguous allocations always succeed?
  9. What is compaction?

14. Slab / SLUB Allocator

  1. Why do we need slab allocator?
  2. What is a slab?
  3. What is a cache?
  4. What is an object?
  5. Slab vs page allocator.
  6. SLAB vs SLUB.
  7. Why is SLUB commonly used?
  8. What is kmem_cache_create()?
  9. What is kmem_cache_alloc()?
  10. What is kmem_cache_free()?

15. Page Cache

  1. What is page cache?
  2. Why does Linux use page cache?
  3. How does read() interact with page cache?
  4. How does write() interact with page cache?
  5. What is buffered I/O?
  6. What is direct I/O?
  7. What is O_DIRECT?
  8. What is dirty page?
  9. What is writeback?
  10. What is fsync()?
  11. What is sync()?
  12. What is fdatasync()?
  13. What is writeback cache?
  14. What happens if RAM becomes full of cached data?

16. File Descriptors

  1. What is a file descriptor?
  2. Why does Linux represent devices/files using file descriptors?
  3. What is FD 0?
  4. What is FD 1?
  5. What is FD 2?
  6. What happens when open() is called?
  7. What is a file descriptor table?
  8. What is an open file description?
  9. What is struct file?
  10. What is an inode?
  11. FD vs inode vs file.
  12. What happens when close() is called?
  13. What happens if two processes share an FD?
  14. What happens after fork()?
  15. What is dup()?
  16. What is dup2()?
  17. What is dup3()?
  18. What is FD inheritance?

17. VFS – Virtual File System

Very important for Linux internals.

  1. What is VFS?
  2. Why does Linux need VFS?
  3. What is a filesystem?
  4. What is an inode?
  5. What is a dentry?
  6. What is struct file?
  7. What is super_block?
  8. Explain:
Process
   ↓
System Call
   ↓
VFS
   ↓
Filesystem
   ↓
Block Layer
   ↓
Device Driver
   ↓
Hardware
  1. What is inode cache?
  2. What is dentry cache?
  3. What is pathname lookup?
  4. What happens during open("/home/test.txt")?
  5. What is namei?
  6. What is mount?
  7. What is superblock?
  8. Hard link vs symbolic link.
  9. What happens when a file is deleted?
  10. Can a deleted file still be open?

18. Filesystem Internals

  1. What is ext4?
  2. What is inode?
  3. What is directory entry?
  4. What is block?
  5. What is filesystem block size?
  6. What is journaling?
  7. Why is journaling needed?
  8. What happens after sudden power failure?
  9. What is fsck?
  10. What is mount?
  11. What is unmount?
  12. What is /etc/fstab?
  13. What is root filesystem?
  14. What is tmpfs?
  15. What is procfs?
  16. What is sysfs?
  17. What is devtmpfs?
  18. What is debugfs?
  19. What is overlayfs?
  20. What is NFS?

19. IPC – Inter-Process Communication

  1. What is IPC?
  2. Why is IPC needed?
  3. What are the IPC mechanisms?
  4. Pipe
  5. FIFO
  6. Message queue
  7. Shared memory
  8. Semaphore
  9. Signal
  10. Socket
  11. Pipe vs FIFO.
  12. Message queue vs shared memory.
  13. Shared memory vs pipe.
  14. Which IPC mechanism is fastest?
  15. Why is shared memory fast?
  16. How do you synchronize shared memory?

20. Pipes

  1. What is a pipe?
  2. How does pipe() work?
  3. Anonymous pipe vs named pipe.
  4. What is FIFO?
  5. What happens if pipe buffer is full?
  6. What happens if no reader exists?
  7. Is pipe unidirectional?
  8. How is pipe implemented inside kernel?

21. Signals

  1. What is a signal?
  2. Why are signals used?
  3. What is SIGINT?
  4. SIGTERM vs SIGKILL.
  5. SIGSTOP vs SIGCONT.
  6. What is SIGSEGV?
  7. What is SIGCHLD?
  8. What happens when a signal is generated?
  9. What is signal handler?
  10. Can you catch SIGKILL?
  11. Can you catch SIGSTOP?
  12. Signal vs interrupt.
  13. What is signal masking?
  14. What is pending signal?
  15. What is blocked signal?
  16. What is sigaction()?
  17. Why is sigaction() preferred over old signal()?

22. Shared Memory

  1. What is shared memory?
  2. Why is shared memory fast?
  3. What is mmap()?
  4. What is POSIX shared memory?
  5. What is System V shared memory?
  6. Shared memory synchronization.
  7. Can multiple processes write simultaneously?
  8. What happens without synchronization?
  9. Shared memory vs message queue.

23. Synchronization

  1. What is synchronization?
  2. What is race condition?
  3. What is critical section?
  4. What is mutex?
  5. What is semaphore?
  6. What is spinlock?
  7. Mutex vs semaphore.
  8. Mutex vs spinlock.
  9. What is read-write lock?
  10. What is RCU?
  11. What is atomic operation?
  12. What is atomic_t?
  13. What is memory barrier?
  14. What is deadlock?
  15. What is livelock?
  16. What is starvation?
  17. What is priority inversion?
  18. How do you avoid deadlocks?
  19. What is lock ordering?
  20. Can a mutex be used in interrupt context?
  21. Can a spinlock be used in process context?
  22. Can you sleep while holding a spinlock?

24. RCU

For advanced interviews:

  1. What is RCU?
  2. Why was RCU introduced?
  3. Read-copy-update concept.
  4. Why is RCU useful for read-heavy workloads?
  5. What is an RCU read-side critical section?
  6. What is rcu_read_lock()?
  7. What is rcu_read_unlock()?
  8. What is synchronize_rcu()?
  9. RCU vs mutex.
  10. RCU vs spinlock.

25. Deadlock

  1. What is deadlock?
  2. Four conditions for deadlock.
  3. Mutual exclusion.
  4. Hold and wait.
  5. No preemption.
  6. Circular wait.
  7. How do you prevent deadlock?
  8. How do you debug deadlock?
  9. What is lockdep?
  10. Give an example of kernel deadlock.

26. Interrupts

  1. What is an interrupt?
  2. Hardware vs software interrupt.
  3. What is IRQ?
  4. What is ISR?
  5. Interrupt context.
  6. What happens when an interrupt occurs?
  7. What is interrupt controller?
  8. What is IRQ number?
  9. Shared IRQ.
  10. Edge-triggered vs level-triggered.
  11. What is interrupt affinity?
  12. What is interrupt storm?
  13. What is interrupt latency?
  14. What is top half?
  15. What is bottom half?
  16. What is threaded IRQ?
  17. What is tasklet?
  18. What is workqueue?
  19. Why can’t ISR sleep?
  20. What is request_irq()?
  21. What is free_irq()?

27. Kernel Timers

  1. What is kernel timer?
  2. Why use kernel timers?
  3. What is timer callback?
  4. Can timer callback sleep?
  5. Timer vs workqueue.
  6. Timer vs delayed work.
  7. What happens if timer callback takes too long?
  8. How do you create a kernel timer?

28. Workqueues

  1. What is workqueue?
  2. Why defer work?
  3. What is work_struct?
  4. What is schedule_work()?
  5. Can workqueue sleep?
  6. Workqueue vs tasklet.
  7. Workqueue vs kernel thread.
  8. What is ordered workqueue?
  9. What is dedicated workqueue?

29. Kernel Threads

  1. What is a kernel thread?
  2. How is it different from a user thread?
  3. What is kthread_run()?
  4. What is kthread_stop()?
  5. Can kernel threads sleep?
  6. How does a kernel thread terminate?
  7. Why would a driver use a kernel thread?

30. Networking Internals

For Embedded Linux, prepare the basics.

  1. Explain Linux networking architecture.
  2. What happens when you run:
ping 8.8.8.8
  1. What happens when an Ethernet frame arrives?
  2. What is NIC?
  3. What is network driver?
  4. What is net_device?
  5. What is socket?
  6. What is socket buffer (sk_buff)?
  7. What is TCP/IP stack?
  8. What is ARP?
  9. What is routing?
  10. What is IP address?
  11. MAC address vs IP address.
  12. TCP vs UDP.
  13. What is port?
  14. What is network namespace?
  15. What is NAPI?
  16. Why is NAPI required?
  17. Interrupt-driven RX vs polling.
  18. What is checksum offload?
  19. What is TSO?
  20. What is GRO?
  21. What is RSS?
  22. What is DMA in network drivers?

31. Socket Internals

  1. What is a socket?
  2. What happens during socket()?
  3. What happens during bind()?
  4. What happens during listen()?
  5. What happens during accept()?
  6. What happens during connect()?
  7. What happens during send()?
  8. What happens during recv()?
  9. What is socket buffer?
  10. Blocking vs non-blocking socket.
  11. What is select()?
  12. What is poll()?
  13. What is epoll()?
  14. Why is epoll() efficient?
  15. Level-triggered vs edge-triggered.

32. DMA

  1. What is DMA?
  2. Why use DMA?
  3. CPU copy vs DMA.
  4. What is DMA buffer?
  5. What is DMA mapping?
  6. What is DMA coherent memory?
  7. What is cache coherency?
  8. dma_map_single().
  9. dma_unmap_single().
  10. dma_alloc_coherent().
  11. Streaming DMA vs coherent DMA.
  12. What is DMA mask?
  13. What is IOMMU?
  14. CPU cache vs DMA.
  15. What happens if cache isn’t synchronized?

33. Device Model

  1. What is Linux device model?
  2. What is a device?
  3. What is a driver?
  4. What is a bus?
  5. What is a class?
  6. What is kobject?
  7. What is sysfs?
  8. What is device binding?
  9. What is driver binding?
  10. Explain:
Bus
 ├── Device
 └── Driver
  1. What is struct device?
  2. What is reference counting?
  3. What is kref?
  4. What is hotplug?
  5. What is uevent?
  6. What is udev?

34. Device Tree

  1. What is Device Tree?
  2. Why do we need Device Tree?
  3. DTS vs DTSI.
  4. DTS vs DTB.
  5. What is DTBO?
  6. What is a node?
  7. What is a property?
  8. What is compatible?
  9. What is reg?
  10. What is interrupts?
  11. What is clocks?
  12. What is gpios?
  13. What is status?
  14. What is phandle?
  15. What is Device Tree overlay?
  16. How does Device Tree bind to a driver?
  17. What is of_match_table?
  18. What is of_device_id?
  19. What is probe()?
  20. How does the kernel discover hardware from Device Tree?

35. Kernel Modules

  1. What is kernel module?
  2. Why use modules?
  3. Built-in vs module.
  4. What is .ko?
  5. What is insmod?
  6. What is modprobe?
  7. What is rmmod?
  8. What is lsmod?
  9. What is modinfo?
  10. What is module dependency?
  11. What is symbol export?
  12. What is EXPORT_SYMBOL()?
  13. What is EXPORT_SYMBOL_GPL()?
  14. What happens during module loading?
  15. What happens during unloading?
  16. Why can a module fail to unload?
  17. What is module reference count?

36. Sysfs / Procfs / Debugfs

  1. What is sysfs?
  2. What is procfs?
  3. What is debugfs?
  4. Difference between them.
  5. What information is exposed through /proc?
  6. What information is exposed through /sys?
  7. Why shouldn’t debugfs be used as a stable application interface?
  8. How does a driver create a sysfs attribute?
  9. What are show() and store()?
  10. What is DEVICE_ATTR()?

37. Kernel Synchronization Context

Interviewers love scenario questions:

Q: Can you sleep here?

Prepare answers for:

ContextCan Sleep?
User processYes
Kernel process contextYes
Kernel threadYes
Interrupt handlerNo
Timer callbackNo
Spinlock-held contextNo
Atomic contextNo

Then expect:

Why?

What API can you use instead?

Which GFP flag should you use?

38. ELF & Program Loading

  1. What is ELF?
  2. What is an ELF executable?
  3. What is an ELF header?
  4. What is a program header?
  5. What is a section header?
  6. What is .text?
  7. What is .data?
  8. What is .bss?
  9. What is symbol table?
  10. What is relocation?
  11. What is dynamic linking?
  12. What is static linking?
  13. Static vs dynamic linking.
  14. What is a shared library?
  15. What is .so?
  16. What is the dynamic linker?
  17. What is ld.so?
  18. What happens when you execute an ELF binary?
  19. What is ASLR?
  20. What is PIE?

39. Dynamic Linking

  1. Static vs dynamic library.
  2. What is .so?
  3. What is LD_LIBRARY_PATH?
  4. What is ldconfig?
  5. What is dynamic linker?
  6. What is symbol resolution?
  7. What is PLT?
  8. What is GOT?
  9. What is lazy binding?
  10. What is LD_PRELOAD?

40. IPC + Synchronization Scenarios

Prepare scenarios like:

Two processes access the same shared buffer. How will you synchronize?

Producer produces data faster than consumer. What happens?

Consumer waits until data arrives. What IPC/synchronization mechanism would you use?

Multiple threads update the same variable. What can go wrong?

An interrupt updates a buffer while a process reads it. How will you protect it?

41. Blocking & Non-Blocking I/O

  1. What is blocking I/O?
  2. What is non-blocking I/O?
  3. What is O_NONBLOCK?
  4. What happens when read() has no data?
  5. What is EAGAIN?
  6. What is EWOULDBLOCK?
  7. How does poll() work?
  8. How does select() work?
  9. How does epoll() work?
  10. Blocking vs polling.
  11. Blocking read vs interrupt-driven design.

42. select() / poll() / epoll()

  1. Why do we need I/O multiplexing?
  2. What is select()?
  3. What is poll()?
  4. What is epoll()?
  5. select() vs poll().
  6. poll() vs epoll().
  7. Why is epoll() more scalable?
  8. Level-triggered vs edge-triggered.
  9. What is EPOLLIN?
  10. What is EPOLLOUT?
  11. What is EPOLLERR?
  12. How does a device driver implement poll()?

43. Signals vs Interrupts

Very common conceptual question.

InterruptSignal
Hardware/kernel eventProcess notification
Usually handled by kernel/ISRDelivered to process
CPU/hardware relatedProcess related
Example GPIO interruptSIGTERM

Questions:

  1. Difference between interrupt and signal.
  2. Can a process generate a signal?
  3. Can kernel generate a signal?
  4. What is hardware interrupt?
  5. What is software interrupt?

44. Time Management

  1. What is system clock?
  2. What is clock tick?
  3. What is jiffies?
  4. What is HZ?
  5. What is monotonic clock?
  6. What is realtime clock?
  7. Difference between CLOCK_REALTIME and CLOCK_MONOTONIC.
  8. What is high-resolution timer?
  9. What is timer interrupt?
  10. What is nanosleep()?
  11. What is clock_nanosleep()?
  12. Why is CLOCK_MONOTONIC preferred for measuring elapsed time?

45. SMP / Multicore Linux

  1. What is SMP?
  2. What is multicore?
  3. How does Linux handle multiple CPUs?
  4. What is CPU affinity?
  5. What is per-CPU data?
  6. Why use per-CPU variables?
  7. What is cache coherence?
  8. What is cache line?
  9. What is false sharing?
  10. What is CPU migration?
  11. What is load balancing?
  12. What is NUMA?
  13. What is memory barrier?
  14. Why are locks more important on SMP?

46. Cache & Memory Ordering

For senior Embedded Linux roles:

  1. What is CPU cache?
  2. L1/L2/L3 cache.
  3. What is cache line?
  4. What is cache coherence?
  5. What is memory ordering?
  6. What is memory barrier?
  7. Why is compiler reordering different from CPU reordering?
  8. What is READ_ONCE()?
  9. What is WRITE_ONCE()?
  10. What is smp_mb()?
  11. What is smp_rmb()?
  12. What is smp_wmb()?
  13. How can missing barriers cause race conditions?
  14. What is false sharing?

47. OOM – Out Of Memory

  1. What happens when Linux runs out of memory?
  2. What is OOM?
  3. What is OOM Killer?
  4. Why does Linux kill a process?
  5. How does Linux select a process?
  6. What is oom_score?
  7. What is oom_score_adj?
  8. How do you debug OOM?
  9. What is swap?
  10. Why might an embedded system disable swap?

48. Swap

  1. What is swap?
  2. Why is swap used?
  3. What is swap partition?
  4. What is swap file?
  5. What happens during swapping?
  6. What is swap-in?
  7. What is swap-out?
  8. What is thrashing?
  9. Why is swap usually avoided in some embedded systems?

49. Kernel Panic / Oops

  1. What is kernel panic?
  2. What is kernel Oops?
  3. Oops vs panic.
  4. What is NULL pointer dereference?
  5. What is use-after-free?
  6. What is stack overflow?
  7. What is kernel BUG?
  8. How do you debug a kernel crash?
  9. What is call trace?
  10. What is dmesg?
  11. What is addr2line?
  12. What is vmlinux?
  13. Why is debug information important?
  14. What is CONFIG_DEBUG_INFO?

50. Linux Debugging

  1. How do you debug a Linux application?
  2. How do you debug a kernel?
  3. What is gdb?
  4. What is strace?
  5. What is ltrace?
  6. What is dmesg?
  7. What is ftrace?
  8. What is perf?
  9. What is top?
  10. What is htop?
  11. What is vmstat?
  12. What is iostat?
  13. What is sar?
  14. What is free?
  15. What is /proc/meminfo?
  16. What is /proc/cpuinfo?
  17. What is /proc/interrupts?
  18. What is /proc/<pid>/maps?
  19. What is /proc/<pid>/status?
  20. What is /proc/<pid>/fd/?

51. Performance Debugging

  1. CPU usage is 100%. How do you debug?
  2. System is slow. What do you check?
  3. Memory usage is increasing continuously. What do you check?
  4. Process is blocked. How do you debug?
  5. High interrupt usage — what could cause it?
  6. High context switches — what could cause it?
  7. High CPU but low application workload — why?
  8. High I/O wait — what does it mean?
  9. What is perf?
  10. What is profiling?
  11. What is flame graph?
  12. What is tracing?
  13. Profiling vs tracing.

52. Kernel Tracing

  1. What is ftrace?
  2. What is tracepoint?
  3. What is kprobe?
  4. What is kretprobe?
  5. What is eBPF?
  6. What is perf?
  7. What is function tracing?
  8. What is event tracing?
  9. How can you trace system calls?
  10. How can you trace scheduler events?

53. eBPF

For modern Linux interviews:

  1. What is eBPF?
  2. Why is eBPF useful?
  3. What can eBPF observe?
  4. eBPF vs kernel module.
  5. What is a BPF program?
  6. What is BPF map?
  7. What is verifier?
  8. How can eBPF help debugging?
  9. What is bpftrace?
  10. What is bpftool?

54. Namespaces

  1. What are Linux namespaces?
  2. Why are namespaces used?
  3. What is PID namespace?
  4. Network namespace?
  5. Mount namespace?
  6. IPC namespace?
  7. UTS namespace?
  8. User namespace?
  9. Cgroup namespace?
  10. How do namespaces help containers?

55. Cgroups

  1. What are cgroups?
  2. Why are cgroups used?
  3. CPU cgroup.
  4. Memory cgroup.
  5. I/O cgroup.
  6. What is resource limiting?
  7. What is resource accounting?
  8. Namespace vs cgroup.
  9. How do containers use namespaces and cgroups?

56. Containers / Docker Internals

  1. What is a container?
  2. Container vs virtual machine.
  3. How does Linux support containers?
  4. Namespaces.
  5. Cgroups.
  6. Overlay filesystem.
  7. Capabilities.
  8. What is container isolation?
  9. What is PID namespace?
  10. What happens when a container starts?

57. Linux Security Internals

  1. What is permission?
  2. What is UID?
  3. What is GID?
  4. Real UID vs effective UID.
  5. What is setuid?
  6. What are Linux capabilities?
  7. What is CAP_NET_ADMIN?
  8. What is CAP_SYS_ADMIN?
  9. What is DAC?
  10. What is MAC?
  11. What is SELinux?
  12. What is AppArmor?
  13. What is seccomp?
  14. What is ASLR?
  15. What is NX/DEP?

58. Kernel Synchronization + Interrupt Scenario Questions

Be ready for questions like:

Q1

ISR updates a variable and user thread reads it. What problem can occur?

Q2

Can you use mutex inside ISR?

Q3

Why use spinlock in interrupt context?

Q4

What happens if you call schedule() while holding a spinlock?

Q5

Why use a workqueue after an interrupt?

Q6

What happens if two CPUs access the same variable simultaneously?

Q7

How do memory barriers solve ordering problems?

59. Linux Power Management

Important for embedded systems.

  1. What is suspend?
  2. What is resume?
  3. What is system sleep?
  4. What is runtime PM?
  5. What is runtime suspend?
  6. What is runtime resume?
  7. What is wakeup source?
  8. What is autosuspend?
  9. What is CPU idle?
  10. What is CPU frequency scaling?
  11. What is cpufreq?
  12. What is cpuidle?
  13. How does a driver participate in suspend/resume?

60. Embedded Linux Internals

For your target profile, definitely prepare:

  1. Bootloader → kernel flow.
  2. Kernel → Device Tree.
  3. Device Tree → driver.
  4. Driver → hardware.
  5. Interrupt → driver.
  6. DMA → memory.
  7. User application → driver.
  8. Driver → sysfs.
  9. Driver → /dev.
  10. ALSA architecture.
  11. Linux audio pipeline.
  12. I2C/SPI/GPIO.
  13. Kernel configuration.
  14. Cross compilation.
  15. Root filesystem.
  16. Init/systemd.
  17. Yocto integration.
  18. Kernel module integration.
  19. Debugging boot failures.
  20. Debugging driver probe failures.

61. ALSA / Audio Internals

Since Automotive Linux/audio roles can ask this:

  1. What is ALSA?
  2. ALSA architecture.
  3. What is ALSA kernel layer?
  4. What is ALSA userspace library?
  5. What is PCM?
  6. What is PCM device?
  7. What is PCM playback?
  8. What is PCM capture?
  9. What is PCM buffer?
  10. What is period?
  11. What is period size?
  12. What is buffer size?
  13. What is sample rate?
  14. What is bit depth?
  15. What is channel count?
  16. What is ALSA driver?
  17. What is ASoC?
  18. What is codec driver?
  19. What is CPU DAI?
  20. What is codec DAI?
  21. What is DAPM?
  22. What is machine driver?
  23. What is audio routing?
  24. How does an ALSA application reach hardware?

62. Linux Audio Stack

Know this flow:

Application
     ↓
ALSA / PulseAudio / PipeWire
     ↓
ALSA Kernel
     ↓
ASoC
     ↓
Machine Driver
     ↓
CPU DAI
     ↓
Codec / DSP
     ↓
I2S / TDM
     ↓
Audio Hardware

Possible questions:

Explain Linux audio architecture.

What happens when an application plays audio?

ALSA vs PulseAudio?

What is ASoC?

What is DAI?

What is PCM?

63. Driver + Linux Internals Scenario Questions

These are extremely important for experienced interviews.

Scenario 1

Application calls read(). Explain everything that happens internally.

Expected chain:

Application
 ↓
libc
 ↓
system call
 ↓
Kernel
 ↓
VFS
 ↓
file_operations
 ↓
Driver read()
 ↓
Hardware/buffer
 ↓
copy_to_user()
 ↓
Application

Scenario 2

Hardware generates an interrupt. Explain what happens.

Hardware
 ↓
Interrupt Controller
 ↓
CPU
 ↓
IRQ Entry
 ↓
ISR
 ↓
Schedule Deferred Work
 ↓
Driver
 ↓
Wake Waiting Process
 ↓
Application

Scenario 3

Application writes to /dev/mydevice.

Explain:

open()
 ↓
VFS
 ↓
driver open()

write()
 ↓
VFS
 ↓
driver write()
 ↓
copy_from_user()
 ↓
hardware

Scenario 4

Driver’s probe() isn’t getting called.

Check:

Device exists?
 ↓
Correct bus?
 ↓
Device Tree?
 ↓
compatible?
 ↓
Driver registered?
 ↓
match table?
 ↓
Kernel configuration?
 ↓
probe()

Scenario 5

System randomly crashes after several hours.

Think:

Memory leak
 ↓
Use-after-free
 ↓
Race condition
 ↓
Buffer overflow
 ↓
DMA corruption
 ↓
Stack overflow
 ↓
Deadlock

64. Top 50 Linux Internals Questions

If you have limited interview preparation time, master these first:

  1. Linux architecture.
  2. Kernel space vs user space.
  3. Linux boot process.
  4. start_kernel().
  5. Process vs program.
  6. task_struct.
  7. fork().
  8. exec().
  9. clone().
  10. wait().
  11. Zombie vs orphan.
  12. Threads vs processes.
  13. Context switching.
  14. Scheduler.
  15. CFS.
  16. Real-time scheduling.
  17. System calls.
  18. User → kernel transition.
  19. Virtual memory.
  20. Page tables.
  21. MMU.
  22. TLB.
  23. Page fault.
  24. Copy-on-write.
  25. mmap().
  26. malloc() internals.
  27. Kernel memory allocation.
  28. Buddy allocator.
  29. SLAB/SLUB.
  30. Page cache.
  31. File descriptors.
  32. VFS.
  33. inode.
  34. dentry.
  35. superblock.
  36. open() internals.
  37. IPC.
  38. Signals.
  39. Shared memory.
  40. Mutex vs spinlock.
  41. Deadlock.
  42. Interrupt handling.
  43. Top half/bottom half.
  44. Workqueue.
  45. Device Tree.
  46. Device model.
  47. DMA.
  48. Kernel debugging.
  49. Kernel panic/Oops.
  50. Linux networking internals.

65.What Interviewers Usually Do

For an experienced Embedded Linux candidate, don’t expect only:

“What is a mutex?”

They may ask:

“Suppose an ISR receives data into a ring buffer and a userspace application reads that data. Explain the complete design.”

You should be able to discuss:

Hardware
   ↓
DMA
   ↓
Ring Buffer
   ↓
Interrupt
   ↓
ISR / Threaded IRQ
   ↓
Synchronization
   ↓
Wait Queue
   ↓
Driver read()
   ↓
copy_to_user()
   ↓
Application

Then they may go deeper:

Why DMA?
Why ring buffer?
Why spinlock?
Can ISR sleep?
Why wait queue?
What happens if buffer is full?
What happens if application is slow?
How do you prevent race conditions?
How do you handle cache coherency?
How would you debug data corruption?

That’s the level you should prepare for.

Best preparation sequence

For your Embedded Linux / Automotive Audio background, I’d study Linux internals in this order:

1. Linux Architecture
       ↓
2. Boot Process
       ↓
3. Processes & Threads
       ↓
4. Scheduling
       ↓
5. System Calls
       ↓
6. Virtual Memory
       ↓
7. Memory Management
       ↓
8. VFS & File Systems
       ↓
9. File Descriptors
       ↓
10. IPC
       ↓
11. Signals
       ↓
12. Synchronization
       ↓
13. Interrupts
       ↓
14. Workqueues / Kernel Threads
       ↓
15. Device Model
       ↓
16. Device Tree
       ↓
17. Drivers
       ↓
18. DMA
       ↓
19. Networking
       ↓
20. Power Management
       ↓
21. Kernel Debugging
       ↓
22. Performance / Tracing
       ↓
23. ALSA / ASoC
       ↓
24. Yocto + Kernel
       ↓
25. Real-world Scenarios

Linux Internals Interview Questions – Complete A–Z

1. Linux Architecture

  1. What is Linux?
  2. What is the Linux kernel?
  3. Explain Linux architecture.
  4. What are the major components of Linux?
  5. What is kernel space?
  6. What is user space?
  7. Why are user space and kernel space separated?
  8. What happens when a user application starts?
  9. What happens when a Linux command is executed?
  10. What happens when you execute ./a.out?
  11. What is the role of the shell?
  12. What is the role of the kernel?
  13. What is GNU/Linux?
  14. What is monolithic kernel?
  15. Is Linux a monolithic kernel?
  16. What is a modular monolithic kernel?
  17. Monolithic vs microkernel.
  18. What are the advantages of Linux’s architecture?
  19. What are kernel subsystems?
  20. Explain the Linux kernel at a high level.

Know this architecture

User Applications
       ↓
Libraries
       ↓
System Calls
       ↓
Linux Kernel
 ┌───────────────┐
 │ Process Mgmt  │
 │ Memory Mgmt   │
 │ VFS           │
 │ Networking    │
 │ IPC           │
 │ Drivers       │
 │ Scheduler     │
 └───────────────┘
       ↓
Hardware

2. Boot Process

  1. What happens when a Linux system powers ON?
  2. What is Boot ROM?
  3. What is firmware?
  4. What is a bootloader?
  5. What is U-Boot?
  6. What does U-Boot do?
  7. How does bootloader load the kernel?
  8. How does bootloader load Device Tree?
  9. What is Image?
  10. What is zImage?
  11. What is uImage?
  12. What is FIT image?
  13. What is initramfs?
  14. What is root filesystem?
  15. What is /sbin/init?
  16. What is systemd?
  17. What happens after kernel decompression?
  18. What is start_kernel()?
  19. What happens inside start_kernel()?
  20. How does Linux initialize devices?
  21. What are initcalls?
  22. What is early_initcall()?
  23. What is subsys_initcall()?
  24. What is module_init()?
  25. How does Linux finally start user space?

Embedded Linux boot flow

Power ON
   ↓
Boot ROM
   ↓
Bootloader
   ↓
DRAM Initialization
   ↓
Load Kernel
   ↓
Load Device Tree
   ↓
Kernel
   ↓
start_kernel()
   ↓
Kernel Initialization
   ↓
Root Filesystem
   ↓
init/systemd
   ↓
User Applications

3. Process Internals

This is one of the most important Linux Internal topics.

  1. What is a process?
  2. What is a program?
  3. Program vs process.
  4. What happens when a process is created?
  5. What is PCB?
  6. What is task_struct?
  7. What information is stored in task_struct?
  8. What is PID?
  9. What is PPID?
  10. What is TGID?
  11. What is TID?
  12. What is a process ID namespace?
  13. What is process state?
  14. Explain:
  • Running
  • Runnable
  • Sleeping
  • Stopped
  • Zombie
  1. What is a zombie process?
  2. What is an orphan process?
  3. What happens to an orphan process?
  4. What is init/PID 1?
  5. What is fork()?
  6. What is vfork()?
  7. Difference between fork() and vfork().
  8. What is clone()?
  9. How does Linux create a process?
  10. What happens internally during fork()?
  11. What is exec()?
  12. Difference between fork() and exec().
  13. What is wait()?
  14. What is waitpid()?
  15. Why does a parent call wait()?
  16. What is process termination?
  17. What happens when exit() is called?
  18. What is _exit()?
  19. exit() vs _exit().
  20. What is process hierarchy?
  21. What is a process tree?
  22. What is pstree?
  23. What is process context?

4. Threads

  1. What is a thread?
  2. Process vs thread.
  3. Why use threads?
  4. What resources are shared between threads?
  5. What resources are private to each thread?
  6. Do threads have separate address spaces?
  7. What is a kernel thread?
  8. User thread vs kernel thread.
  9. What is pthread_create()?
  10. What is pthread_join()?
  11. What is thread cancellation?
  12. What is thread-local storage?
  13. What is TLS?
  14. How does Linux implement threads?
  15. What is clone()?
  16. Why are Linux threads often described as tasks?
  17. What is a thread group?
  18. What is TGID?
  19. What is TID?

5. CPU Scheduling

Very frequently asked.

  1. What is process scheduling?
  2. Why do we need a scheduler?
  3. What is the Linux scheduler?
  4. What is context switching?
  5. What happens during a context switch?
  6. Process context vs interrupt context.
  7. What is preemptive scheduling?
  8. What is cooperative scheduling?
  9. What is scheduling latency?
  10. What is time slice?
  11. What is priority?
  12. What is nice value?
  13. What is nice?
  14. What is renice?
  15. What is CFS?
  16. What is the Completely Fair Scheduler?
  17. What is SCHED_NORMAL?
  18. What is SCHED_FIFO?
  19. What is SCHED_RR?
  20. What is SCHED_DEADLINE?
  21. FIFO vs Round Robin.
  22. Real-time scheduling vs normal scheduling.
  23. What is starvation?
  24. What is priority inversion?
  25. How is priority inversion handled?
  26. What is CPU affinity?
  27. What is taskset?
  28. What is CPU isolation?
  29. What is load balancing?
  30. How does Linux select the next task?
  31. What is a runqueue?
  32. What is scheduler tick?
  33. What is tickless Linux?
  34. What is CONFIG_NO_HZ?

6. Context Switching

  1. What is context switching?
  2. Why does context switching happen?
  3. What is saved during context switch?
  4. What is restored?
  5. Process context switch vs thread context switch.
  6. What is register context?
  7. What is stack context?
  8. What is address-space switching?
  9. Why is context switching expensive?
  10. What happens to CPU cache during context switching?
  11. What is TLB?
  12. Does every context switch flush the TLB?
  13. How does ASID/PCID help?
  14. What is voluntary context switching?
  15. What is involuntary context switching?
  16. How can you measure context switches?

7. System Calls

One of the most important Linux internals topics.

  1. What is a system call?
  2. Why are system calls needed?
  3. User function vs system call.
  4. Library call vs system call.
  5. What happens internally when read() is called?
  6. What happens when write() is called?
  7. What happens when open() is called?
  8. What happens when fork() is called?
  9. What happens when execve() is called?
  10. What is system call number?
  11. How does kernel identify a system call?
  12. What is syscall entry?
  13. What is syscall return?
  14. What is trap instruction?
  15. What is privilege-level transition?
  16. What happens to CPU registers during syscall?
  17. How does user space return from kernel space?
  18. What is strace?
  19. How can strace help debug applications?
  20. Can user space directly call kernel functions?
  21. Why can’t user space access kernel memory directly?

8. CPU Privilege Levels

  1. What is privilege?
  2. User mode vs kernel mode.
  3. What is ring 0?
  4. What is ring 3?
  5. Why does Linux use different privilege levels?
  6. What happens during user → kernel transition?
  7. What happens during kernel → user transition?
  8. What is a trap?
  9. What is an exception?
  10. What is an interrupt?
  11. Interrupt vs exception vs trap.

9. Virtual Memory

Extremely important.

  1. What is virtual memory?
  2. Why does Linux use virtual memory?
  3. Virtual address vs physical address.
  4. What is address space?
  5. What is process address space?
  6. What is virtual address space?
  7. What is page?
  8. What is page frame?
  9. What is page table?
  10. What is multi-level page table?
  11. Why are multi-level page tables used?
  12. What is MMU?
  13. What is TLB?
  14. Why do we need TLB?
  15. What is page fault?
  16. Minor vs major page fault.
  17. What happens during a page fault?
  18. What is demand paging?
  19. What is lazy allocation?
  20. What is copy-on-write?
  21. How does fork() use copy-on-write?
  22. What is memory mapping?
  23. What is mmap()?
  24. What is anonymous memory?
  25. What is file-backed memory?
  26. What is shared memory?
  27. What is private memory?
  28. What is memory overcommit?
  29. What is ASLR?
  30. What is memory protection?

10. Process Address Space

Know this diagram:

High Address
+------------------+
| Kernel Space     |
+------------------+
| Stack            |
|        ↓         |
|                  |
|        ↑         |
| Heap             |
+------------------+
| BSS              |
| Data             |
| Text             |
+------------------+
Low Address

Questions:

  1. What is text segment?
  2. What is data segment?
  3. What is BSS?
  4. What is heap?
  5. What is stack?
  6. Heap vs stack.
  7. Where are global variables stored?
  8. Where are static variables stored?
  9. Where are local variables stored?
  10. Where are string literals stored?
  11. What causes stack overflow?
  12. What is stack frame?
  13. What is function call stack?
  14. What is ASLR?
  15. How does shared library memory appear in process address space?

11. Memory Allocation

  1. What is malloc()?
  2. What happens internally during malloc()?
  3. malloc() vs calloc().
  4. malloc() vs realloc().
  5. What is brk()?
  6. What is sbrk()?
  7. What is mmap() used for in memory allocation?
  8. How does glibc allocate memory?
  9. What is memory fragmentation?
  10. Internal vs external fragmentation.
  11. What is memory leak?
  12. How do you find memory leaks?
  13. What is valgrind?
  14. What is AddressSanitizer?
  15. What is double free?
  16. What is use-after-free?
  17. What is dangling pointer?

12. Kernel Memory Management

  1. What is kmalloc()?
  2. What is kzalloc()?
  3. What is vmalloc()?
  4. kmalloc() vs vmalloc().
  5. What is GFP_KERNEL?
  6. What is GFP_ATOMIC?
  7. Why can’t GFP_KERNEL be used in interrupt context?
  8. What is the buddy allocator?
  9. What is SLAB?
  10. What is SLUB?
  11. What is SLOB?
  12. Why does Linux use slab allocation?
  13. What is an object cache?
  14. What is page allocator?
  15. What is high memory?
  16. What is low memory?
  17. What is physically contiguous memory?
  18. What is virtually contiguous memory?

13. Buddy Allocator

  1. What is buddy system?
  2. Why is buddy allocator used?
  3. What is an order?
  4. What is an order-0 page?
  5. How does buddy splitting work?
  6. How does buddy merging work?
  7. What is external fragmentation?
  8. Why can’t large physically contiguous allocations always succeed?
  9. What is compaction?

14. Slab / SLUB Allocator

  1. Why do we need slab allocator?
  2. What is a slab?
  3. What is a cache?
  4. What is an object?
  5. Slab vs page allocator.
  6. SLAB vs SLUB.
  7. Why is SLUB commonly used?
  8. What is kmem_cache_create()?
  9. What is kmem_cache_alloc()?
  10. What is kmem_cache_free()?

15. Page Cache

  1. What is page cache?
  2. Why does Linux use page cache?
  3. How does read() interact with page cache?
  4. How does write() interact with page cache?
  5. What is buffered I/O?
  6. What is direct I/O?
  7. What is O_DIRECT?
  8. What is dirty page?
  9. What is writeback?
  10. What is fsync()?
  11. What is sync()?
  12. What is fdatasync()?
  13. What is writeback cache?
  14. What happens if RAM becomes full of cached data?

16. File Descriptors

  1. What is a file descriptor?
  2. Why does Linux represent devices/files using file descriptors?
  3. What is FD 0?
  4. What is FD 1?
  5. What is FD 2?
  6. What happens when open() is called?
  7. What is a file descriptor table?
  8. What is an open file description?
  9. What is struct file?
  10. What is an inode?
  11. FD vs inode vs file.
  12. What happens when close() is called?
  13. What happens if two processes share an FD?
  14. What happens after fork()?
  15. What is dup()?
  16. What is dup2()?
  17. What is dup3()?
  18. What is FD inheritance?

17. VFS – Virtual File System

Very important for Linux internals.

  1. What is VFS?
  2. Why does Linux need VFS?
  3. What is a filesystem?
  4. What is an inode?
  5. What is a dentry?
  6. What is struct file?
  7. What is super_block?
  8. Explain:
Process
   ↓
System Call
   ↓
VFS
   ↓
Filesystem
   ↓
Block Layer
   ↓
Device Driver
   ↓
Hardware
  1. What is inode cache?
  2. What is dentry cache?
  3. What is pathname lookup?
  4. What happens during open("/home/test.txt")?
  5. What is namei?
  6. What is mount?
  7. What is superblock?
  8. Hard link vs symbolic link.
  9. What happens when a file is deleted?
  10. Can a deleted file still be open?

18. Filesystem Internals

  1. What is ext4?
  2. What is inode?
  3. What is directory entry?
  4. What is block?
  5. What is filesystem block size?
  6. What is journaling?
  7. Why is journaling needed?
  8. What happens after sudden power failure?
  9. What is fsck?
  10. What is mount?
  11. What is unmount?
  12. What is /etc/fstab?
  13. What is root filesystem?
  14. What is tmpfs?
  15. What is procfs?
  16. What is sysfs?
  17. What is devtmpfs?
  18. What is debugfs?
  19. What is overlayfs?
  20. What is NFS?

19. IPC – Inter-Process Communication

  1. What is IPC?
  2. Why is IPC needed?
  3. What are the IPC mechanisms?
  4. Pipe
  5. FIFO
  6. Message queue
  7. Shared memory
  8. Semaphore
  9. Signal
  10. Socket
  11. Pipe vs FIFO.
  12. Message queue vs shared memory.
  13. Shared memory vs pipe.
  14. Which IPC mechanism is fastest?
  15. Why is shared memory fast?
  16. How do you synchronize shared memory?

20. Pipes

  1. What is a pipe?
  2. How does pipe() work?
  3. Anonymous pipe vs named pipe.
  4. What is FIFO?
  5. What happens if pipe buffer is full?
  6. What happens if no reader exists?
  7. Is pipe unidirectional?
  8. How is pipe implemented inside kernel?

21. Signals

  1. What is a signal?
  2. Why are signals used?
  3. What is SIGINT?
  4. SIGTERM vs SIGKILL.
  5. SIGSTOP vs SIGCONT.
  6. What is SIGSEGV?
  7. What is SIGCHLD?
  8. What happens when a signal is generated?
  9. What is signal handler?
  10. Can you catch SIGKILL?
  11. Can you catch SIGSTOP?
  12. Signal vs interrupt.
  13. What is signal masking?
  14. What is pending signal?
  15. What is blocked signal?
  16. What is sigaction()?
  17. Why is sigaction() preferred over old signal()?

22. Shared Memory

  1. What is shared memory?
  2. Why is shared memory fast?
  3. What is mmap()?
  4. What is POSIX shared memory?
  5. What is System V shared memory?
  6. Shared memory synchronization.
  7. Can multiple processes write simultaneously?
  8. What happens without synchronization?
  9. Shared memory vs message queue.

23. Synchronization

  1. What is synchronization?
  2. What is race condition?
  3. What is critical section?
  4. What is mutex?
  5. What is semaphore?
  6. What is spinlock?
  7. Mutex vs semaphore.
  8. Mutex vs spinlock.
  9. What is read-write lock?
  10. What is RCU?
  11. What is atomic operation?
  12. What is atomic_t?
  13. What is memory barrier?
  14. What is deadlock?
  15. What is livelock?
  16. What is starvation?
  17. What is priority inversion?
  18. How do you avoid deadlocks?
  19. What is lock ordering?
  20. Can a mutex be used in interrupt context?
  21. Can a spinlock be used in process context?
  22. Can you sleep while holding a spinlock?

24. RCU

For advanced interviews:

  1. What is RCU?
  2. Why was RCU introduced?
  3. Read-copy-update concept.
  4. Why is RCU useful for read-heavy workloads?
  5. What is an RCU read-side critical section?
  6. What is rcu_read_lock()?
  7. What is rcu_read_unlock()?
  8. What is synchronize_rcu()?
  9. RCU vs mutex.
  10. RCU vs spinlock.

25. Deadlock

  1. What is deadlock?
  2. Four conditions for deadlock.
  3. Mutual exclusion.
  4. Hold and wait.
  5. No preemption.
  6. Circular wait.
  7. How do you prevent deadlock?
  8. How do you debug deadlock?
  9. What is lockdep?
  10. Give an example of kernel deadlock.

26. Interrupts

  1. What is an interrupt?
  2. Hardware vs software interrupt.
  3. What is IRQ?
  4. What is ISR?
  5. Interrupt context.
  6. What happens when an interrupt occurs?
  7. What is interrupt controller?
  8. What is IRQ number?
  9. Shared IRQ.
  10. Edge-triggered vs level-triggered.
  11. What is interrupt affinity?
  12. What is interrupt storm?
  13. What is interrupt latency?
  14. What is top half?
  15. What is bottom half?
  16. What is threaded IRQ?
  17. What is tasklet?
  18. What is workqueue?
  19. Why can’t ISR sleep?
  20. What is request_irq()?
  21. What is free_irq()?

27. Kernel Timers

  1. What is kernel timer?
  2. Why use kernel timers?
  3. What is timer callback?
  4. Can timer callback sleep?
  5. Timer vs workqueue.
  6. Timer vs delayed work.
  7. What happens if timer callback takes too long?
  8. How do you create a kernel timer?

28. Workqueues

  1. What is workqueue?
  2. Why defer work?
  3. What is work_struct?
  4. What is schedule_work()?
  5. Can workqueue sleep?
  6. Workqueue vs tasklet.
  7. Workqueue vs kernel thread.
  8. What is ordered workqueue?
  9. What is dedicated workqueue?

29. Kernel Threads

  1. What is a kernel thread?
  2. How is it different from a user thread?
  3. What is kthread_run()?
  4. What is kthread_stop()?
  5. Can kernel threads sleep?
  6. How does a kernel thread terminate?
  7. Why would a driver use a kernel thread?

30. Networking Internals

For Embedded Linux, prepare the basics.

  1. Explain Linux networking architecture.
  2. What happens when you run:
ping 8.8.8.8
  1. What happens when an Ethernet frame arrives?
  2. What is NIC?
  3. What is network driver?
  4. What is net_device?
  5. What is socket?
  6. What is socket buffer (sk_buff)?
  7. What is TCP/IP stack?
  8. What is ARP?
  9. What is routing?
  10. What is IP address?
  11. MAC address vs IP address.
  12. TCP vs UDP.
  13. What is port?
  14. What is network namespace?
  15. What is NAPI?
  16. Why is NAPI required?
  17. Interrupt-driven RX vs polling.
  18. What is checksum offload?
  19. What is TSO?
  20. What is GRO?
  21. What is RSS?
  22. What is DMA in network drivers?

31. Socket Internals

  1. What is a socket?
  2. What happens during socket()?
  3. What happens during bind()?
  4. What happens during listen()?
  5. What happens during accept()?
  6. What happens during connect()?
  7. What happens during send()?
  8. What happens during recv()?
  9. What is socket buffer?
  10. Blocking vs non-blocking socket.
  11. What is select()?
  12. What is poll()?
  13. What is epoll()?
  14. Why is epoll() efficient?
  15. Level-triggered vs edge-triggered.

32. DMA

  1. What is DMA?
  2. Why use DMA?
  3. CPU copy vs DMA.
  4. What is DMA buffer?
  5. What is DMA mapping?
  6. What is DMA coherent memory?
  7. What is cache coherency?
  8. dma_map_single().
  9. dma_unmap_single().
  10. dma_alloc_coherent().
  11. Streaming DMA vs coherent DMA.
  12. What is DMA mask?
  13. What is IOMMU?
  14. CPU cache vs DMA.
  15. What happens if cache isn’t synchronized?

33. Device Model

  1. What is Linux device model?
  2. What is a device?
  3. What is a driver?
  4. What is a bus?
  5. What is a class?
  6. What is kobject?
  7. What is sysfs?
  8. What is device binding?
  9. What is driver binding?
  10. Explain:
Bus
 ├── Device
 └── Driver
  1. What is struct device?
  2. What is reference counting?
  3. What is kref?
  4. What is hotplug?
  5. What is uevent?
  6. What is udev?

34. Device Tree

  1. What is Device Tree?
  2. Why do we need Device Tree?
  3. DTS vs DTSI.
  4. DTS vs DTB.
  5. What is DTBO?
  6. What is a node?
  7. What is a property?
  8. What is compatible?
  9. What is reg?
  10. What is interrupts?
  11. What is clocks?
  12. What is gpios?
  13. What is status?
  14. What is phandle?
  15. What is Device Tree overlay?
  16. How does Device Tree bind to a driver?
  17. What is of_match_table?
  18. What is of_device_id?
  19. What is probe()?
  20. How does the kernel discover hardware from Device Tree?

35. Kernel Modules

  1. What is kernel module?
  2. Why use modules?
  3. Built-in vs module.
  4. What is .ko?
  5. What is insmod?
  6. What is modprobe?
  7. What is rmmod?
  8. What is lsmod?
  9. What is modinfo?
  10. What is module dependency?
  11. What is symbol export?
  12. What is EXPORT_SYMBOL()?
  13. What is EXPORT_SYMBOL_GPL()?
  14. What happens during module loading?
  15. What happens during unloading?
  16. Why can a module fail to unload?
  17. What is module reference count?

36. Sysfs / Procfs / Debugfs

  1. What is sysfs?
  2. What is procfs?
  3. What is debugfs?
  4. Difference between them.
  5. What information is exposed through /proc?
  6. What information is exposed through /sys?
  7. Why shouldn’t debugfs be used as a stable application interface?
  8. How does a driver create a sysfs attribute?
  9. What are show() and store()?
  10. What is DEVICE_ATTR()?

37. Kernel Synchronization Context

Interviewers love scenario questions:

Q: Can you sleep here?

Prepare answers for:

ContextCan Sleep?
User processYes
Kernel process contextYes
Kernel threadYes
Interrupt handlerNo
Timer callbackNo
Spinlock-held contextNo
Atomic contextNo

Then expect:

Why?

What API can you use instead?

Which GFP flag should you use?

38. ELF & Program Loading

  1. What is ELF?
  2. What is an ELF executable?
  3. What is an ELF header?
  4. What is a program header?
  5. What is a section header?
  6. What is .text?
  7. What is .data?
  8. What is .bss?
  9. What is symbol table?
  10. What is relocation?
  11. What is dynamic linking?
  12. What is static linking?
  13. Static vs dynamic linking.
  14. What is a shared library?
  15. What is .so?
  16. What is the dynamic linker?
  17. What is ld.so?
  18. What happens when you execute an ELF binary?
  19. What is ASLR?
  20. What is PIE?

39. Dynamic Linking

  1. Static vs dynamic library.
  2. What is .so?
  3. What is LD_LIBRARY_PATH?
  4. What is ldconfig?
  5. What is dynamic linker?
  6. What is symbol resolution?
  7. What is PLT?
  8. What is GOT?
  9. What is lazy binding?
  10. What is LD_PRELOAD?

40. IPC + Synchronization Scenarios

Prepare scenarios like:

Two processes access the same shared buffer. How will you synchronize?

Producer produces data faster than consumer. What happens?

Consumer waits until data arrives. What IPC/synchronization mechanism would you use?

Multiple threads update the same variable. What can go wrong?

An interrupt updates a buffer while a process reads it. How will you protect it?

41. Blocking & Non-Blocking I/O

  1. What is blocking I/O?
  2. What is non-blocking I/O?
  3. What is O_NONBLOCK?
  4. What happens when read() has no data?
  5. What is EAGAIN?
  6. What is EWOULDBLOCK?
  7. How does poll() work?
  8. How does select() work?
  9. How does epoll() work?
  10. Blocking vs polling.
  11. Blocking read vs interrupt-driven design.

42. select() / poll() / epoll()

  1. Why do we need I/O multiplexing?
  2. What is select()?
  3. What is poll()?
  4. What is epoll()?
  5. select() vs poll().
  6. poll() vs epoll().
  7. Why is epoll() more scalable?
  8. Level-triggered vs edge-triggered.
  9. What is EPOLLIN?
  10. What is EPOLLOUT?
  11. What is EPOLLERR?
  12. How does a device driver implement poll()?

43. Signals vs Interrupts

Very common conceptual question.

InterruptSignal
Hardware/kernel eventProcess notification
Usually handled by kernel/ISRDelivered to process
CPU/hardware relatedProcess related
Example GPIO interruptSIGTERM

Questions:

  1. Difference between interrupt and signal.
  2. Can a process generate a signal?
  3. Can kernel generate a signal?
  4. What is hardware interrupt?
  5. What is software interrupt?

44. Time Management

  1. What is system clock?
  2. What is clock tick?
  3. What is jiffies?
  4. What is HZ?
  5. What is monotonic clock?
  6. What is realtime clock?
  7. Difference between CLOCK_REALTIME and CLOCK_MONOTONIC.
  8. What is high-resolution timer?
  9. What is timer interrupt?
  10. What is nanosleep()?
  11. What is clock_nanosleep()?
  12. Why is CLOCK_MONOTONIC preferred for measuring elapsed time?

45. SMP / Multicore Linux

  1. What is SMP?
  2. What is multicore?
  3. How does Linux handle multiple CPUs?
  4. What is CPU affinity?
  5. What is per-CPU data?
  6. Why use per-CPU variables?
  7. What is cache coherence?
  8. What is cache line?
  9. What is false sharing?
  10. What is CPU migration?
  11. What is load balancing?
  12. What is NUMA?
  13. What is memory barrier?
  14. Why are locks more important on SMP?

46. Cache & Memory Ordering

For senior Embedded Linux roles:

  1. What is CPU cache?
  2. L1/L2/L3 cache.
  3. What is cache line?
  4. What is cache coherence?
  5. What is memory ordering?
  6. What is memory barrier?
  7. Why is compiler reordering different from CPU reordering?
  8. What is READ_ONCE()?
  9. What is WRITE_ONCE()?
  10. What is smp_mb()?
  11. What is smp_rmb()?
  12. What is smp_wmb()?
  13. How can missing barriers cause race conditions?
  14. What is false sharing?

47. OOM – Out Of Memory

  1. What happens when Linux runs out of memory?
  2. What is OOM?
  3. What is OOM Killer?
  4. Why does Linux kill a process?
  5. How does Linux select a process?
  6. What is oom_score?
  7. What is oom_score_adj?
  8. How do you debug OOM?
  9. What is swap?
  10. Why might an embedded system disable swap?

48. Swap

  1. What is swap?
  2. Why is swap used?
  3. What is swap partition?
  4. What is swap file?
  5. What happens during swapping?
  6. What is swap-in?
  7. What is swap-out?
  8. What is thrashing?
  9. Why is swap usually avoided in some embedded systems?

49. Kernel Panic / Oops

  1. What is kernel panic?
  2. What is kernel Oops?
  3. Oops vs panic.
  4. What is NULL pointer dereference?
  5. What is use-after-free?
  6. What is stack overflow?
  7. What is kernel BUG?
  8. How do you debug a kernel crash?
  9. What is call trace?
  10. What is dmesg?
  11. What is addr2line?
  12. What is vmlinux?
  13. Why is debug information important?
  14. What is CONFIG_DEBUG_INFO?

50. Linux Debugging

  1. How do you debug a Linux application?
  2. How do you debug a kernel?
  3. What is gdb?
  4. What is strace?
  5. What is ltrace?
  6. What is dmesg?
  7. What is ftrace?
  8. What is perf?
  9. What is top?
  10. What is htop?
  11. What is vmstat?
  12. What is iostat?
  13. What is sar?
  14. What is free?
  15. What is /proc/meminfo?
  16. What is /proc/cpuinfo?
  17. What is /proc/interrupts?
  18. What is /proc/<pid>/maps?
  19. What is /proc/<pid>/status?
  20. What is /proc/<pid>/fd/?

51. Performance Debugging

  1. CPU usage is 100%. How do you debug?
  2. System is slow. What do you check?
  3. Memory usage is increasing continuously. What do you check?
  4. Process is blocked. How do you debug?
  5. High interrupt usage — what could cause it?
  6. High context switches — what could cause it?
  7. High CPU but low application workload — why?
  8. High I/O wait — what does it mean?
  9. What is perf?
  10. What is profiling?
  11. What is flame graph?
  12. What is tracing?
  13. Profiling vs tracing.

52. Kernel Tracing

  1. What is ftrace?
  2. What is tracepoint?
  3. What is kprobe?
  4. What is kretprobe?
  5. What is eBPF?
  6. What is perf?
  7. What is function tracing?
  8. What is event tracing?
  9. How can you trace system calls?
  10. How can you trace scheduler events?

53. eBPF

For modern Linux interviews:

  1. What is eBPF?
  2. Why is eBPF useful?
  3. What can eBPF observe?
  4. eBPF vs kernel module.
  5. What is a BPF program?
  6. What is BPF map?
  7. What is verifier?
  8. How can eBPF help debugging?
  9. What is bpftrace?
  10. What is bpftool?

54. Namespaces

  1. What are Linux namespaces?
  2. Why are namespaces used?
  3. What is PID namespace?
  4. Network namespace?
  5. Mount namespace?
  6. IPC namespace?
  7. UTS namespace?
  8. User namespace?
  9. Cgroup namespace?
  10. How do namespaces help containers?

55. Cgroups

  1. What are cgroups?
  2. Why are cgroups used?
  3. CPU cgroup.
  4. Memory cgroup.
  5. I/O cgroup.
  6. What is resource limiting?
  7. What is resource accounting?
  8. Namespace vs cgroup.
  9. How do containers use namespaces and cgroups?

56. Containers / Docker Internals

  1. What is a container?
  2. Container vs virtual machine.
  3. How does Linux support containers?
  4. Namespaces.
  5. Cgroups.
  6. Overlay filesystem.
  7. Capabilities.
  8. What is container isolation?
  9. What is PID namespace?
  10. What happens when a container starts?

57. Linux Security Internals

  1. What is permission?
  2. What is UID?
  3. What is GID?
  4. Real UID vs effective UID.
  5. What is setuid?
  6. What are Linux capabilities?
  7. What is CAP_NET_ADMIN?
  8. What is CAP_SYS_ADMIN?
  9. What is DAC?
  10. What is MAC?
  11. What is SELinux?
  12. What is AppArmor?
  13. What is seccomp?
  14. What is ASLR?
  15. What is NX/DEP?

58. Kernel Synchronization + Interrupt Scenario Questions

Be ready for questions like:

Q1

ISR updates a variable and user thread reads it. What problem can occur?

Q2

Can you use mutex inside ISR?

Q3

Why use spinlock in interrupt context?

Q4

What happens if you call schedule() while holding a spinlock?

Q5

Why use a workqueue after an interrupt?

Q6

What happens if two CPUs access the same variable simultaneously?

Q7

How do memory barriers solve ordering problems?

59. Linux Power Management

Important for embedded systems.

  1. What is suspend?
  2. What is resume?
  3. What is system sleep?
  4. What is runtime PM?
  5. What is runtime suspend?
  6. What is runtime resume?
  7. What is wakeup source?
  8. What is autosuspend?
  9. What is CPU idle?
  10. What is CPU frequency scaling?
  11. What is cpufreq?
  12. What is cpuidle?
  13. How does a driver participate in suspend/resume?

60. Embedded Linux Internals

For your target profile, definitely prepare:

  1. Bootloader → kernel flow.
  2. Kernel → Device Tree.
  3. Device Tree → driver.
  4. Driver → hardware.
  5. Interrupt → driver.
  6. DMA → memory.
  7. User application → driver.
  8. Driver → sysfs.
  9. Driver → /dev.
  10. ALSA architecture.
  11. Linux audio pipeline.
  12. I2C/SPI/GPIO.
  13. Kernel configuration.
  14. Cross compilation.
  15. Root filesystem.
  16. Init/systemd.
  17. Yocto integration.
  18. Kernel module integration.
  19. Debugging boot failures.
  20. Debugging driver probe failures.

61. ALSA / Audio Internals

Since Automotive Linux/audio roles can ask this:

  1. What is ALSA?
  2. ALSA architecture.
  3. What is ALSA kernel layer?
  4. What is ALSA userspace library?
  5. What is PCM?
  6. What is PCM device?
  7. What is PCM playback?
  8. What is PCM capture?
  9. What is PCM buffer?
  10. What is period?
  11. What is period size?
  12. What is buffer size?
  13. What is sample rate?
  14. What is bit depth?
  15. What is channel count?
  16. What is ALSA driver?
  17. What is ASoC?
  18. What is codec driver?
  19. What is CPU DAI?
  20. What is codec DAI?
  21. What is DAPM?
  22. What is machine driver?
  23. What is audio routing?
  24. How does an ALSA application reach hardware?

62. Linux Audio Stack

Know this flow:

Application
     ↓
ALSA / PulseAudio / PipeWire
     ↓
ALSA Kernel
     ↓
ASoC
     ↓
Machine Driver
     ↓
CPU DAI
     ↓
Codec / DSP
     ↓
I2S / TDM
     ↓
Audio Hardware

Possible questions:

Explain Linux audio architecture.

What happens when an application plays audio?

ALSA vs PulseAudio?

What is ASoC?

What is DAI?

What is PCM?

63. Driver + Linux Internals Scenario Questions

These are extremely important for experienced interviews.

Scenario 1

Application calls read(). Explain everything that happens internally.

Expected chain:

Application
 ↓
libc
 ↓
system call
 ↓
Kernel
 ↓
VFS
 ↓
file_operations
 ↓
Driver read()
 ↓
Hardware/buffer
 ↓
copy_to_user()
 ↓
Application

Scenario 2

Hardware generates an interrupt. Explain what happens.

Hardware
 ↓
Interrupt Controller
 ↓
CPU
 ↓
IRQ Entry
 ↓
ISR
 ↓
Schedule Deferred Work
 ↓
Driver
 ↓
Wake Waiting Process
 ↓
Application

Scenario 3

Application writes to /dev/mydevice.

Explain:

open()
 ↓
VFS
 ↓
driver open()

write()
 ↓
VFS
 ↓
driver write()
 ↓
copy_from_user()
 ↓
hardware

Scenario 4

Driver’s probe() isn’t getting called.

Check:

Device exists?
 ↓
Correct bus?
 ↓
Device Tree?
 ↓
compatible?
 ↓
Driver registered?
 ↓
match table?
 ↓
Kernel configuration?
 ↓
probe()

Scenario 5

System randomly crashes after several hours.

Think:

Memory leak
 ↓
Use-after-free
 ↓
Race condition
 ↓
Buffer overflow
 ↓
DMA corruption
 ↓
Stack overflow
 ↓
Deadlock

64. Top 50 Linux Internals Questions

If you have limited interview preparation time, master these first:

  1. Linux architecture.
  2. Kernel space vs user space.
  3. Linux boot process.
  4. start_kernel().
  5. Process vs program.
  6. task_struct.
  7. fork().
  8. exec().
  9. clone().
  10. wait().
  11. Zombie vs orphan.
  12. Threads vs processes.
  13. Context switching.
  14. Scheduler.
  15. CFS.
  16. Real-time scheduling.
  17. System calls.
  18. User → kernel transition.
  19. Virtual memory.
  20. Page tables.
  21. MMU.
  22. TLB.
  23. Page fault.
  24. Copy-on-write.
  25. mmap().
  26. malloc() internals.
  27. Kernel memory allocation.
  28. Buddy allocator.
  29. SLAB/SLUB.
  30. Page cache.
  31. File descriptors.
  32. VFS.
  33. inode.
  34. dentry.
  35. superblock.
  36. open() internals.
  37. IPC.
  38. Signals.
  39. Shared memory.
  40. Mutex vs spinlock.
  41. Deadlock.
  42. Interrupt handling.
  43. Top half/bottom half.
  44. Workqueue.
  45. Device Tree.
  46. Device model.
  47. DMA.
  48. Kernel debugging.
  49. Kernel panic/Oops.
  50. Linux networking internals.

65.What Interviewers Usually Do

For an experienced Embedded Linux candidate, don’t expect only:

“What is a mutex?”

They may ask:

“Suppose an ISR receives data into a ring buffer and a userspace application reads that data. Explain the complete design.”

You should be able to discuss:

Hardware
   ↓
DMA
   ↓
Ring Buffer
   ↓
Interrupt
   ↓
ISR / Threaded IRQ
   ↓
Synchronization
   ↓
Wait Queue
   ↓
Driver read()
   ↓
copy_to_user()
   ↓
Application

Then they may go deeper:

Why DMA?
Why ring buffer?
Why spinlock?
Can ISR sleep?
Why wait queue?
What happens if buffer is full?
What happens if application is slow?
How do you prevent race conditions?
How do you handle cache coherency?
How would you debug data corruption?

That’s the level you should prepare for.

Best preparation sequence

For your Embedded Linux / Automotive Audio background, I’d study Linux internals in this order:

1. Linux Architecture
       ↓
2. Boot Process
       ↓
3. Processes & Threads
       ↓
4. Scheduling
       ↓
5. System Calls
       ↓
6. Virtual Memory
       ↓
7. Memory Management
       ↓
8. VFS & File Systems
       ↓
9. File Descriptors
       ↓
10. IPC
       ↓
11. Signals
       ↓
12. Synchronization
       ↓
13. Interrupts
       ↓
14. Workqueues / Kernel Threads
       ↓
15. Device Model
       ↓
16. Device Tree
       ↓
17. Drivers
       ↓
18. DMA
       ↓
19. Networking
       ↓
20. Power Management
       ↓
21. Kernel Debugging
       ↓
22. Performance / Tracing
       ↓
23. ALSA / ASoC
       ↓
24. Yocto + Kernel
       ↓
25. Real-world Scenarios

Linux Kernel Programming – Complete Interview Question Bank

1. Linux Kernel Programming Basics

  1. What is Linux kernel programming?
  2. How is kernel programming different from normal C programming?
  3. What is kernel space?
  4. What is user space?
  5. Why can’t kernel code use normal user-space APIs?
  6. Can kernel code use printf()?
  7. What is printk()?
  8. What are pr_info(), pr_err(), pr_warn(), and pr_debug()?
  9. What is a kernel module?
  10. What is an LKM?
  11. Why are kernel modules used?
  12. Built-in code vs loadable module.
  13. What is a .ko file?
  14. What happens when a .ko file is loaded?
  15. What happens when a module is unloaded?
  16. What is insmod?
  17. What is rmmod?
  18. What is modprobe?
  19. Difference between insmod and modprobe.
  20. What is lsmod?
  21. What is modinfo?
  22. What is module dependency?
  23. What is module reference counting?
  24. Why can a module fail to unload?

2. Kernel Module Programming

Questions

  1. What is module_init()?
  2. What is module_exit()?
  3. What happens inside module initialization?
  4. What happens inside module cleanup?
  5. Can a kernel module have multiple module_init() functions?
  6. What is MODULE_LICENSE()?
  7. Why is module licensing important?
  8. What is MODULE_AUTHOR()?
  9. What is MODULE_DESCRIPTION()?
  10. What is MODULE_VERSION()?
  11. What is MODULE_DEVICE_TABLE()?
  12. What is EXPORT_SYMBOL()?
  13. What is EXPORT_SYMBOL_GPL()?
  14. Difference between them.
  15. What is a kernel symbol?
  16. What is symbol resolution?
  17. What causes an “Unknown symbol” error?
  18. What happens if a module depends on another module?
  19. How does the kernel resolve module dependencies?
  20. What is modprobe doing internally?

Basic structure

#include <linux/module.h>
#include <linux/kernel.h>

static int __init my_init(void)
{
    pr_info("Driver loaded\n");
    return 0;
}

static void __exit my_exit(void)
{
    pr_info("Driver unloaded\n");
}

module_init(my_init);
module_exit(my_exit);

MODULE_LICENSE("GPL");

Interviewers may ask you to write this from memory.

3. Kernel Build System

  1. How do you compile a kernel module?
  2. What is a kernel Makefile?
  3. What is Kbuild?
  4. What is Kconfig?
  5. What is .config?
  6. What is CONFIG_xxx?
  7. Difference between:
CONFIG_xxx=y
CONFIG_xxx=m
CONFIG_xxx=n
  1. What does obj-m mean?
  2. What does obj-y mean?
  3. How do you build an external module?
  4. What is KDIR?
  5. What is ARCH?
  6. What is CROSS_COMPILE?
  7. Why must a module be built against the correct kernel?
  8. What is vermagic?
  9. What happens if kernel and module versions don’t match?
  10. What are kernel headers?
  11. Difference between userspace headers and kernel headers.
  12. How do you cross-compile a kernel module?
  13. How do you add a driver to the Linux kernel source tree?

4. Kernel Data Types

  1. What is u8?
  2. What is u16?
  3. What is u32?
  4. What is u64?
  5. What is s32?
  6. What is size_t?
  7. What is ssize_t?
  8. What is phys_addr_t?
  9. What is dma_addr_t?
  10. What is dev_t?
  11. What is pid_t?
  12. What is atomic_t?
  13. Why does kernel code use its own data types?
  14. Why should you avoid assuming int is always a particular size?

5. Kernel Memory Programming

This is one of the highest-priority areas.

Allocation

  1. What is kmalloc()?
  2. What is kzalloc()?
  3. What is kcalloc()?
  4. What is krealloc()?
  5. What is kfree()?
  6. What is vmalloc()?
  7. What is vzalloc()?
  8. What is vfree()?
  9. kmalloc() vs vmalloc().
  10. What does “physically contiguous” mean?
  11. What does “virtually contiguous” mean?
  12. Why is kmalloc() physically contiguous?
  13. Why is vmalloc() only virtually contiguous?
  14. Which is faster: kmalloc() or vmalloc()?
  15. When would you use each?

GFP flags

  1. What is GFP?
  2. What is GFP_KERNEL?
  3. What is GFP_ATOMIC?
  4. What is GFP_NOWAIT?
  5. Why can’t GFP_KERNEL be used in interrupt context?
  6. Why is GFP_ATOMIC needed?
  7. What does it mean for an allocation to sleep?

Advanced

  1. What is the buddy allocator?
  2. What is SLAB?
  3. What is SLUB?
  4. Why does the kernel use slab allocation?
  5. What is a slab cache?
  6. What is kmem_cache_create()?
  7. What is kmem_cache_alloc()?
  8. What is kmem_cache_free()?
  9. What is memory fragmentation?
  10. What is a memory leak?
  11. What is use-after-free?
  12. What is double-free?
  13. How do you detect kernel memory leaks?

6. copy_to_user() / copy_from_user()

  1. Why can’t you directly access user memory from kernel code?
  2. What is copy_to_user()?
  3. What is copy_from_user()?
  4. Difference between memcpy() and copy_to_user().
  5. What does copy_to_user() return?
  6. What does copy_from_user() return?
  7. What happens if the user passes an invalid pointer?
  8. What is access_ok()?
  9. Why is validating user input important?
  10. Can copy_to_user() sleep?
  11. Can you call it from interrupt context?

7. Kernel Pointers

  1. What is a kernel virtual address?
  2. What is a physical address?
  3. What is a user virtual address?
  4. What is virt_to_phys()?
  5. What is phys_to_virt()?
  6. What is ioremap()?
  7. Why is ioremap() required?
  8. What is __iomem?
  9. What is IS_ERR()?
  10. What is PTR_ERR()?
  11. What is ERR_PTR()?
  12. NULL pointer vs ERR_PTR.
  13. Why are kernel error pointers used?

8. Character Driver Programming

  1. What is a character driver?
  2. How do you create a character driver?
  3. What is struct cdev?
  4. What is struct file_operations?
  5. What is struct inode?
  6. What is struct file?
  7. Difference between inode and file.
  8. What is dev_t?
  9. What is major number?
  10. What is minor number?
  11. What is alloc_chrdev_region()?
  12. What is register_chrdev_region()?
  13. Difference between them.
  14. What is cdev_init()?
  15. What is cdev_add()?
  16. What is cdev_del()?
  17. What is class_create()?
  18. What is device_create()?
  19. Who creates /dev/mydevice?
  20. What is udev?
  21. What is devtmpfs?
  22. How does /dev/mydevice connect to your driver?
  23. How does open() reach the driver?
  24. How does read() reach the driver?
  25. How does write() reach the driver?
  26. How does close() reach the driver?

Flow

Application
     ↓
open("/dev/mydevice")
     ↓
VFS
     ↓
file_operations
     ↓
driver->open()

9. file_operations

Prepare every callback:

  1. What is .open?
  2. What is .release?
  3. What is .read?
  4. What is .write?
  5. What is .unlocked_ioctl?
  6. What is .compat_ioctl?
  7. What is .mmap?
  8. What is .poll?
  9. What is .llseek?
  10. What is .fasync?
  11. What is .fsync?
  12. What is .read_iter?
  13. What is .write_iter?
  14. What is private_data?
  15. How do you store per-device data in private_data?

10. ioctl

  1. What is ioctl?
  2. Why use ioctl?
  3. When should you use ioctl instead of read/write?
  4. What is _IO()?
  5. What is _IOR()?
  6. What is _IOW()?
  7. What is _IOWR()?
  8. What is an ioctl command number?
  9. How is data passed between userspace and kernel?
  10. Why should ioctl arguments be validated?
  11. How do you pass a structure through ioctl?
  12. What security problems can ioctl create?
  13. What is 32-bit/64-bit compatibility in ioctl?
  14. What is .compat_ioctl?

11. Blocking & Non-Blocking I/O

  1. What is blocking I/O?
  2. What is non-blocking I/O?
  3. What is O_NONBLOCK?
  4. What happens when read() has no data?
  5. What is EAGAIN?
  6. What is EWOULDBLOCK?
  7. How do you implement blocking read in a driver?
  8. How do you implement non-blocking read?
  9. What is a wait queue?
  10. Why do drivers put processes to sleep?
  11. How does the driver wake the process?

12. Wait Queues

  1. What is a wait queue?
  2. Why are wait queues required?
  3. What is wait_event()?
  4. What is wait_event_interruptible()?
  5. What is wait_event_timeout()?
  6. What is wake_up()?
  7. What is wake_up_interruptible()?
  8. What is the wait condition?
  9. Why must the condition be checked again after waking?
  10. What is a spurious wakeup?
  11. How would you implement a blocking read() using a wait queue?

Typical design

Application
    ↓
read()
    ↓
Data unavailable
    ↓
wait_event()
    ↓
Process sleeps
    ↓
Hardware interrupt
    ↓
Data arrives
    ↓
wake_up()
    ↓
read() continues

13. Poll / Select / Epoll

  1. Why does a driver implement poll()?
  2. What is poll_wait()?
  3. How does select() work?
  4. How does poll() work?
  5. How does epoll() work?
  6. select() vs poll().
  7. poll() vs epoll().
  8. Level-triggered vs edge-triggered.
  9. What is POLLIN?
  10. What is POLLOUT?
  11. What is POLLERR?
  12. How does a driver notify userspace that data is available?

14. Interrupt Programming

  1. What is an interrupt?
  2. What is IRQ?
  3. What is ISR?
  4. What is interrupt context?
  5. What is request_irq()?
  6. What is free_irq()?
  7. What is irqreturn_t?
  8. What is IRQ_HANDLED?
  9. What is IRQ_NONE?
  10. What is shared IRQ?
  11. What is IRQF_SHARED?
  12. Edge vs level triggered interrupt.
  13. What is interrupt affinity?
  14. What is interrupt latency?
  15. Why can’t an ISR sleep?
  16. Can you call kmalloc(GFP_KERNEL) from ISR?
  17. Can you acquire a mutex inside ISR?
  18. Can you use a spinlock inside ISR?
  19. What is threaded IRQ?
  20. What is request_threaded_irq()?

15. Top Half / Bottom Half

  1. What is top half?
  2. What is bottom half?
  3. Why do we defer interrupt work?
  4. What is tasklet?
  5. What is workqueue?
  6. What is threaded interrupt?
  7. Tasklet vs workqueue.
  8. Workqueue vs threaded IRQ.
  9. Which can sleep?
  10. Which runs in interrupt context?
  11. When would you choose each mechanism?

Simple idea

Hardware Interrupt
       ↓
    Top Half
       ↓
  Quick processing
       ↓
   Bottom Half
       ↓
Longer processing

16. Spinlocks

  1. What is spinlock?
  2. Why do we need spinlocks?
  3. What is spin_lock()?
  4. What is spin_unlock()?
  5. What is spin_lock_irqsave()?
  6. What is spin_unlock_irqrestore()?
  7. Why disable interrupts while taking some spinlocks?
  8. Can a spinlock holder sleep?
  9. What happens if it does?
  10. Spinlock vs mutex.
  11. Spinlock vs semaphore.
  12. What is spinlock contention?
  13. What is recursive spinlock acquisition?
  14. What is deadlock with spinlocks?

17. Mutex

  1. What is a mutex?
  2. Why use mutex?
  3. mutex_lock().
  4. mutex_unlock().
  5. Can mutex sleep?
  6. Can mutex be used in interrupt context?
  7. Mutex vs spinlock.
  8. Mutex vs semaphore.
  9. Recursive mutex?
  10. What happens if a process dies while holding a mutex?
  11. What is priority inversion?

18. Semaphores

  1. What is semaphore?
  2. Binary semaphore vs counting semaphore.
  3. Semaphore vs mutex.
  4. What is down()?
  5. What is up()?
  6. Can semaphore sleep?
  7. Can semaphore be used in interrupt context?
  8. When would you choose semaphore?

19. Atomic Operations

  1. What is an atomic operation?
  2. Why do we need atomic operations?
  3. What is atomic_t?
  4. What is atomic_read()?
  5. What is atomic_set()?
  6. What is atomic_inc()?
  7. What is atomic_dec()?
  8. What is atomic_add()?
  9. Atomic variable vs mutex.
  10. When should you use atomic operations?

20. Memory Barriers

  1. What is memory ordering?
  2. What is a memory barrier?
  3. Why are memory barriers required on SMP?
  4. What is compiler reordering?
  5. What is CPU reordering?
  6. What is mb()?
  7. What is rmb()?
  8. What is wmb()?
  9. What is smp_mb()?
  10. What is READ_ONCE()?
  11. What is WRITE_ONCE()?
  12. Give a real race condition where a memory barrier is needed.

21. Kernel Linked Lists

  1. Why does Linux use linked lists?
  2. What is struct list_head?
  3. What is an intrusive linked list?
  4. INIT_LIST_HEAD().
  5. list_add().
  6. list_add_tail().
  7. list_del().
  8. list_for_each().
  9. list_for_each_entry().
  10. What is container_of()?
  11. Why is container_of() important?
  12. How does container_of() work?
  13. What is offsetof()?

22. container_of()

A classic interview question.

Suppose:

struct my_device {
    int id;
    struct list_head list;
};

If you have:

struct list_head *ptr;

how do you obtain:

struct my_device *

Answer:

container_of()

Know exactly how and why it works.

23. Kernel Process Programming

  1. What is task_struct?
  2. What information does it contain?
  3. How do you get the current task?
  4. What is current?
  5. What is current->pid?
  6. What is current->comm?
  7. What is process context?
  8. What is kernel context?
  9. Can kernel code create processes?
  10. Can kernel code create threads?
  11. What is kthread_run()?
  12. What is kthread_stop()?
  13. How do you stop a kernel thread?
  14. Can a kernel thread sleep?
  15. What is schedule()?
  16. What is schedule_timeout()?

24. Kernel Threads

  1. What is a kernel thread?
  2. User thread vs kernel thread.
  3. What is kthread_run()?
  4. What is kthread_create()?
  5. What is wake_up_process()?
  6. What is kthread_should_stop()?
  7. What is kthread_stop()?
  8. Can a kernel thread call schedule()?
  9. How do you safely terminate a kernel thread?
  10. Kernel thread vs workqueue.

25. Timers

  1. What is a kernel timer?
  2. Why are kernel timers used?
  3. What is struct timer_list?
  4. What is timer_setup()?
  5. What is mod_timer()?
  6. What is del_timer()?
  7. What is timer callback?
  8. Can a timer callback sleep?
  9. Timer vs delayed work.
  10. How do you create a periodic timer?

26. Workqueues

  1. What is workqueue?
  2. Why use workqueue?
  3. What is deferred work?
  4. What is struct work_struct?
  5. What is INIT_WORK()?
  6. What is schedule_work()?
  7. What is cancel_work_sync()?
  8. Can workqueue code sleep?
  9. Workqueue vs tasklet.
  10. Workqueue vs kernel thread.
  11. What is delayed work?
  12. What is schedule_delayed_work()?

27. Device Tree Programming

  1. What is Device Tree?
  2. What is DTS?
  3. What is DTSI?
  4. What is DTB?
  5. What is DTBO?
  6. What is compatible?
  7. What is reg?
  8. What is interrupts?
  9. What is clocks?
  10. What is gpios?
  11. What is status?
  12. What is a phandle?
  13. What is of_match_table?
  14. What is of_device_id?
  15. How does a driver read a Device Tree property?
  16. What is of_property_read_u32()?
  17. What is of_property_read_string()?
  18. How do you obtain a GPIO?
  19. How do you obtain an IRQ?
  20. How does Device Tree trigger probe()?

Critical flow

DTS
 ↓
DTB
 ↓
Kernel parses Device Tree
 ↓
Device created
 ↓
Driver registered
 ↓
compatible matching
 ↓
probe()

28. Platform Driver Programming

  1. What is a platform driver?
  2. Why use platform drivers?
  3. What is struct platform_driver?
  4. What is probe()?
  5. What is remove()?
  6. When is probe() called?
  7. How does platform driver matching work?
  8. What is platform_get_resource()?
  9. What is platform_get_irq()?
  10. What is platform_get_drvdata()?
  11. What is platform_set_drvdata()?
  12. What is devm_ioremap_resource()?
  13. What is devm_kzalloc()?
  14. What is devm_request_irq()?
  15. What happens if probe fails?
  16. How do you clean up resources?

29. I2C Kernel Programming

  1. What is I2C?
  2. What is an I2C adapter?
  3. What is an I2C client?
  4. What is struct i2c_driver?
  5. What is struct i2c_client?
  6. What is struct i2c_adapter?
  7. What is probe()?
  8. What is remove()?
  9. What is i2c_transfer()?
  10. What is i2c_master_send()?
  11. What is i2c_master_recv()?
  12. What is SMBus?
  13. I2C vs SMBus.
  14. How does an I2C driver match a Device Tree node?
  15. How do you debug an I2C device that isn’t responding?

30. SPI Kernel Programming

  1. What is SPI?
  2. What is SPI master?
  3. What is SPI device?
  4. What is struct spi_driver?
  5. What is struct spi_device?
  6. What is struct spi_transfer?
  7. What is struct spi_message?
  8. What is spi_sync()?
  9. What is spi_async()?
  10. What is CPOL?
  11. What is CPHA?
  12. What are SPI modes?
  13. How does SPI driver matching work?
  14. How is SPI represented in Device Tree?
  15. I2C vs SPI.

31. GPIO Kernel Programming

  1. What is GPIO?
  2. What is GPIO descriptor?
  3. What is gpiod_get()?
  4. What is gpiod_set_value()?
  5. What is gpiod_get_value()?
  6. GPIO input vs output.
  7. GPIO vs pinctrl.
  8. How do you describe GPIO in Device Tree?
  9. How can a GPIO generate an interrupt?
  10. Legacy GPIO API vs descriptor-based API.

32. MMIO

  1. What is memory-mapped I/O?
  2. What is a hardware register?
  3. How does CPU access hardware registers?
  4. What is ioremap()?
  5. What is iounmap()?
  6. What is readb()?
  7. What is readw()?
  8. What is readl()?
  9. What is writeb()?
  10. What is writew()?
  11. What is writel()?
  12. Why shouldn’t you use normal pointer access for MMIO?
  13. What is __iomem?
  14. What is register masking?
  15. How do you set/clear a register bit?

33. DMA

  1. What is DMA?
  2. Why use DMA?
  3. CPU transfer vs DMA transfer.
  4. What is a DMA buffer?
  5. What is DMA mapping?
  6. What is dma_map_single()?
  7. What is dma_unmap_single()?
  8. What is dma_alloc_coherent()?
  9. What is coherent DMA?
  10. What is streaming DMA?
  11. What is cache coherency?
  12. What is DMA mask?
  13. What is dma_set_mask_and_coherent()?
  14. What is IOMMU?
  15. What happens if CPU cache isn’t synchronized with DMA?

34. Device Model

  1. What is Linux device model?
  2. What is struct device?
  3. What is a bus?
  4. What is a driver?
  5. What is a device?
  6. What is a class?
  7. What is kobject?
  8. What is reference counting?
  9. What is sysfs?
  10. What is uevent?
  11. What is device binding?
  12. What is driver binding?
  13. What is hotplug?
  14. What is udev?

35. Sysfs Programming

  1. What is sysfs?
  2. Why is sysfs used?
  3. How does a driver create a sysfs attribute?
  4. What is struct device_attribute?
  5. What is show()?
  6. What is store()?
  7. What is DEVICE_ATTR()?
  8. What is sysfs_create_group()?
  9. Sysfs vs procfs.
  10. Sysfs vs debugfs.

36. Debugfs

  1. What is debugfs?
  2. Why use debugfs?
  3. How do you create a debugfs file?
  4. How do you expose driver debug information?
  5. Debugfs vs sysfs.
  6. Should production applications depend on debugfs?

37. Kernel Debugging

  1. How do you debug a kernel module?
  2. What is dmesg?
  3. What is dynamic debug?
  4. What is ftrace?
  5. What is tracepoint?
  6. What is kprobe?
  7. What is kretprobe?
  8. What is perf?
  9. What is KGDB?
  10. What is KASAN?
  11. What is KCSAN?
  12. What is lockdep?
  13. What is kmemleak?
  14. What is kernel panic?
  15. What is Oops?
  16. Oops vs panic.
  17. What is a kernel call trace?
  18. How do you find the source line causing a crash?
  19. What is addr2line?
  20. Why do you need vmlinux with debug symbols?

38. Kernel Crash Questions

Prepare these scenarios:

Q1

Kernel crashes with NULL pointer dereference. How do you debug?

Q2

Driver works for 10 minutes and then crashes.

What do you investigate?

Memory corruption
Race condition
Use-after-free
DMA corruption
Stack overflow

Q3

Driver unload causes kernel panic.

Think:

Outstanding references
Running workqueue
Active timer
Interrupt still enabled
Use-after-free

Q4

System hangs when driver is unloaded.

Think:

Deadlock
Blocked process
Workqueue not cancelled
Kernel thread not stopped

39. Error Handling

  1. Why does kernel code return negative error codes?
  2. What is -EINVAL?
  3. What is -ENOMEM?
  4. What is -EFAULT?
  5. What is -EBUSY?
  6. What is -ENODEV?
  7. What is -EIO?
  8. What is IS_ERR()?
  9. What is PTR_ERR()?
  10. What is ERR_PTR()?
  11. NULL pointer vs error pointer.
  12. How do you clean resources when probe() fails halfway?

40. Reference Counting

  1. What is reference counting?
  2. Why is reference counting needed?
  3. What is kref?
  4. What is refcount_t?
  5. What happens if reference counting is wrong?
  6. How can reference counting prevent use-after-free?
  7. What is a module reference count?
  8. Why can’t a driver unload while it is still in use?

41. RCU

  1. What is RCU?
  2. Why use RCU?
  3. What is read-copy-update?
  4. What is rcu_read_lock()?
  5. What is rcu_read_unlock()?
  6. What is synchronize_rcu()?
  7. RCU vs mutex.
  8. RCU vs spinlock.
  9. When is RCU useful?

42. Kernel Scheduling APIs

  1. What is schedule()?
  2. What is schedule_timeout()?
  3. What is cond_resched()?
  4. What is yield()?
  5. What is task state?
  6. What is TASK_RUNNING?
  7. What is TASK_INTERRUPTIBLE?
  8. What is TASK_UNINTERRUPTIBLE?
  9. Why shouldn’t you normally use TASK_UNINTERRUPTIBLE unnecessarily?

43. Kernel Preemption

  1. What is preemption?
  2. What is kernel preemption?
  3. What is voluntary preemption?
  4. What is preemptive kernel?
  5. What is preempt_disable()?
  6. What is preempt_enable()?
  7. What is preemption count?
  8. Why can’t certain kernel contexts be preempted?
  9. How does PREEMPT_RT change kernel behavior?

44. Per-CPU Variables

  1. What is per-CPU data?
  2. Why use per-CPU variables?
  3. What problem do they solve?
  4. What is DEFINE_PER_CPU()?
  5. What is alloc_percpu()?
  6. How does per-CPU data improve performance?
  7. How does it reduce locking?

45. Kernel Stack

  1. What is a kernel stack?
  2. User stack vs kernel stack.
  3. Does each thread have its own kernel stack?
  4. How large is a kernel stack?
  5. Why must kernel stack usage be limited?
  6. What causes kernel stack overflow?
  7. Why should large local arrays be avoided in kernel code?
  8. What happens during user → kernel transition to the stack?

46. Kernel Concurrency Scenarios

Be able to answer:

Scenario

One CPU is executing your driver while an interrupt occurs and accesses the same data.

What do you use?

Possible answer: appropriate locking such as a spinlock, depending on context.

Scenario

Two processes call your driver’s write() simultaneously.

What do you do?

Answer: identify shared state and protect it with appropriate synchronization.

Scenario

ISR modifies a buffer while userspace reads it.

Think:

Interrupt context
       ↕
Synchronization
       ↕
Process context

47. User ↔ Kernel Communication

Know every major mechanism:

read()
write()
ioctl()
mmap()
poll()
sysfs
procfs
netlink

Questions:

  1. How does userspace communicate with kernel?
  2. When would you use read/write?
  3. When would you use ioctl?
  4. When would you use mmap?
  5. When would you use sysfs?
  6. What is netlink?
  7. What is procfs?
  8. Which mechanism is appropriate for configuration vs bulk data?

48. mmap Programming

  1. What is mmap()?
  2. Why map kernel memory into userspace?
  3. How does a driver’s .mmap callback work?
  4. What is zero-copy?
  5. Why is mmap useful for high-bandwidth data?
  6. What are mmap security concerns?
  7. How can DMA buffers be exposed to userspace?

49. Kernel Networking Programming

  1. What is struct net_device?
  2. What is sk_buff?
  3. What is NAPI?
  4. Why is NAPI used?
  5. What happens when an Ethernet packet arrives?
  6. How does a network driver receive packets?
  7. What is RX ring?
  8. What is TX ring?
  9. How is DMA used by network drivers?
  10. What is interrupt coalescing?

50. Power Management

  1. What is runtime PM?
  2. What is system suspend?
  3. What is resume?
  4. What is suspend()?
  5. What is resume()?
  6. What is pm_runtime_get_sync()?
  7. What is pm_runtime_put()?
  8. What is autosuspend?
  9. What is wakeup source?
  10. How does a driver handle power state transitions?

51. Kernel Time / Timers

  1. What is jiffies?
  2. What is HZ?
  3. What is kernel tick?
  4. What is high-resolution timer?
  5. What is monotonic time?
  6. What is ktime?
  7. Timer vs sleep.
  8. Timer callback vs workqueue.

52. Kernel Lists / Queues

  1. Linked list.
  2. Hash list.
  3. Circular buffer.
  4. Ring buffer.
  5. FIFO.
  6. What is kfifo?
  7. Why use kfifo?
  8. How do you implement producer-consumer?
  9. How do you synchronize a ring buffer?

53. Kernel FIFO

  1. What is kfifo?
  2. Why use kfifo?
  3. kfifo_in().
  4. kfifo_out().
  5. How do you allocate a FIFO?
  6. Is kfifo automatically thread-safe?
  7. How would you synchronize producer and consumer?

54. Kernel APIs — Must Know

You should recognize and explain these:

kmalloc()
kzalloc()
kfree()

vmalloc()
vfree()

copy_to_user()
copy_from_user()

mutex_lock()
mutex_unlock()

spin_lock()
spin_unlock()

spin_lock_irqsave()
spin_unlock_irqrestore()

wait_event()
wake_up()

schedule()
schedule_timeout()

request_irq()
free_irq()
request_threaded_irq()

alloc_chrdev_region()
unregister_chrdev_region()

cdev_init()
cdev_add()
cdev_del()

class_create()
device_create()
device_destroy()

ioremap()
iounmap()

readl()
writel()

devm_kzalloc()
devm_request_irq()
devm_ioremap_resource()

kthread_run()
kthread_stop()

schedule_work()
cancel_work_sync()

dma_alloc_coherent()
dma_map_single()
dma_unmap_single()

container_of()
list_add()
list_del()
list_for_each_entry()

55. Kernel Coding Questions

Interviewers may give you code and ask:

Example 1

char *buf;

buf = kmalloc(100, GFP_KERNEL);

Questions:

  • What does this do?
  • What if allocation fails?
  • How do you free it?
  • Can this be called from ISR?

Example 2

spin_lock(&lock);
foo++;
spin_unlock(&lock);

Questions:

  • Why use spinlock?
  • Can foo++ be interrupted?
  • Can this code sleep?
  • What happens on SMP?

Example 3

if (copy_from_user(buf, user_buf, count))
    return -EFAULT;

Questions:

  • Why use copy_from_user()?
  • What does its return value mean?
  • Why return -EFAULT?

56. Kernel Programming Scenario Questions

These are very important for actual interviews.

1. Your driver hangs the system.

How do you debug it?

2. Your probe() isn’t called.

What do you check?

3. /dev/mydevice isn’t created.

What do you check?

4. Interrupt isn’t coming.

What do you check?

5. I2C device isn’t detected.

What do you check?

6. Driver crashes during rmmod.

What do you check?

7. read() blocks forever.

What could be wrong?

8. CPU usage becomes 100%.

Could your driver be causing it?

9. DMA data is corrupted.

What could be wrong?

10. Driver works on one board but not another.

What would you investigate?

11. Race condition occurs only occasionally.

How would you debug it?

12. Kernel memory usage keeps increasing.

What do you investigate?

13. System crashes after suspend/resume.

What do you investigate?

14. Driver works initially but fails after repeated open/close.

What could be wrong?

15. Hardware generates interrupts continuously.

What could cause an interrupt storm?

57. Most Important Questions to Master

If you have an interview soon, do these first:

  1. Kernel vs user space.
  2. Kernel module lifecycle.
  3. module_init() / module_exit().
  4. Kernel Makefile.
  5. kmalloc() / vmalloc().
  6. GFP flags.
  7. copy_to_user() / copy_from_user().
  8. Character driver architecture.
  9. Major/minor numbers.
  10. cdev.
  11. file_operations.
  12. open/read/write/ioctl.
  13. Blocking/non-blocking I/O.
  14. Wait queues.
  15. poll().
  16. Interrupts.
  17. Top half/bottom half.
  18. Workqueue.
  19. Kernel thread.
  20. Mutex.
  21. Spinlock.
  22. Semaphore.
  23. Atomic operations.
  24. Memory barriers.
  25. Race conditions.
  26. Deadlocks.
  27. container_of().
  28. Linked lists.
  29. Device Tree.
  30. Platform driver.
  31. probe() / remove().
  32. MMIO.
  33. ioremap().
  34. I2C driver.
  35. SPI driver.
  36. GPIO.
  37. DMA.
  38. Sysfs.
  39. Debugfs.
  40. Kernel debugging.
  41. Kernel Oops.
  42. Kernel panic.
  43. KASAN.
  44. Lockdep.
  45. ftrace.
  46. Power management.
  47. mmap.
  48. VFS basics.
  49. Kernel scheduling.
  50. Real-world debugging scenarios.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *