Advanced Linux Interview Questions on Kernel Resources

Advanced Linux interview answers need to connect a measurement to its scope and explain what would change your conclusion. These questions focus on cgroup v2, pressure stalls, process limits and service resource settings. A checked offline Python exercise compares invented memory-event counters without reading a running machine.

Aug 28, 2024 - 10:12
Updated: 
106.9k

Linux Administration in IT Infrastructure · Interview preparation

Advanced Linux Interview Questions on Kernel Resources

Quick answer: Advanced Linux interview answers need to connect a measurement to its scope and explain what would change your conclusion. These questions focus on cgroup v2, pressure stalls, process limits and service resource settings. A checked offline Python exercise compares invented memory-event counters without reading a running machine. Use it to practise distinguishing an allocation problem from evidence of an OOM kill, then explain what further system evidence you would request.

Key takeaways

  • Identify the cgroup, hierarchy and observation interval before interpreting counters.
  • Treat memory.high and memory.max as different controls.
  • Compare pressure stalls with application latency and workload context.
  • Separate namespace isolation from resource accounting and limits.
  • Explain why a proposed limit change needs a measured acceptance test.

Table of Contents

What must you establish before interpreting resource figures?

Identify whether the evidence comes from the host, a container, a service cgroup or a single process. Record the time interval and whether the workload restarted during it. A machine can have available memory while one service is constrained by a parent cgroup.

The kernel cgroup v2 reference describes a hierarchy in which ancestor restrictions affect descendants. A child cannot override a more restrictive ancestor simply by requesting a higher limit. In an interview, ask for the parent settings before recommending more memory for the child.

Our worked case is a fictional image worker whose request latency rose during a short processing interval. The supplied evidence contains counters only. It has no host totals, parent configuration or application trace, so the first answer should identify those missing measurements.

How do memory.high and memory.max differ?

memory.high applies reclaim pressure and throttling when usage exceeds its boundary; crossing it does not itself invoke the OOM killer. memory.max is a hard usage boundary, where an unreclaimable allocation can lead to an OOM situation. Neither setting is a performance target that should automatically be raised whenever an event appears.

For the image worker, ask whether the working set changed or the configured boundary was recently lowered. Compare the same workload before and after that change. A larger allowance may merely move contention to another service.

At the service layer, the systemd resource-control manual documents settings such as MemoryHigh and MemoryMax. Verify which settings and controllers the installed system supports; the current online manual can describe features newer than a particular distribution package.

ObservationReasonable interpretationStill needed
high counter risesHigh-boundary pressure occurredInterval, latency and configured boundary
oom counter risesAn OOM condition was encounteredKill counter and corroborating evidence
oom_kill risesProcesses in this cgroup were OOM-killedVictim identity and surrounding context

Does a rising oom counter prove a process was killed?

No. In the supplied records, oom increases by one while oom_kill stays unchanged. The narrow conclusion is that the supplied interval shows an OOM-counter increase without an OOM-kill-counter increase. Avoid naming a killed process when the evidence contains no victim record.

The following checked Python calculation uses invented dictionaries. Its counter-reset check refuses a decreasing value because subtracting across a restart or replacement could produce a meaningless interval. It reads no cgroup files and does not reproduce a kernel memory event.

before = {"high": 4, "max": 0, "oom": 0, "oom_kill": 0}
after = {"high": 9, "max": 1, "oom": 1, "oom_kill": 0}

if before.keys() != after.keys():
    raise ValueError("counter sets differ")
delta = {}
for key in before:
    if type(before[key]) is not int or type(after[key]) is not int:
        raise ValueError("integer counters required")
    if before[key] < 0 or after[key] < before[key]:
        raise ValueError("negative or reset counter: compare a new interval")
    delta[key] = after[key] - before[key]

print("Invented interval deltas:")
for key, value in delta.items():
    print(f"{key}: {value}")
print("oom rose; oom_kill did not rise in the supplied interval.")
print("No live kernel files were read.")

Checked output:

Invented interval deltas:
high: 5
max: 1
oom: 1
oom_kill: 0
oom rose; oom_kill did not rise in the supplied interval.
No live kernel files were read.

