mywiki:linux:linuxstack
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| mywiki:linux:linuxstack [2014/07/20 22:53] – external edit 127.0.0.1 | 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). | ||
| + | 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* < | ||
| + | |||
| + | $CROSS_COMPILE)objdump -d vmlinux | scripts/ | ||
| - | $(CROSS_COMPILE)objdump -d vmlinux | scripts/ | + | Example: |
| - | $ arm-eabi-objdummp | + | * mips-openwrt-linux-objdump |
| - | $ cat vmlinux-arm.S | + | |
| + | Its output like below: | ||
| < | < | ||
| - | 0x0012c858 nlmclnt_reclaim | + | 0x803feed4 match [vmlinux]: 3184 |
| - | 0x0025748c do_tcp_getsockopt.clone.11 [vmlinux-arm.o]: 552 | + | 0x803fedc8 mangle_http_header.constprop.2 [vmlinux]: 2096 |
| - | 0x00258d04 do_tcp_setsockopt.clone.14 | + | 0x80045da8 mtsched_proc_write |
| - | 0x000b2db4 | + | 0x801119c0 |
| - | 0x00138744 semctl_main.clone.7 | + | 0x802fa7ac pce_rule_write |
| - | 0x00138ec4 sys_semtimedop | + | 0x8033daec of_get_dma_window |
| - | 0x000c5618 default_file_splice_read | + | 0x80110c78 do_select |
| - | 0x00251de4 do_ip_setsockopt.clone.22 | + | 0x802ed918 GSW_MulticastRouterPortRemove |
| - | 0x00191fd4 extract_buf | + | 0x802edd68 GSW_MulticastSnoopCfgSet |
| - | 0x0019bc24 loop_get_status_old | + | ... |
| - | 0x000e6f88 do_task_stat | + | 0x8023ade4 test_comp |
| - | 0x0019b8f0 loop_set_status_old | + | 0x8022b4e0 SyS_semtimedop |
| - | 0x002078f0 snd_ctl_elem_add_user | + | 0x80038ff8 dma_build_device_chan_tbl |
| - | 0x0026267c tcp_make_synack | + | 0x801298ac default_file_splice_read |
| - | 0x00127be4 nfs_dns_parse | + | 0x8023b690 __test_skcipher |
| - | 0x000b2240 do_select | + | 0x80163cd0 elf_kcore_store_hdr |
| - | 0x001f6f10 mmc_blk_issue_rw_rq | + | ... |
| - | 0x001726a0 fb_set_var | + | 0x80129c08 vmsplice_to_pipe [vmlinux]: 368 |
| - | 0x000c58d0 __generic_file_splice_read | + | 0x801aabc8 autofs4_notify_daemon |
| - | 0x0022a074 dev_seq_printf_stats | + | 0x8034c8b8 skb_splice_bits |
| - | 0x0006383c tracing_splice_read_pipe | + | 0x800c2c3c show_free_areas |
| - | 0x000c53c8 vmsplice_to_pipe | + | 0x8037053c dev_seq_printf_stats |
| - | 0x002512b4 | + | 0x803b0e8c do_ip_setsockopt.isra.17 [vmlinux]: 344 |
| - | 0x00225f68 skb_splice_bits | + | 0x80592c94 init_posix_timers |
| + | 0x801111ac core_sys_select | ||
| + | 0x8030adb4 tmu_proc_tmu_cascade_write | ||
| + | 0x803b0214 | ||
| + | 0x80122c88 setxattr | ||
| + | 0x80147660 elf_core_dump [vmlinux]: | ||
| + | ... | ||
| + | 0x80396de0 conntrack_pptp_help [vmlinux]: 304 | ||
| </ | </ | ||
| + | |||
| + | ===== 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 76: | 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.1405868011.txt.gz · Last modified: (external edit)
