Add drgn tests, man page, and dynamic region list research#4
Merged
Conversation
- 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(®ion_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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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