본문으로 건너뛰기
cccskills
무료GitHub에 공개

kernel-memory-management

Use when using kmalloc, vmalloc, or the page allocator, sizing kmalloc allocations, working with SLUB or the buddy allocator, or debugging memory zones and kernel OOM.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md4.8 KB
  • agents/openai.yaml245 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Kernel memory management

Contract

FieldBound contract
TriggerAllocating kernel memory in a driver or subsystem: kmalloc versus vmalloc, GFP flags, the buddy allocator, SLUB caches, DMA-coherent buffers, or OOM and slab corruption debugging.
AuthorityRead-only. Writes nothing. Chat output only. No remote mutation.
Side effectReturns allocation choices and debug commands. No source files are modified.
DoneThe allocator choice per allocation site, the GFP flag per context, and a debug path for any reported memory symptom are delivered.

Inputs

  1. Allocation sites (required): each buffer with its size, lifetime, and the context that allocates it.
  2. Hardware requirement (optional): which buffers feed a DMA device, and the device's addressing limits.
  3. Failure report (optional): OOM kills, slab corruption reports, or allocation failures under load.

Procedure

  1. Pick the allocator per site from the contiguity and size facts.

    Physically contiguous needed (device DMA)?
    ├── Yes: dma_alloc_coherent() or the CMA pool
    └── No
        ├── Small buffer: kmalloc / kzalloc
        ├── Large buffer, virtual contiguity is enough: vmalloc / vzalloc
        └── Whole pages with manual layout: alloc_pages() / __free_pages()
    

    kmalloc returns physically contiguous memory from SLUB caches; above the largest cache the call falls back to the page allocator, which still yields contiguous pages up to the allocator's order limit. Check the real limits per architecture and page size in include/linux/slab.h (KMALLOC_MAX_CACHE_SIZE, KMALLOC_MAX_SIZE) instead of quoting a fixed byte ceiling. vmalloc gets virtual contiguity from scattered pages and must not back device DMA without dma_map_*. Done when: every site names its allocator and the reason.

  2. Match the GFP flag to the context.

    GFP flagContext
    GFP_KERNELProcess context, may sleep
    GFP_ATOMICIRQ or spinlock held; draws from smaller reserves
    GFP_DMALegacy 32-bit devices limited to the DMA zone

    Done when: no sleeping allocation can run in an atomic context, and atomic allocations are small and rare.

  3. Inspect SLUB state when allocation behavior needs evidence.

    cat /proc/slabinfo           # per-cache counts; root-readable
    cat /sys/kernel/slab/kmalloc-1k/object_size
    

    SLUB is the only in-tree SLAB allocator since kernel 6.12 removed the legacy SLAB backend; the kernel floor here (LTS 6.18, mainline 7.2) has no SLAB. Done when: the cache sizes behind a hot allocation path are known from the running system.

  4. Use the page allocator for page-granular structures.

    struct page *page = alloc_pages(GFP_KERNEL, order);
    void *addr = page_address(page);
    __free_pages(page, order);
    

    An order of n allocates 2^n pages. Zone selection (ZONE_DMA, ZONE_NORMAL, ZONE_MOVABLE) lives in include/linux/mmzone.h. Done when: the order and the free call match the allocation.

  5. Handle NUMA deliberately on multi-node systems. kmalloc already prefers the local node; bind hot per-node structures with alloc_pages_node(). In user space, control placement with numactl or mbind for HPC paths. Done when: per-node placement is stated for each latency-critical buffer.

  6. Debug the reported symptom from evidence.

    cat /proc/meminfo
    cat /proc/slabinfo
    dmesg | grep -i oom
    

    For use-after-free and corruption hunts, build with CONFIG_SLUB_DEBUG and CONFIG_KASAN. Route deeper work: virtual-memory-paging-and-tlb for paging mechanics, mmio-and-bit-manipulation for register-level access around mapped buffers, dma-baremetal for bare-metal DMA setup. Done when: the symptom maps to one row of the failure table.

Failure and recovery

SymptomCauseRecovery
Large kmalloc failsAbove the allocator's contiguous limitMove to vmalloc, or redesign around pages; check KMALLOC_MAX_SIZE.
Device reads garbage from a buffervmalloc memory handed to DMAAllocate with dma_alloc_coherent, or map with dma_map_*.
OOM killer firesUnbounded cache growthCap pool sizes; use a shrinker.
Slab corruption reportUse-after-free or double freeEnable KASAN; audit kfree pairing.
Sleep warning under loadGFP_KERNEL in atomic contextSwitch that site to GFP_ATOMIC or defer the work.

Output

The allocator choice with reasons per site; the GFP flag per context; the SLUB inspection evidence; the page-allocation orders; the NUMA placement plan; the debug transcript for the reported symptom; the routing to related skills.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

af-xdp

무료

Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

agents-md

무료

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

OutlineDriven의 스킬 모두 보기

이 스킬의 문제 신고