Skip to content

Add drgn tests, man page, and dynamic region list research#4

Merged
sdimitro merged 3 commits into
developfrom
claude/add-tests-docs-research-rZIzA
Feb 9, 2026
Merged

Add drgn tests, man page, and dynamic region list research#4
sdimitro merged 3 commits into
developfrom
claude/add-tests-docs-research-rZIzA

Conversation

@sdimitro

@sdimitro sdimitro commented Feb 9, 2026

Copy link
Copy Markdown
Owner
  • Expand test_drgn.py from 7 to 20 tests covering kernel structure
    walks (task_struct fields, mm_struct, dentry/inode, per-CPU data,
    superblocks, network namespaces), filter stats validation, ELF
    header comparison with /proc/kcore, raw page zeroing verification,
    sysfs parameter checks, and read consistency

  • Add kcore_filtered.4 man page documenting all module parameters
    (Layer 0 page filters, Layer 1 slab lists, Layer 2 audit, Layer 3
    rate limits), /proc/kcore_filtered_stats counters, usage examples,
    permissions, and known limitations

  • Update Makefile install target to install the man page alongside the
    module, add uninstall target for cleanup

  • Add doc/dynamic-region-list.md researching 6 approaches to overcome
    the static region list limitation (memory hotplug notifier, rebuild
    on open, lazy re-walk, kallsyms/kprobes, upstream, other notifiers)
    with recommended solution using register_memory_notifier() combined
    with lazy rebuild on open

https://claude.ai/code/session_01YMjtMS4kfRuUtH5KqzcC2e

- Expand test_drgn.py from 7 to 20 tests covering kernel structure
  walks (task_struct fields, mm_struct, dentry/inode, per-CPU data,
  superblocks, network namespaces), filter stats validation, ELF
  header comparison with /proc/kcore, raw page zeroing verification,
  sysfs parameter checks, and read consistency

- Add kcore_filtered.4 man page documenting all module parameters
  (Layer 0 page filters, Layer 1 slab lists, Layer 2 audit, Layer 3
  rate limits), /proc/kcore_filtered_stats counters, usage examples,
  permissions, and known limitations

- Update Makefile install target to install the man page alongside the
  module, add uninstall target for cleanup

- Add doc/dynamic-region-list.md researching 6 approaches to overcome
  the static region list limitation (memory hotplug notifier, rebuild
  on open, lazy re-walk, kallsyms/kprobes, upstream, other notifiers)
  with recommended solution using register_memory_notifier() combined
  with lazy rebuild on open

https://claude.ai/code/session_01YMjtMS4kfRuUtH5KqzcC2e
Remove the static region list limitation by mirroring the upstream
/proc/kcore pattern: register a memory hotplug notifier that sets a
dirty flag on MEM_ONLINE/MEM_OFFLINE events, then lazily rebuild the
region list on the next kcf_open() call.

The rebuild uses atomic_xchg() under write_lock(&region_lock) to
prevent a double-rebuild race when two CPUs open simultaneously.
On failure the flag is re-armed so the next open retries. The read
path is unchanged (read_lock only).

register_memory_notifier() is EXPORT_SYMBOL_GPL and becomes a no-op
when CONFIG_MEMORY_HOTPLUG is disabled, so this adds zero overhead
on systems without hotplug support.

Also removes doc/dynamic-region-list.md (research doc, now
implemented) and updates the man page to drop the static region
list limitation.

https://claude.ai/code/session_01YMjtMS4kfRuUtH5KqzcC2e
Test 35 exercises the hotplug notifier + lazy rebuild path by
offlining a memory block via /sys/devices/system/memory/memoryN/state,
opening /proc/kcore_filtered to trigger the rebuild, then verifying
"region list rebuilt" appears in dmesg. The block is re-onlined
immediately after.

Gracefully skips when CONFIG_MEMORY_HOTPLUG is not enabled, no
sysfs memory blocks exist, or the selected block cannot be offlined
(e.g., pinned by kernel allocations).

https://claude.ai/code/session_01YMjtMS4kfRuUtH5KqzcC2e
@sdimitro sdimitro merged commit 2e0c81e into develop Feb 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants