Skip to content

Instantly share code, notes, and snippets.

@davidlohr
Created June 9, 2022 18:50
Show Gist options
  • Save davidlohr/f8eb7344affcf78d20f6b98e0a500ac1 to your computer and use it in GitHub Desktop.
Save davidlohr/f8eb7344affcf78d20f6b98e0a500ac1 to your computer and use it in GitHub Desktop.
Applies to the MM, but works on any subsystem.
Based on https://deferred.io/2015/10/27/visualizing-linux-kernel-call-graphs.html
$ git diff
diff --git a/Makefile b/Makefile
index c43d825a3c4c..3b9f43a112b8 100644
--- a/Makefile
+++ b/Makefile
@@ -523,7 +523,7 @@ KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
-Werror=implicit-function-declaration -Werror=implicit-int \
- -Werror=return-type -Wno-format-security \
+ -Werror=return-type -Wno-format-security -fdump-rtl-expand \
-std=gnu11
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_AFLAGS_KERNEL :=
$ make mm/ to generate the RTL insn info.
Then to generate a mm-callgraph.svg file:
$ egypt mm/backing-dev.c.253r.expand mm/balloon_compaction.c.253r.expand mm/bootmem_info.c.253r.expand mm/cma.c.253r.expand mm/cma_sysfs.c.253r.expand mm/compaction.c.253r.expand mm/debug.c.253r.expand mm/dmapool.c.253r.expand mm/early_ioremap.c.253r.expand mm/fadvise.c.253r.expand mm/filemap.c.253r.expand mm/folio-compat.c.253r.expand mm/frontswap.c.253r.expand mm/gup.c.253r.expand mm/hmm.c.253r.expand mm/huge_memory.c.253r.expand mm/hugetlb.c.253r.expand mm/hugetlb_cgroup.c.253r.expand mm/hugetlb_vmemmap.c.253r.expand mm/hwpoison-inject.c.253r.expand mm/init-mm.c.253r.expand mm/interval_tree.c.253r.expand mm/khugepaged.c.253r.expand mm/ksm.c.253r.expand mm/list_lru.c.253r.expand mm/maccess.c.253r.expand mm/madvise.c.253r.expand mm/mapping_dirty_helpers.c.253r.expand mm/memblock.c.253r.expand mm/memcontrol.c.253r.expand mm/memfd.c.253r.expand mm/memory.c.253r.expand mm/memory-failure.c.253r.expand mm/memory_hotplug.c.253r.expand mm/mempolicy.c.253r.expand mm/mempool.c.253r.expand mm/memremap.c.253r.expand mm/migrate.c.253r.expand mm/migrate_device.c.253r.expand mm/mincore.c.253r.expand mm/mlock.c.253r.expand mm/mmap.c.253r.expand mm/mmap_lock.c.253r.expand mm/mm_init.c.253r.expand mm/mmu_gather.c.253r.expand mm/mmu_notifier.c.253r.expand mm/mmzone.c.253r.expand mm/mprotect.c.253r.expand mm/mremap.c.253r.expand mm/msync.c.253r.expand mm/oom_kill.c.253r.expand mm/page_alloc.c.253r.expand mm/page_counter.c.253r.expand mm/page_ext.c.253r.expand mm/page_io.c.253r.expand mm/page_isolation.c.253r.expand mm/page_owner.c.253r.expand mm/page_poison.c.253r.expand mm/page_reporting.c.253r.expand mm/page_vma_mapped.c.253r.expand mm/pagewalk.c.253r.expand mm/page-writeback.c.253r.expand mm/percpu.c.253r.expand mm/pgtable-generic.c.253r.expand mm/process_vm_access.c.253r.expand mm/ptdump.c.253r.expand mm/readahead.c.253r.expand mm/rmap.c.253r.expand mm/rodata_test.c.253r.expand mm/secretmem.c.253r.expand mm/shmem.c.253r.expand mm/shuffle.c.253r.expand mm/slab_common.c.253r.expand mm/slub.c.253r.expand mm/sparse.c.253r.expand mm/sparse-vmemmap.c.253r.expand mm/swap.c.253r.expand mm/swap_cgroup.c.253r.expand mm/swapfile.c.253r.expand mm/swap_slots.c.253r.expand mm/swap_state.c.253r.expand mm/truncate.c.253r.expand mm/usercopy.c.253r.expand mm/userfaultfd.c.253r.expand mm/util.c.253r.expand mm/vmacache.c.253r.expand mm/vmalloc.c.253r.expand mm/vmpressure.c.253r.expand mm/vmscan.c.253r.expand mm/vmstat.c.253r.expand mm/workingset.c.253r.expand mm/z3fold.c.253r.expand mm/zbud.c.253r.expand mm/zpool.c.253r.expand mm/zsmalloc.c.253r.expand mm/zswap.c.253r.expand | dot -Grankdir=LR -Tsvg -o mm-callgraph.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment