View the Linux process CPU too high specific thread stacks (without interrupting the program)

Source: Internet
Author: User
Tags usleep

1. Top command, find the process that consumes the highest CPU

$ 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, sleeping, 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:16418172k Total, 15693376k used, 724796k free, 1146696k buffers
swap:10223608k total,0k used, 10223608k free, 12537692k cached

PID USER PR NI VIRT RES SHR S%cpu%memtime+ COMMAND
24714 ztgame16 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 S 0.0 0.0 0:05.75 migration/0
3 root (S) 0.0 0.0 5:22.97 ksoftirqd/0
4 root RT 0 S 0.0 0.0 0:07.90 MIGRATION/1
5 root (S) 0.0 0.0 0:00.27 KSOFTIRQD/1
6 root RT 0 S 0.0 0.0 0:04.07 MIGRATION/2
7 root (S) 0.0 0.0 0:00.47 KSOFTIRQD/2
8 root RT 0 S 0.0 0.0 0:04.00 MIGRATION/3
9 root (S) 0.0 0.0 0:00.33 KSOFTIRQD/3


2, through TOP-H-p process ID, find the specific thread occupancy, shift+h can turn off the 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 running, 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
mem:16418172k Total, 15701376k used, 716796k free, 1146704k buffers
swap:10223608k total,0k used, 10223608k free, 12546048k cached

PID USER PR NI VIRT RES SHR S%cpu%memtime+ COMMAND
24729 ztgame16 0 1409m 1.2g 4252 R 97.0 7.4 2307:22 imvchannelserve
24721 ztgame15 0 1409m 1.2g 4252 S 2.0 7.4 84:22.40 Imvchannelserve
24714 ztgame16 0 1409m 1.2g 4252 S 0.0 7.4 0:03.80 Imvchannelserve
24716 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 Imvchannelserve
24717 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.04 Imvchannelserve
24718 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 Imvchannelserve
24719 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.08 Imvchannelserve
24720 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.01 Imvchannelserve
24722 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 Imvchannelserve
24723 ztgame16 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 Imvchannelserve
24724 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.01 Imvchannelserve
24725 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:09.83 Imvchannelserve
24726 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 Imvchannelserve
24727 ztgame15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.76 Imvchannelserve
24728 ztgame16 0 1409m 1.2g 4252 S 0.0 7.4 0:00.53 Imvchannelserve
24730 ztgame16 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 to the thread ID stack, is the highest CPU stack, you can specifically analyze what caused the cause.

$ pstack 24714
Thread (thread 1084229984 (LWP 24716)):
#0 0x00000039c5a901d5 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 (thread 1094719840 (LWP 24717)):
#0 0x00000039c5a901d5 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 1105209696 (LWP 24718):
#0 0x00000039c5a901d5 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 1115699552 (LWP 24719):
#0 0x00000039c5a901d5 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 3 (thread 1220598112 (LWP 24729)):
#0 0x00000039c5a71e87 in memset () from/lib64/tls/libc.so.6
#1 0x00000000004fa591 in Channeltask::forwardtoclientbymedia ()
#2 0x0000000000506220 in Channeltask::p arseclientmsg_normal ()
#3 0x000000000051ef55 in Channeltask::p arseclientmsg ()
#4 0x000000000051f070 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 0x00000000005e9d29 in Zthread::threadfunc ()
#10 0x00000039c6106137 in Start_thread () from/lib64/tls/libpthread.so.0
#11 0x00000039c5ac9883 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 delete () 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 0x0000000000000000 in?? ()
Thread 1 (thread 182894183104 (LWP 24714)):
#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 0x0000000000564298 in Main ()


Permanent update of this article address: http://www.linuxdiyf.com/linux/18227.html

View the Linux process CPU too high specific thread stacks (without interrupting the program)

Related Article

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.