View the Linux process CPU high specific thread stack (not interrupt program) __linux

Source: Internet
Author: User
Tags usleep

1, Top command, to find the highest CPU-consuming process

$ top top-20:11:45 up 850 days, 1:18, 3 users, load average:1.04, 1.01, 0.99 tasks:61 Total, 1 running, SLE eping, 0 stopped, 0 zombie Cpu (s): 1.4% us, 0.1% sy, 0.0% ni, 98.3% ID, 0.1% wa, 0.0% Hi, 0.2% si mem:16418172 K Total, 15693376k used, 724796k free, 1146696k buffers swap:10223608k total, 0k used, 10223608k free, 12537692                                                                
K Cached PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND                                                        
    24714 ztgame 0 1409m 1.2g 4252 S 99.6 7.4 2390:57 imvchannelserve                                                                   
    1 Root 0 4772 520 432 S 0.0 0.0 0:03.43 Init                                                            
    2 root RT 0 0 0 0 S 0.0 0.0 0:05.75 migration/0 3 Root 0 0 0 S 0.0 0.0 5:22.97 Ksoftir                    qd/0                                        
    4 root RT 0 0 0 0 S 0.0 0.0 0:07.90 MIGRATION/1 5 Root 0 0 0 S 0.0 0.0 0:00.27 KSOFTIRQD /1 6 root RT 0 0 0 0 S 0.0 0.0 0:04.0 7 MIGRATION/2 7 Root 0 0 0 S 0.0 0    .0 0:00.47 KSOFTIRQD/2 8 root RT 0 0 0     0 S 0.0 0.0 0:04.00 MIGRATION/3 9 Root 34 19     0 0 0 S 0.0 0.0 0:00.33 KSOFTIRQD/3


2, through the TOP-H-p process ID, to find the specific thread occupancy, shift+h can open the closed thread display

$ top-h-P 24714 top-20:15:30 up 850 days, 1:22, 3 users, load average:1.26, 1.09, 1.02 tasks:16 total, 1 Runn ING, sleeping, 0 stopped, 0 zombie Cpu (s): 24.8% us, 0.3% sy, 0.0% ni, 73.1% ID, 0.0% wa, 0.0% Hi, 1.8% si Me m:16418172k Total, 15701376k used, 716796k free, 1146704k buffers swap:10223608k total, 0k used, 10223608k fr                                                                
EE, 12546048k cached PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND                                                        
24729 ztgame 0 1409m 1.2g 4252 R 97.0 7.4 2307:22 imvchannelserve                                                        
24721 ztgame 0 1409m 1.2g 4252 S 2.0 7.4 84:22.40 Imvchannelserve 24714 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:03.80 Imvcha Nnelserve 24716 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:0    0.00 Imvchannelserve                                                    
24717 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.04 Imvchann Elserve 24718 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.  Imvchannelserve 24719 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.08 imvchannelserve 24720 ztgame 0 1409m 1.2g 42 0.0 7.4 0:00.01 imvchannelserve 24722 ztgame 15 0 14    09m 1.2g 4252 S 0.0 7.4 0:00.00 imvchannelserve 24723 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 imvchannelserve 247                                                        
Ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.01 Imvchannelserve    24725 Ztgame0 1409m 1.2g 4252 S 0.0 7.4 0:09.83 imvchannelserve 24726                                                        
Ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 Imvchannelserve                                                        
24727 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.76 Imvchannelserve                                                        
24728 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 0:00.53 Imvchannelserve                                                         24730 ztgame 0 1409m 1.2g 4252 S 0.0 7.4 2:42.18 Imvchannelserve

3, through the command pstack process ID display thread stack, LWP 24729 corresponding thread ID of the stack, is to occupy the highest CPU stack, can be specific analysis of what the cause.

