LCA Performance Monitoring & Tuning 2 — Questions and Answers
Question 1: Which command displays real-time per-CPU statistics including user, system, and idle percentages?
- mpstat (Correct answer)
- vmstat
- iostat
- sar
Correct answer: mpstat
mpstat from the sysstat package shows per-processor statistics in real time.
Question 2: What does a consistently high 'si' (swap-in) value in vmstat output indicate?
- The system is actively swapping pages from disk to RAM, indicating memory pressure (Correct answer)
- CPU is spending time in software interrupts
- Storage I/O is saturated
- The kernel is servicing hardware interrupts at a high rate
Correct answer: The system is actively swapping pages from disk to RAM, indicating memory pressure
High 'si' in vmstat means the OS is reading pages back from swap into RAM, a sign of insufficient physical memory.
Question 3: Which /proc file provides a summary of CPU time spent in user mode, kernel mode, idle, and iowait?
- /proc/stat (Correct answer)
- /proc/cpuinfo
- /proc/interrupts
- /proc/schedstat
Correct answer: /proc/stat
/proc/stat contains cumulative CPU time counters used by tools like top and vmstat.
Question 4: You run 'perf stat ./myapp' and see a very low Instructions Per Cycle (IPC). What is the most likely bottleneck?
- Memory latency or cache misses causing the CPU to stall (Correct answer)
- Excessive context switching
- Disk I/O wait
- Network packet loss
Correct answer: Memory latency or cache misses causing the CPU to stall
Low IPC typically means the CPU is stalling while waiting for data from cache or RAM.
Question 5: What is the purpose of 'nice' and 'renice' commands in Linux performance tuning?
- Adjusting a process's scheduling priority to influence CPU time allocation (Correct answer)
- Changing a process's memory limit
- Pinning a process to a specific CPU core
- Modifying the I/O scheduler for a process
Correct answer: Adjusting a process's scheduling priority to influence CPU time allocation
nice and renice set a process's niceness value, which affects its priority in the CPU scheduler.
Question 6: Which tool would you use to trace system calls made by a running process to diagnose unexpected latency?
- strace (Correct answer)
- ltrace
- ftrace
- blktrace
Correct answer: strace
strace intercepts and logs system calls and signals for a given process.
Question 7: The kernel parameter vm.swappiness controls what behavior?
- How aggressively the kernel moves anonymous pages to swap relative to reclaiming file cache (Correct answer)
- The maximum size of the swap partition
- Whether swap is enabled at boot
- The priority order of multiple swap areas
Correct answer: How aggressively the kernel moves anonymous pages to swap relative to reclaiming file cache
vm.swappiness (0–100) tunes the kernel's tendency to swap anonymous memory versus dropping page cache.
Which command displays real-time per-CPU statistics including user, system, and idle percentages?