mywiki:linux:linuxstack
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mywiki:linux:linuxstack [2014/10/21 10:37] – shaoguoh | mywiki:linux:linuxstack [2022/04/02 17:29] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== kernel Stack ====== | ====== kernel Stack ====== | ||
| + | The default stack size for a process running in kernel space is 8K (as of 2011). | ||
| + | |||
| exception/ | exception/ | ||
| Line 15: | Line 17: | ||
| ===== checkstack.pl ====== | ===== checkstack.pl ====== | ||
| - | checkstack.pl creates a listing of the size of the stack frame used by every function in the kernel (i.e. the total amount of local scratch space used by each function for local variables and whatnot). | + | checkstack.pl creates a listing of **the size of the stack frame used by every function in the kernel** (i.e. the total amount of local scratch space used by each function for local variables and whatnot). |
| The way it does this is by going through the disassembly of the kernel and looking for 2 things: function names and instructions which adjust the stack. It looks for function names by looking for lines that match $funcre (qr/^$x* < | The way it does this is by going through the disassembly of the kernel and looking for 2 things: function names and instructions which adjust the stack. It looks for function names by looking for lines that match $funcre (qr/^$x* < | ||
| Line 23: | Line 25: | ||
| Example: | Example: | ||
| - | * mips-openwrt-linux-objdump -d vmlinux | + | * mips-openwrt-linux-objdump -d vmlinux | scripts/ |
| - | * cat vmlinux.S | + | |
| Its output like below: | Its output like below: | ||
| Line 38: | Line 39: | ||
| 0x802ed918 GSW_MulticastRouterPortRemove [vmlinux]: | 0x802ed918 GSW_MulticastRouterPortRemove [vmlinux]: | ||
| 0x802edd68 GSW_MulticastSnoopCfgSet [vmlinux]: | 0x802edd68 GSW_MulticastSnoopCfgSet [vmlinux]: | ||
| - | 0x802f1cb4 GSW_PortRedirectSet [vmlinux]: | + | ... |
| - | 0x802ed610 GSW_MulticastRouterPortAdd [vmlinux]: | + | |
| - | 0x802f3908 GSW_8021X_EAPOL_RuleSet [vmlinux]: | + | |
| - | 0x802e6b30 GSW_STP_BPDU_RuleSet [vmlinux]: | + | |
| - | 0x8023a820 test_pcomp [vmlinux]: | + | |
| - | 0x8022a7d8 semctl_main [vmlinux]: | + | |
| 0x8023ade4 test_comp [vmlinux]: | 0x8023ade4 test_comp [vmlinux]: | ||
| 0x8022b4e0 SyS_semtimedop [vmlinux]: | 0x8022b4e0 SyS_semtimedop [vmlinux]: | ||
| Line 50: | Line 46: | ||
| 0x8023b690 __test_skcipher [vmlinux]: | 0x8023b690 __test_skcipher [vmlinux]: | ||
| 0x80163cd0 elf_kcore_store_hdr [vmlinux]: | 0x80163cd0 elf_kcore_store_hdr [vmlinux]: | ||
| - | 0x801a5110 nlmsvc_mark_resources [vmlinux]: | + | ... |
| - | 0x802e2120 proc_write_directpath [vmlinux]: | + | |
| - | 0x80412190 copy_to_user_tmpl.part.33 [vmlinux]: | + | |
| - | 0x802a80bc loop_get_status_old [vmlinux]: | + | |
| - | 0x80197de0 nfs_dns_parse [vmlinux]: | + | |
| - | 0x802a7d58 loop_set_status_old [vmlinux]: | + | |
| - | 0x800d50b4 shmem_file_splice_read [vmlinux]: | + | |
| - | 0x80129268 __generic_file_splice_read [vmlinux]: | + | |
| 0x80129c08 vmsplice_to_pipe [vmlinux]: | 0x80129c08 vmsplice_to_pipe [vmlinux]: | ||
| 0x801aabc8 autofs4_notify_daemon [vmlinux]: | 0x801aabc8 autofs4_notify_daemon [vmlinux]: | ||
| Line 70: | Line 59: | ||
| 0x80122c88 setxattr [vmlinux]: | 0x80122c88 setxattr [vmlinux]: | ||
| 0x80147660 elf_core_dump [vmlinux]: | 0x80147660 elf_core_dump [vmlinux]: | ||
| - | 0x8023d1c0 test_hash [vmlinux]: | + | ... |
| - | 0x803d8df0 __udp4_lib_mcast_deliver.isra.55 [vmlinux]: | + | |
| - | 0x800895e4 sched_domain_debug_one.constprop.66 [vmlinux]: | + | |
| - | 0x8015f668 show_stat [vmlinux]: | + | |
| - | 0x801ac09c autofs4_expire_run [vmlinux]: | + | |
| - | 0x8027d7f4 store_mode [vmlinux]: | + | |
| - | 0x802b9aa4 mtdchar_ioctl [vmlinux]: | + | |
| - | 0x80122880 getxattr [vmlinux]: | + | |
| - | 0x8015f304 meminfo_proc_show [vmlinux]: | + | |
| - | 0x8019e460 exportfs_decode_fh [vmlinux]: | + | |
| - | 0x803696b8 rtnl_newlink [vmlinux]: | + | |
| 0x80396de0 conntrack_pptp_help [vmlinux]: | 0x80396de0 conntrack_pptp_help [vmlinux]: | ||
| </ | </ | ||
| + | |||
| + | ===== CONFIG_FRAME_WARN ===== | ||
| + | This kernel configuration option passes an option to the compiler to cause it to emit a warning when a static stack size for a routine is detected that is larger than the specified threshold. It requires gcc version 4.4 or later in order to work. | ||
| + | |||
| + | The gcc option used is " | ||
| + | |||
| + | By default, CONFIG_FRAME_WARN has the value of **1024**, but you can set it to any value from 0 to 8192. | ||
| + | |||
| + | Here is a sample of build output with this option configured to 256: | ||
| + | ... | ||
| + | CC ipc/msg.o | ||
| + | CC ipc/sem.o | ||
| + | .../ | ||
| + | .../ | ||
| + | .../ | ||
| + | .../ | ||
| + | CC ipc/shm.o | ||
| + | CC ipc/ | ||
| + | ... | ||
| + | |||
| ===== stack_size ===== | ===== stack_size ===== | ||
| Line 111: | Line 110: | ||
| - | ==== CONFIG_DEBUG_STACK_USAGE / CONFIG_DEBUG_STACKOVERFLOW ==== | + | ===== CONFIG_DEBUG_STACK_USAGE / CONFIG_DEBUG_STACKOVERFLOW |
| # dmesg | grep greatest | # dmesg | grep greatest | ||
| < | < | ||
mywiki/linux/linuxstack.1413859027.txt.gz · Last modified: (external edit)
