2022年Linux操作系统性能调优_了解系统 .pdf
LinuxLinux.”.task_struct,(state):lTASK_RUNNINGCPU()lTASK_INTERRUPTIBLE(TASK_RUNNING)lTASK_UNINTERRUPTIBLETASK_INTERRUPTIBLEstopTASK_UNTERRUPITBLEI/OlTASK_STOPPEDSIGSTOP,SIGTSTP,SIGTTIN SIGTTOUSIGCONTTASK_RUNNINGlTASK_TRACEDdebugger,TASK_TRACED名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 16 页 -lEXIT_ZOMBIE,wait4()waitpid()wait(),lEXIT_DEAD.wait4()waitpid()Process statetopZ(Zombie)killinit,Linuxshellfork()fork()PID()exec()()名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 16 页 -,(Copy On Write).exit(),wait(),wait(),Linuxwait()RAMContent SwitchCPU,CPU(Content)process address space(),:名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 16 页 -():lText Segment,lData Segment:lData,lBBS0lHeap()malloc()()free(),lStack Segment,:static.,/:,Data,BBS,Heap-,”,名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 16 页 -()(),Linux()Linux(Virtual Memory System)x86,:l”.l,32(64),4G0 x000000000 xffffffff,l3264(MMU);,:1632,GDTGDT,CPU,ds,cs,ss,(),GDTgdtrLinux0,4GB()0 x00000000,:Linux名师资料总结-精品资料欢迎下载-名师精心整理-第 5 页,共 16 页 -.(0 x7b:0 x80495b0)1)TI,GDT2)index.index*8(),gdtr.3)BaseLinuxRAM()RAM,RAM,cr3.10Directory10Table,12OffsetOffsetoffset12,4k(0 x80495b0)名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 16 页 -,Linux4GB3GB1GB,1GBRAM32CPU,ISA:RAM16MLinux 2.63lZONE_DMA16MBISADMAlZONE_NORMAL16MB896MB”4GB,lZONE_HIGHMEM896MB896MB896MB4GB,名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 16 页 -(),Linux,4MB,2MB,1MB,512KB,256KB,128KB,64KB,32KB,16KB,8KB,4KB(n),Linux,4MB,4KB111,2,4,8,16,32,64,128,256,512102410244MB16,16*4096(4096),1616*2*40963216:1MB(256),2565121MB2562561MB512,-10241024256,768512512,2565121024名师资料总结-精品资料欢迎下载-名师精心整理-第 8 页,共 16 页 -,n2n,4n,4MB:DRAM,(,mp3,)Slab,4K24KBLinuxSlabSlabSlab()Slab(Slab)slabSlabSlabSlabSlab名师资料总结-精品资料欢迎下载-名师精心整理-第 9 页,共 16 页 -slab,slabslab(),:RAMRAMLinux(PFRA)”PFRA,PFRA:,n()nnnnnn(1)ntmpfs(2)nnnn(),n(slab)n1:”(,名师资料总结-精品资料欢迎下载-名师精心整理-第 10 页,共 16 页 -)”2:”,”,PFRA:l”l,FPRAlPFRAl”(LRU)PFRA”PFRAPFRALRUkswapdKswapd,(page_high)Kswapd:heapstack;,kswapd,RAMkswapd(swappiness),60/proc/sys/vm/swappiness(pageoutswap out):page outswap outpage out();swap outswap,LinuxLinux,名师资料总结-精品资料欢迎下载-名师精心整理-第 11 页,共 16 页 -RAM,LinuxkswapdRAM,4KB0;,32767”,32768()gettyRAMPLinux50%LinuxLinuxLinux名师资料总结-精品资料欢迎下载-名师精心整理-第 12 页,共 16 页 -LinuxLinuxLinuxFATJFS,Linuxext2ext3LinuxReiserFS(Virtual Filesystem)(Virtual Filesystem Switch,VFS)VFS,shell:$cp/floppy/TEST/tmp/test/floppy/MS-DOS,/tmpext2cp/floopy/TEST/tmp/test,cpVFS,名师资料总结-精品资料欢迎下载-名师精心整理-第 13 页,共 16 页 -:(metadata),fsckGB(journal area):;,I/O()I/O()fsck()I/OB+名师资料总结-精品资料欢迎下载-名师精心整理-第 14 页,共 16 页 -EXT2EXT3ReriserFSJFS(Journal File System)XFSlLinuxhttp:/ Slabhttp:/ Virtual Memory RedHathttp:/ 15 页,共 16 页 -lLinux 2.6http:/ 16 页,共 16 页 -