Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions kernel_ai/services/syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import platform
from datetime import datetime


def _kernel_dna_read_proc_vmstat():
Expand Down Expand Up @@ -140,3 +141,33 @@ def get_real_system_calls(syscall_names, map_syscall_to_subsystem_fn, kernel_dna
return []
except Exception:
return [] if platform.system() == "Linux" else fallback_mock_calls_fn()


def get_softirq_nucleotides(map_interrupt_to_subsystem_fn, limit=8):
"""Per-vector softirq totals from /proc/softirqs."""
out = []
try:
with open("/proc/softirqs", "r", encoding="utf-8", errors="replace") as f:
lines = f.readlines()
if len(lines) < 2:
return out
for line in lines[1 : 1 + limit]:
parts = line.split()
if len(parts) < 2:
continue
vec = parts[0].rstrip(":")
total = sum(int(x) for x in parts[1:] if x.isdigit())
if total > 0:
out.append(
{
"type": "interrupt",
"code": "T",
"name": f"softirq:{vec}",
"count": total,
"subsystem": map_interrupt_to_subsystem_fn(vec),
"timestamp": datetime.now().isoformat(),
}
)
except (OSError, ValueError):
pass
return out
Loading
Loading