$ pstack 24714 Thread (thread 1084229984 (LWP 24716)): #0 0x00000039c5a901d5 in __nanosleep_nocancel () from/lib64/tl
S/libc.so.6 #1 0x00000039c5ac3058 in Usleep () from/lib64/tls/libc.so.6 #2 0x00000000005ebe10 in Zverifythread::run () 
#3 0x00000000005e9d29 in Zthread::threadfunc () #4 0x00000039c6106137 in Start_thread () from/lib64/tls/libpthread.so.0 #5 0x00000039c5ac9883 in Clone () from/lib64/tls/libc.so.6 thread (thread 1094719840 (LWP 24717)): #0 0x00000039c5a 901d5 in __nanosleep_nocancel () from/lib64/tls/libc.so.6 #1 0x00000039c5ac3058 in Usleep () from/lib64/tls/libc.so.6 # 2 0x00000000005ebe10 in Zverifythread::run () #3 0x00000000005e9d29 in Zthread::threadfunc () #4 0x00000039c6106137 in Start_thread () from/lib64/tls/libpthread.so.0 #5 0x00000039c5ac9883 in Clone () from/lib64/tls/libc.so.6 thread (Th Read 1105209696 (LWP 24718)): #0 0x00000039c5a901d5 in __nanosleep_nocancel () from/lib64/tls/libc.so.6 #1 0x00000039c5 ac3058 in Usleep () from /lib64/tls/libc.so.6 #2 0x00000000005ebe10 in Zverifythread::run () #3 0x00000000005e9d29 in Zthread::threadfunc () #4 0x00000039c6106137 in Start_thread () from/lib64/tls/libpthread.so.0 #5 0x00000039c5ac9883 in Clone () from/lib64/tls/ Libc.so.6 thread 1115699552 (LWP 24719): #0 0x00000039c5a901d5 in __nanosleep_nocancel () from/lib64/tls/lib C.so.6 #1 0x00000039c5ac3058 in Usleep () from/lib64/tls/libc.so.6 #2 0x00000000005ebe10 in Zverifythread::run () #3 0  X00000000005e9d29 in Zthread::threadfunc () #4 0x00000039c6106137 in Start_thread () from/lib64/tls/libpthread.so.0 #5 0x00000039c5ac9883 in Clone () from/lib64/tls/libc.so.6 thread 3 (thread 1220598112 (LWP 24729)): #0 0x00000039c5a71e87 In memset () from/lib64/tls/libc.so.6 #1 0x00000000004fa591 in Channeltask::forwardtoclientbymedia () #2 0x000000000050 6220 in Channeltask::p arseclientmsg_normal () #3 0x000000000051ef55 in Channeltask::p arseclientmsg () #4 0x000000000051f 070 in CHANNELTASK::CMDMSgparse_forward () #5 0x000000000051f1d1 in Channeltask::cmdmsgparse () #6 0x000000000051f414 in ChannelTask::p rocesscmd () #7 0x0000000000523ea8 in Channeltaskmanager::p rocesscmd () #8 0x0000000000525ddd in Channeltimetick::run () #9 0x00 000000005e9d29 in Zthread::threadfunc () #10 0x00000039c6106137 in Start_thread () from/lib64/tls/libpthread.so.0 #11 0x0 0000039c5ac9883 in Clone () from/lib64/tls/libc.so.6 thread 2 (thread 1231087968 (LWP 24730)): #0 0x00000039c610af8b in __lll_mutex_lock_wait () #1 0x0000000000000001 in?? () #2 0x0000000000000065 in?? () #3 0x00000039c6107d87 in Pthread_mutex_lock () from/lib64/tls/libpthread.so.0 #4 0x0000003a500ae29e in operator Dele Te () from/usr/lib64/libstdc++.so.6 #5 0x000000000053f59d in channelloadclient::p rocesscmd_db () #6 0x00000000005986c9 In gameappclient::p rocesstaskcmd_db () #7 0x00000039c5a901e3 in __nanosleep_nocancel () from/lib64/tls/libc.so.6 #8 0x0 000000000000000 in?? () thread 1 (thread 182894183104 (LWP24714): #0 0x00000039c5ac9c5c in epoll_wait () from/lib64/tls/libc.so.6 #1 0X0000000000620CAC in ZTCPServer::accept () #2 0x00000000005f9c0d in Znetservice::servicecallback () #3 0x00000000005f89e3 in Zservice::main () #4 0x0000000000564 298 in Main ()


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.