Perseverance and Passion.

2019-05-16
一次有趣的High load average排查暨深刻理解Linux系统负载

当Linux服务运行慢的时候,我们一般都是用top命令看看当前CPU使用率以及哪些进程占用了资源等。资深一些管理员,会通过查看load average来查看系统负载以评估系统是越来越慢还是会越来越快。正常情况下,系统没有活跃进程时,系统的负载是0, 如下所示(用uptime):

1
2
# uptime
03:07am up 0:38, 2 users, load average: 0.00, 0.00, 0.02

可是有一次有台机会变慢,load average很高,但是CPU 使用率接近于0,如下所示:

1
2
3
4
5
6
top - 05:15:28 up  2:25,  2 users,  load average: 18.44, 18.47, 18.32
Tasks: 144 total, 1 running, 143 sleeping, 0 stopped, 0 zombie
%Cpu0 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu1 : 0.0 us, 0.8 sy, 0.0 ni, 99.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu2 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu3 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

如果是使用vmstats/iostat,都没办法发现是什么导致High load average和机器变慢。在大量Google之后,最终怀疑到是因为有一个NFS mount的服务器可能down了,大量的df进程导致系统High load average,下面我们细细分析个中原因。

Read More

2019-05-14
Linux虚拟内存介绍以及glibc内存管理机制窥探

Long ago, I have presentd an overview of virtual memory in Linux kernel and memory memory in glibc. Now i am lazy to write these again, so I try to upload the PPT in images. As you know, each pages has details knowledge could be digged into, so you have further view, please google the keywords.

Overview of VM system in Linux

VM

Read More

2017-08-02
Cscope Usage

Actually the source insight is the fist choice code viewing tool for me, but it requires license and in Linux the vim is the powerful editor for me. So to better understanding the code, cscope is the best choice for me to read code in vim. Now i used the cscope more and more often.

Generate the cscope meta data

Enter below commands at the top dir of the project, and then cscope.out will be generated:

find . -name “*.h” -o -name “*.c” -o -name “*.cc” -o -name “*.cpp” > cscope.files
cscope -bqR -i cscope.files

More parameters you can refer to cscope -h.

Read More

2017-07-31
Advanced GDB Usage

This Page was a summary of the advanced gdb usge in daily work, for the basic usage of gdb will not being described here.

1. Advanced commands in using

gdb> info share - show the shared libraries load by process.
gdb> until (line number) - run until to the line number in case you want to break out the while&for loop.
gdb> finish - run out of the this function call.
gdb> call (function name) - call a function in current context.
gdb> disas (function name) - check the assembly code for a function.
gdb> run (arguments) - run the program with arguments.
gdb> bt - get the call stack for current thread.
gdb> frame (stack number) - change stack frame to specfic function call.
gdb> info regs - show the values of current registers.
gdb> list filename:line - list the code of filename:line
gdb> info - list all info sub commands and which are helpful.

Read More

2017-07-30
开篇

最近闲下来有空想一些东西,至今工作已经5年了。5年之际,除了工作上得到一些小许的认可,其他好像无其他。脑海时常有一个想法,至今为止我在自己维系生计的技术方面有什么积累吗?有时候和一些小伙子侃侃而谈,可内心总觉得空虚,主要还是没有积累。查看各身边大牛,技术博客好像是必不可少的东西,即是一种积累也是一种展示内容的地方。

于是乎调研了一些大牛在哪写博客:CSDN,博客园等等,可是各平台水平参次不齐。想想自己只是想要有个地方可以积累知识,作为程序员最好的方式是自己可以控制运维。偶然间发现GitHub Pages,这种本来用来作为项目说明网页的东西,被一些大牛整成了Blog平台。虽然网络上有人批判这种行为,说以国人的脾性,很快这里将会乌烟瘴气,然后GitHub就会关闭中国的Access,然这些对于我们个人是没有办法控制的。

Read More