How is pressure stall information different from utilisation?

Utilisation describes resource use; pressure stall information describes time during which tasks cannot make progress because resources are contended. The kernel PSI guide distinguishes some, where at least some tasks are stalled, from full, where all non-idle tasks in the measured group are stalled simultaneously. Interpret the resource and scope carefully, including the CPU full distinction at system level.

Suppose the image worker’s latency doubled while the supplied memory-pressure trend rose. That association is a reason to investigate, not a complete diagnosis. Compare request size, concurrency, reclaim evidence and the same time window. A single average from a different interval can mislead.

Ask which service outcome must improve. “Lower memory use” alone can be a poor acceptance criterion if the proposed restriction makes user requests time out.

Do namespaces, process limits and cgroups solve the same problem?

Namespaces change the view of particular system resources. For example, the mount-namespace manual explains that processes in different mount namespaces can see different mount hierarchies. That does not itself assign each workload a memory budget or protect it from every kernel-level risk.

Process resource limits are another interface. The getrlimit manual defines a soft limit as the enforced resource limit and a hard limit as the ceiling for changing that soft limit, subject to privilege rules. These process limits differ from cgroup-wide budgets, so identify which interface supplied the limit in the question.

For an application reporting too many open files, ask about its actual process limit and file-descriptor use. A free-memory figure does not answer that question. Match the interface to the resource involved.

Why might two memory reports disagree?

They can measure different scopes or categories. A process resident-set measurement, a cgroup’s accounted memory and host memory information answer different questions. Summing process figures may also count shared pages in ways that make the sum unsuitable as a host total.

The kernel proc filesystem guide documents the meaning and limitations of process and system interfaces. Describe the field you need before naming a tool. Include units, collection time and whether the process identity remained stable.

For the fictional worker, prepare an evidence request with the worker’s cgroup path, parent controls, application latency, recent release identifier and comparable interval samples. This is more useful than asking for a screenshot of every available dashboard. Avoid collecting command lines or unrelated process details when they may contain sensitive information.

How would you answer a request to tune the kernel immediately?

Explain the hypothesis, affected scope, proposed test and reversal route first. The kernel sysctl documentation covers interfaces for inspecting and modifying kernel parameters; the existence of a writable setting is not a recommendation to change it for this workload.

For our worker, propose a supervised staging comparison at a fixed input size and concurrency. Agree acceptable latency, error rate and impact on neighbouring workloads. If the hypothesis concerns a service cgroup boundary, changing a global kernel parameter may miss the cause and widen the risk.

Interview follow-upAnswer cue
Would adding RAM settle the case?Check workload and hierarchy constraints first
Can the supplied counters identify a victim?No victim identity is supplied
What would invalidate the delta?A reset, replaced group or mismatched interval
When is the change accepted?When agreed service and neighbour checks pass

Related reading: Linux troubleshooting interview questions; Command interpretation in Linux interviews.

References

Frequently Asked Questions

The resource examples use cgroup v2 terminology, so identify the running hierarchy before applying their interpretations to a real system.

The high boundary applies throttling and reclaim pressure; crossing it does not itself invoke the OOM killer for that group.

An oom event and an oom_kill event describe different counters, so corroborate a kill claim with the appropriate evidence.

The example compares invented dictionaries offline and does not allocate a stress workload, inspect cgroups or change kernel settings.

The script rejects that interval because a reset or replacement could make a simple before-and-after subtraction misleading or invalid.

Namespaces provide scoped views of resources, while cgroups and process limits control or account for particular resource usage in different ways.

Check the installed package version and distribution documentation first, because the latest manual can include unsupported directives or different defaults.

Name the observation scope, explain a supported inference, identify missing evidence and propose a measurable test with an agreed owner.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Anjali

I am passionate about technology, invention and big challenging tasks on my to- do list. In terms of the work I am doing also at Bunnyshell, I am most passionate about the technologies that we are using., I'm devoted to delivering content that not only informs but also inspires. Whether you need in- depth analysis pieces, educational attendants, or study- provoking opinion pieces, I draft content that resonates with tech suckers and professionals likewise.