Linux /proc與/sys目錄分析

proc與sys目錄分析

基於Apollo,gingerbread,公版(LeOs之後還會加一些接口的,不予分析)
具體標準接口,可見linux代碼documents/proc.txt在這裏不做贅述,僅僅對我們解系統問題時用的信息做闡述。
並且很多信息也可以從命令中讀出,那樣看起來更方便並且已經加以分析,往往源數據來自於proc。

/proc/msm_pm_stats

該文件爲MSM在/arch/arm/mach_msm/pm2.c提供,主要描述了PM各種狀態進入次數以及時間,並且統計時間段內落入的次數。
該時間段可以修改,調整時間段間隔、次數等參數。
CONFIG_MSM_IDLE_STATUS_FIRST_BUCKET, COUNT等
共有idle-request, idle-spin, idle-wfi, idle-standalone-power-collapse, idle-failed-standalone-power-collapse, idle-sleep, idle-failed-sleep, idle-power-collapse, idle-failed-power-collapse, suspend, failed-suspend, not-idle
比如suspend可以看出suspend的次數以及時間,這樣可以來判定是不是PM的一些問題。

摘錄部分內容
Clocks against last TCXO shutdown:
Last power collapse voted for TCXO shutdown
idle-request: --進入idle的次數和時間
count: 482052
total_time: 4801.513422569 < 0.000062500: 2612 (0-62499) < 0.000250000: 7850 (62708-249999) < 0.001000000: 28075 (250208-999999) < 0.004000000: 92731 (1000208-3999999) < 0.016000000: 222003 (4000208-15999791) < 0.064000000: 128781 (16000208-19995624) – 落入0.016-0.064s之間的idle次數 < 0.256000000: 0 (0-0) < 1.024000000: 0 (0-0) < 4.096000000: 0 (0-0) >= 4.096000000: 0 (0-0)
suspend: suspend的次數和時間,很清楚可以看到休眠的情況 count: 59 total_time: 3330.154449459 < 1.000000000: 10 (150268555-388610840) < 4.000000000: 3 (1161407471-3151611328) < 16.000000000: 44 (6152343750-10162872314) < 64.000000000: 1 (42738952637-42738952637) < 256.000000000: 0 (0-0) < 1024.000000000: 0 (0-0) < 4096.000000000: 1 (2873943359375-2873943359375) < 16384.000000000: 0 (0-0) < 65536.000000000: 0 (0-0) >= 65536.000000000: 0 (0-0)

/proc/mtd

Apollo用的是emmc,沒有mtd,因此該文件爲空,如lephone上的mtd就是我們從appsbl傳過來的幾個分區。

/proc/sysrq-trigger (sysrq.txt)

很強大的功能,遺憾的是隻能在串口輸出,adb要看的話只好看dmesg了。
常用的 i m t等

in /proc/sys/kernel/sysrq: – 使能sysrq功能
0 - disable sysrq completely
1 - enable all functions of sysr
功能使用方法 echo “command” > /proc/sysrq-trigger
‘b’ - Will immediately reboot the system without syncing or unmounting your disks
‘c’ - Will perform a system crash by a NULL pointer dereference. A crashdump will be taken if configured. //crashdump是不是需要研究一下。
‘d’ - Shows all locks that are held.
‘e’ - Send a SIGTERM to all processes, except for init.
‘f’ - Will call oom_kill to kill a memory hog process.
‘g’ - Used by kgdb on ppc and sh platforms.
‘h’ - Will display help (actually any other key than those listed here will display help. but ‘h’ is easy to remember 😃
‘i’ - Send a SIGKILL to all processes, except for init. //相當於重啓android
‘j’ - Forcibly “Just thaw it” - filesystems frozen by the FIFREEZE ioctl.
‘k’ - Secure Access Key (SAK) Kills all programs on the current virtual console. NOTE: See important comments below in SAK section.
‘l’ - Shows a stack backtrace for all active CPUs.
‘m’ - Will dump current memory info to your console.//memory信息使用情況
‘n’ - Used to make RT tasks nice-able
‘o’ - Will shut your system off (if configured and supported).
‘p’ - Will dump the current registers and flags to your console.
‘q’- Will dump per CPU lists of all armed hrtimers (but NOT regular timer_list timers) and detailed information about all clockevent devices.
‘r’ - Turns off keyboard raw mode and sets it to XLATE.
‘s’ - Will attempt to sync all mounted filesystems.
‘t’ - Will dump a list of current tasks and their information to your console.//所有task的信息
‘u’ - Will attempt to remount all mounted filesystems read-only.
‘v’ - Dumps Voyager SMP processor info to your console.
‘w’ - Dumps tasks that are in uninterruptable (blocked) state.//
‘x’ - Used by xmon interface on ppc/powerpc platforms.
‘z’ - Dump the ftrace buffer
‘0’-‘9’ - Sets the console log level, controlling which kernel messages will be printed to your console. (‘0’, for example would make it so that only emergency messages like PANICs or OOPSes would make it to your console.)

/proc/partitions

這裏對應了emmc內所有的分區以及大小。mmcblk0爲整個emmc card。
major minor #blocks name
179 0 15629312 mmcblk0
179 1 102400 mmcblk0p1
179 2 500 mmcblk0p2
179 3 1500 mmcblk0p3
179 4 1 mmcblk0p4
179 5 1000 mmcblk0p5
179 6 2000 mmcblk0p6
179 7 3072 mmcblk0p7
179 8 5120 mmcblk0p8
179 9 7000 mmcblk0p9
179 10 3072 mmcblk0p10
179 11 3072 mmcblk0p11
179 12 204800 mmcblk0p12
179 13 2097152 mmcblk0p13
179 14 8192 mmcblk0p14
179 15 5120 mmcblk0p15
179 16 40000 mmcblk0p16
179 17 204800 mmcblk0p17
179 18 65536 mmcblk0p18
179 19 1024 mmcblk0p19
179 20 12090368 mmcblk0p20

/proc/diskstats (iostats.txt)

Field 1 – # of reads completed
This is the total number of reads completed successfully.
Field 2 – # of reads merged, field 6 – # of writes merged
Reads and writes which are adjacent to each other may be merged for
efficiency. Thus two 4K reads may become one 8K read before it is
ultimately handed to the disk, and so it will be counted (and queued)
as only one I/O. This field lets you know how often this was done.
Field 3 – # of sectors read
This is the total number of sectors read successfully.
Field 4 – # of milliseconds spent reading
This is the total number of milliseconds spent by all reads (as
measured from __make_request() to end_that_request_last()).
Field 5 – # of writes completed
This is the total number of writes completed successfully.
Field 7 – # of sectors written
This is the total number of sectors written successfully.
Field 8 – # of milliseconds spent writing
This is the total number of milliseconds spent by all writes (as
measured from __make_request() to end_that_request_last()).
Field 9 – # of I/Os currently in progress
The only field that should go to zero. Incremented as requests are
given to appropriate struct request_queue and decremented as they finish.
Field 10 – # of milliseconds spent doing I/Os
This field is increases so long as field 9 is nonzero.
Field 11 – weighted # of milliseconds spent doing I/Os
This field is incremented at each I/O start, I/O completion, I/O
merge, or read of these stats by the number of I/Os in progress
(field 9) times the number of milliseconds spent doing I/O since the
last update of this field. This can provide an easy measure of both
I/O completion time and the backlog that may be accumulating.

1 0 ram0 0 0 0 0 0 0 0 0 0 0 0
1 1 ram1 0 0 0 0 0 0 0 0 0 0 0
1 2 ram2 0 0 0 0 0 0 0 0 0 0 0
1 3 ram3 0 0 0 0 0 0 0 0 0 0 0
1 4 ram4 0 0 0 0 0 0 0 0 0 0 0 1 5 ram5 0 0 0 0 0 0 0 0 0 0 0 1 6 ram6 0 0 0 0 0 0 0 0 0 0 0 1 7 ram7 0 0 0 0 0 0 0 0 0 0 0 7 0 loop0 0 0 0 0 0 0 0 0 0 0 0 7 1 loop1 0 0 0 0 0 0 0 0 0 0 0 7 2 loop2 0 0 0 0 0 0 0 0 0 0 0 7 3 loop3 0 0 0 0 0 0 0 0 0 0 0 7 4 loop4 0 0 0 0 0 0 0 0 0 0 0 7 5 loop5 0 0 0 0 0 0 0 0 0 0 0 7 6 loop6 0 0 0 0 0 0 0 0 0 0 0 7 7 loop7 0 0 0 0 0 0 0 0 0 0 0 179 0 mmcblk0 1883 2626 150173 6830 473 5143 44726 56570 0 7500 63380 179 1 mmcblk0p1 0 0 0 0 0 0 0 0 0 0 0 179 2 mmcblk0p2 0 0 0 0 0 0 0 0 0 0 0 179 3 mmcblk0p3 1 0 8 10 0 0 0 0 0 10 10 179 4 mmcblk0p4 0 0 0 0 0 0 0 0 0 0 0 179 5 mmcblk0p5 0 0 0 0 0 0 0 0 0 0 0 179 6 mmcblk0p6 0 0 0 0 0 0 0 0 0 0 0 179 7 mmcblk0p7 0 0 0 0 0 0 0 0 0 0 0 179 8 mmcblk0p8 0 0 0 0 0 0 0 0 0 0 0 179 9 mmcblk0p9 0 0 0 0 0 0 0 0 0 0 0 179 10 mmcblk0p10 1 0 8 0 26 743 6152 4280 0 330 4280 179 11 mmcblk0p11 0 0 0 0 0 0 0 0 0 0 0 179 12 mmcblk0p12 994 78 76618 4270 0 0 0 0 0 2080 4250 179 13 mmcblk0p13 807 682 64818 2180 420 4398 38544 51790 0 5160 53970 179 14 mmcblk0p14 8 155 328 10 11 2 26 250 0 260 260 179 15 mmcblk0p15 2 0 4 0 0 0 0 0 0 0 0 179 16 mmcblk0p16 0 0 0 0 0 0 0 0 0 0 0 179 17 mmcblk0p17 0 0 0 0 0 0 0 0 0 0 0 179 18 mmcblk0p18 0 0 0 0 0 0 0 0 0 0 0 179 19 mmcblk0p19 0 0 0 0 0 0 0 0 0 0 0 179 20 mmcblk0p20 63 1698 8229 270 4 0 4 250 0 450 520

/proc/crypto

內核使用的所有已安裝的加密密碼及細節.

/proc/yaffs

在apollo裏面沒有yaffs文件系統,用的ext4的。
看看lephone裏面的信息。
YAFFS built:May 17 2011 11:04:05
Device 0 “system” startBlock… 0 endBlock… 1159 totalBytesPerChunk. 2048 nDataBytesPerChunk. 2048 chunkGroupBits… 0 chunkGroupSize… 1 nErasedBlocks… 104 nReservedBlocks… 5 blocksInCheckpoint. 2 nTnodesCreated… 5500 nFreeTnodes… 47 nObjectsCreated… 800 nFreeObjects… 30 nFreeChunks… 6707 nPageWrites… 116 nPageReads… 26056 nBlockErasures… 2 nGCCopies… 0 garbageCollections. 0 passiveGCs… 0 nRetriedWrites… 0 nShortOpCaches… 10 nRetireBlocks… 0 eccFixed… 0 eccUnfixed… 0 tagsEccFixed… 0 tagsEccUnfixed… 0 cacheHits… 0 nDeletedFiles… 0.nUnlinkedFiles… 0 nBackgroudDeletions 0 useNANDECC… 1 isYaffs2… 1 inbandTags… 0
Device 1 “userdata”.,.,
………

/proc/kpageflags

/proc/kpagecount

/proc/kmsg

Kernel log

/proc/softirqs

/proc/version

Linux 版本信息

/proc/uptime

The uptime of the system (seconds), and the amount of time spent in idle process (seconds).
系統開機和idle的時間。

/proc/stat

信息直接看文檔。
cpu 6723 79 6291 782707 484 4 0 0 0 0
cpu0 6723 79 6291 782707 484 4 0 0 0 0
intr 172970 0 93676 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1356 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14927 49 0 0 0 0 0 44208 0 0 0 844 3665 0 0 0 8 0 0 0 0 0 0 0 0 0 2539 794 0 0 955 0 0 0 0 0 0 0 0 0 0 0 0 91 0 9683 0 52 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 95 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 385453
btime 315980647
processes 2600
procs_running 1
procs_blocked 0
softirq 85353 4 39035 0 0 0 0 2567 0 100 43647

/proc/meminfo

具體含義見文檔。這裏需要分析的是,內存信息是否合理,是否有內存過渡使用狀態是system不穩定的原因之一。
MemTotal: 388544 kB MemFree: 206412 kB Buffers: 7008 kB Cached: 74484 kB SwapCached: 0 kB Active: 85848 kB Inactive: 72476 kB Active(anon): 76860 kB Inactive(anon): 288 kB Active(file): 8988 kB Inactive(file): 72188 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 76836 kB Mapped: 33560 kB Shmem: 324 kB Slab: 7968 kB SReclaimable: 3104 kB SUnreclaim: 4864 kB KernelStack: 3016 kB PageTables: 7952 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 194272 kB Committed_AS: 1204456 kB VmallocTotal: 417792 kB VmallocUsed: 84076 kB VmallocChunk: 325636 kB

/proc/interrupts

這個記錄中斷次數,驗證中斷是否發生來驗證硬件軟件問題。
CPU0 0: 0 msm dg_timer 1: 11584 msm gp_timer 20: 0 msm adsp 22: 533 msm smd_dev 27: 1 msm smsm_dev 53: 1717 msm msm_i2c 54: 49 msm msm_i2c 55: 0 msm msm_touchscreen 56: 0 msm msm_touchscreen 60: 4680 msm msm_otg, msm_hsusb 64: 1376 msm spi_qsd 65: 7310 msm spi_qsd 66: 0 msm spi_qsd 69: 3 msm msm_serial1 79: 2172 msm msmdatamover 80: 925 msm MDP 82: 0 msm kgsl 83: 997 msm kgsl 84: 0 msm msm_rotator 85: 0 msm vidc 96: 39 msm msm-sdcc (cmd), msm-sdcc (pio) 98: 7332 msm msm-sdcc (cmd), msm-sdcc (pio) 100: 26 msm msm-sdcc (cmd), msm-sdcc (pio) 102: 0 msm qup_in_intr 103: 0 msm qup_out_intr 104: 9 msm qup_err_intr 155: 8 msmgpio pm8058-irq 168: 201 msmgpio W88 TouchPanel(GWD) 172: 1 msmgpio MHL_cable 246: 1 msmgpio msm-sdccsdiowakeup 275: 1 msmgpio headset_plug 384: 8 pm8058 pmic-keypad 385: 0 pm8058 pmic-keypad-stuck 537: 0 pm8058 msm-sdcc (slot) Err: 0

/proc/devices

列出所有字符和塊設備。

/proc/cpuinfo

Processor : ARMv7 Processor rev 2 (v7l) BogoMIPS : 163.75 Features : swp half thumb fastmult vfp edsp neon vfpv3 CPU implementer : 0x51 CPU architecture: 7 CPU variant : 0x1 CPU part : 0x00f CPU revision : 2
Hardware : QCT MSM8X55 SURF Revision : 0000 Serial : 0000000000000000

/proc/cmdline

這個就是代碼中/device下面boardconfig中的cmdline信息。對我們的用處可能也就是看看串口對不對吧,設備對不對,別的意義也不大。
console=ttyMSM1,115200n8 androidboot.hardware=qcom androidboot.emmc=true androidboot.baseband=msm

/proc/locks

/proc/filesystems

支持的文件系統類型
nodev sysfs nodev rootfs nodev bdev nodev proc nodev cgroup nodev tmpfs nodev debugfs nodev sockfs nodev pipefs nodev anon_inodefs nodev rpc_pipefs nodev devpts ext3 ext2 ext4 nodev ramfs vfat nodev nfs yaffs yaffs2 nodev mtd_inodefs

/proc/slabinfo

slab內存信息,linux一種內存分配,沒研究過。

/proc/vmallocinfo

Vmalloc內存分配信息。裏面有ioremap、user、哪裏分配的等信息,可以看是不是有內存使用不合理的情況。

/proc/zoneinfo

Zone內存信息,沒研究過。

/proc/vmstat

虛擬內存統計信息。

/proc/pagetypeinfo

cat就oops了.

/proc/buddyinfo

和內存碎片有關。

/proc/config.gz

Kernel的config文件,可以看看配置是否有問題等。初期用處多一些。

/proc/kallsyms

內核symbol。

/proc/modules

相當於lsmod

/proc/timer_stats

/proc/timer_list

/proc/iomem

/proc/ioports

/proc/execdomains

/proc/misc

Misc註冊設備。

/proc/fb

Framebuffer

/proc/sn_number

/proc/pcb_version

添加的兩個接口,從modem nv項中讀回來的。 請參照linux_crash&modem_crash。

/proc/wakelocks

結合/sys/power/wake_lock一起分析電源管理睡眠情況使用。

/proc/irq/

該目錄是各個irq的信息。

/proc/cgroups

/proc/sys/kernel/sched_child_run_first

child 在 fork 之後進行調度;此爲默認設置爲0。如果設置爲 0,那麼先調度 parent。

/proc/sys/kernel/sched_rt_period_us

/proc/sys/kernel/sched_rt_runtime_us

這 兩個文件規定了,在以sched_rt_period_us爲一個週期的時間內,所有實時進程的運行時間之和不超過 sched_rt_runtime_us。這兩個文件的默認值是1s和0.95s,表示每秒種爲一個週期,在這個週期中,所有實時進程運行的總時間不超過 0.95秒,剩下的至少0.05秒會留給普通進程。也就是說,實時進程佔有不超過95%的CPU。

/proc/sys/kernel/sched_compat_yield

With this tunable you can make sys_sched_yield() be more aggressive, by moving the yielding task to the last position in the rbtree. The default is 0 (what Ingo Molnar likes), and when you set it to 1 you get what Linux Torvalds proposes.
with sched_compat_yield = 0:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2539 mingo 20 0 1576 252 204 R 50 0.0 0:02.03 loop_yield
2541 mingo 20 0 1576 244 196 R 50 0.0 0:02.05 loop

with sched_compat_yield = 1:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2584 mingo 20 0 1576 248 196 R 99 0.0 0:52.45 loop
2582 mingo 20 0 1576 256 204 R 0 0.0 0:00.00 loop_yield

This tunable is available in 2.6.23 or newer kernel.

/proc/sys/kernel/panic

Reboot的時間,現在默認是0.
The value in this file represents the number of seconds the kernel waits before rebooting on a panic. When you use the software watchdog, the recommended setting is 60. If set to 0, the auto reboot after a kernel panic is disabled, which is the default setting.

/proc/sys/kernel/core_uses_pid

The default coredump filename is “core”. By setting core_uses_pid to 1 (the default is 0), the coredump filename becomes core.PID. Ifcore_patterndoes not include “%p” (default does not) and core_uses_pid is set, then .PID will be appended to the filename.

/proc/sys/kernel/core_pattern

core_pattern is used to specify a core dumpfile pattern name

/proc/sys/kernel/core_pipe_limit

/proc/sys/kernel/tainted

Documentation\sysctl\kernel.txt
內核被污染的情況,比如說GPL污染等。

/proc/sys/kernel/real-root-dev

/proc/sys/kernel/print-fatal-signals

This enables printing of some minimal information about userspace segfaults to the kernel console. This is useful to find early bootup bugs where userspace debugging is very hard. Defaults to off.
0 代表不打開, 1 代表打開。
值得研究一下用法。

/proc/sys/kernel/ctrl-alt-del

/proc/sys/kernel/modprobe

The location where the modprobe binary is located. The kernel uses this program to load modules on demand. The default valueis “/sbin/modprobe”.

/proc/sys/kernel/modules_disabled

阻止啓動後加載更多模塊

/proc/sys/kernel/hotplug

The location where the hotplug policy agent is located. The default value is “/sbin/hotplug”.
在我們的GB上沒有該文件/sbin/hotplug。

/proc/sys/kernel/sg-big-buff

This file shows the size of the generic SCSI device (sg) buffer. You can’t tune it just yet, but you could change it on compile time by editing include/scsi/sg.h and changing the value of SG_BIG_BUFF. However, there shouldn’t be any reason to change this value.
32768 貌似對我們意義不大。

/proc/sys/kernel/sysrq

When running a kernel with SysRq compiled in, this file controls the functions allowed to be invoked via the SysRq key. By default the file contains 1 which means that every possible SysRq request is allowed. Here is the list of all possible values:
0 - disable sysrq completely
1 - enable all functions of sysrq

1 - bitmask of allowed sysrq functions (see below for detailed function description):
2 - enable control of console logging level
4 - enable control of keyboard (SAK, unraw)
8 - enable debugging dumps of processes etc.
16 - enable sync command
32 - enable remount read-only
64 - enable signalling of processes (term, kill, oom-kill)
128 - allow reboot/poweroff
256 - allow nicing of all RT tasks

這個對我們用處很大,需要打開。 設置爲1即可。

/proc/sys/kernel/cad-pid

This tunable can be used to set/get PID of the process that gets the signal when ctrl-alt-del key sequence is pressed. By default it is the init process (PID 1). See alsoctrl-alt-del.

/proc/sys/kernel/threads-max

Gets/sets the limit on the maximum number of running threads system-wide.
線程最大數,我看的GB apollo上是1970.

/proc/sys/kernel/random/

The files in this subdirectory provide an additional interface to the /dev/random device.
ls -l
-r–r--r-- 1 root root 0 11-27 12:49 boot_id
-r–r--r-- 1 root root 0 11-27 12:49 entropy_avail
-r–r--r-- 1 root root 0 11-27 12:49 poolsize
-rw-r–r-- 1 root root 0 11-27 12:49 read_wakeup_threshold
-r–r--r-- 1 root root 0 11-27 12:49 uuid
-rw-r–r-- 1 root root 0 11-27 12:49 write_wakeup_threshold
1 boot_id
This read-only file contains random string like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9. This one was generated once at boot. See also:/proc/sys/kernel/random/uuid.
2 entropy_avail
This read-only file gives the available entropy. Normally, this will be 4096 (bits), a full entropy pool.
3 poolsize
This file gives the size of the entropy pool. Normally, this will be 4096 bits (512 bytes). It can be changed to any value for which an algorithm is available. Currently the choices are: 32, 64, 128, 256, 512, 1024, 2048
4 read_wakeup_threshold
This file contains the number of bits of entropy required for waking up processes that sleep waiting for entropy from /dev/random. The default is 64.
5 uuid
This read-only file contains random string like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9. This one is generated afresh for each read. See also:/proc/sys/kernel/random/boot_id.
6 write_wakeup_threshold
This file contains the number of bits of entropy below which we wake up processes that do a select() or poll() for write access to /dev/random.

/proc/sys/kernel/overflowgid

/proc/sys/kernel/overflowuid

/proc/sys/kernel/pid_max

PID allocation wrap value. When the kernel’s next PID value reaches this value, it wraps back to a minimum PID value. PIDs of value pid_max or larger are not allocated. The default is 32768.

/proc/sys/kernel/panic_on_oops

Controls the kernel’s behaviour when an oops or BUG is encountered.
0 - try to continue operation
1 - delay a few seconds (to give klogd time to record the oops output) and then panic. If thepanicsysctl is also non-zero then the machine will be rebooted.

現在手機默認是1,對我們是有意義的。

/proc/sys/kernel/printk

The four values in printk denote:
console_loglevel - messages with a priority higher than this will be printed to the console
default_message_loglevel - messages without an explicit priority will be printed with this priority
minimum_console_loglevel - minimum (highest) value to which console_loglevel can be set
default_console_loglevel - default value for console_loglevel

eg:7 4 1 7

/proc/sys/kernel/printk_ratelimit 5

/proc/sys/kernel/printk_ratelimit_burst 10

/proc/sys/kernel/printk_delay 0

前者表示當這個值置爲0後隔多少秒後恢復爲1,即等待允許再次打印的時間(秒),後者可能和緩存隊列長度有關,他表示在值爲0之前,可以printk的條目數。系統缺省值爲5和10,也就是在printk_ratelimit()的控制下,每秒可以有兩個輸出。

/proc/sys/kernel/ngroups_max

This file exposes the maximum number of supplementary groups a user can be a member of (kernel’s NGROUPS_MAX) to the userspace. The default value is 65536. This tunable does not seem to be used anywhere in the latest kernels.

/proc/sys/kernel/randomize_va_space

/proc/sys/kernel/max_lock_depth

This tunable limits the amount of deadlock-checking the kernel will do. The default value is 1024.

/proc/sys/kernel/poweroff_cmd

Poweroff位置,/sbin/poweroff GB上沒有,沒用。

/proc/sys/kernel/perf_event_paranoid

/proc/sys/kernel/perf_event_mlock_kb

/proc/sys/kernel/perf_event_max_sample_rate

/proc/sys/kernel/blk_iopoll

/proc/sys/kernel/boot_reason

這個需要研究一下含義。

/proc/sys/kernel/ostype

Linux

/proc/sys/kernel/osrelease

2.6.35.7-perf+

/proc/sys/kernel/version

以上三個加起來就是 ### /proc/version

/proc/sys/kernel/hostname

/proc/sys/kernel/domainname

/proc/sys/kernel/msg* shm*

/proc/sys/vm/overcommit_memory

該文件指定了內核針對內存分配的策略,其值可以是0、1、2。
0, 表示內核將檢查是否有足夠的可用內存供應用進程使用;如果有足夠的可用內存,內存申請允許;否則,內存申請失敗,並把錯誤返回給應用進程。
1, 表示內核允許分配所有的物理內存,而不管當前的內存狀態如何。
2, 表示內核允許分配超過所有物理內存和交換空間總和的內存(參照overcommit_ratio)。
缺省設置:0
GB上設置值爲1.

/proc/sys/vm/overcommit_ratio

上個值爲2時,該值有效。內存可過量分配的百分比。 GB上爲50,不過因爲上值爲1,則無效。

/proc/sys/vm/panic_on_oom

Linux 有一個保護機制,OOM Killer ,用於避免 Linux 在內存不足的時候不至於出太嚴重的問題,把無關緊要的進程殺掉,有些壯士斷腕的意思。
當值爲0的時候,在OOM的時候會調用OOM Killer,大部分情況下,會殺掉導致OOM的進程,然後系統恢復
當值爲1的時候,發生了OOM以後,如果有mempolicy/cpusets的進程限制,而這些nodes導致了內存問題的時候,OOM Killer會幹掉這些中的一個,系統也會恢復
當值爲2的時候,OOM後必然panic

/proc/sys/vm/oom_kill_allocating_task

殺死的進程未必是 引起 OOM的進程,除非/proc/sys/vm/oom_kill_allocating_task被設爲了1,當/proc/sys/vm/oom_kill_allocating_task未被設置爲1(缺省爲0)時,內核自己來選擇那個進程(如根據oom_score)被殺,通常消耗memory最多的那個.

/proc/sys/vm/oom_dump_tasks

當oom killer被引發的時候,將進程的信息輸出,包括pid、uid、tgid、vm、rss、cpu等
默認爲0

/proc/sys/vm/page-cluster

每次swap in或者swap out操作多少內存頁, 該數字爲2的指數。
GB上是3.

/proc/sys/vm/dirty_background_ratio

這個參數控制文件系統的pdflush進程,在何時刷新磁盤。單位是百分比,表示系統內存的百分比,意思是當寫緩衝使用到系統內存多少的時候,pdflush開始向磁盤寫出數據。增大之會使用更多系統內存用於磁盤寫緩衝,也可以極大提高系統的寫性能。但是,當你需要持續、恆定的寫入場合時, 應該降低其數值,一般啓動上缺省是 5。
GB上是5.

/proc/sys/vm/dirty_background_bytes

If dirty_background_bytes is written, dirty_background_ratio becomes a function of its value (dirty_background_bytes / the amount of dirtyable system memory).
GB上是0.所以用的是ratio,而不用bytes。

/proc/sys/vm/dirty_ratio

這個參數控制文件系統的文件系統寫緩衝區的大小,單位是百分比,表示系統內存的百分比,表示當寫緩衝使用到系統內存多少的時候,開始向磁盤寫出數據。增大之會使用更多系統內存用於磁盤寫緩衝,也可以極大提高系統的寫性能。但是,當你需要持續、恆定的寫入場合時,應該降低其數值。
GB上是20.
注:dirty_background_ratio和dirty_ratio的區別在於一個是與pdflash判斷相關,一個是與自身進程相關。

曾經的USB長時間讀寫文件時會導致pc端給usb發送reset信號導致手機斷連接,解決該問題的辦法就是將dirty_ratio改小爲4,爲的就是fs讀寫文件flash迅速。

/proc/sys/vm/dirty_bytes

GB上爲0.用的是dirty_ratio,不用bytes。

/proc/sys/vm/dirty_writeback_centisecs

這個參數控制內核的髒數據刷新進程pdflush的運行間隔。單位是 1/100 秒。缺省數值是500,也就是 5 秒。如果你的系統是持續地寫入動作,那麼實際上還是降低這個數值比較好,這樣可以把尖峯的寫操作削平成多次寫操作。
GB裏面是60000.
這個值是不是太大了? 就像dirty_ratio一樣也需要改小一些對usb傳輸大文件有利?

/proc/sys/vm/dirty_expire_centisecs

這個參數聲明Linux內核寫緩衝區裏面的髒數據多“舊”了之後,pdflush 進程就開始考慮寫到磁盤中去。單位是 1/100秒。缺省是 30000,也就是 30 秒的數據就算舊了,將會刷新磁盤。對於特別重載的寫操作來說,這個值適當縮小也是好的,但也不能縮小太多,因爲縮小太多也會導致IO提高太快。建議設置爲 1500,也就是15秒算舊。
GB裏面的是60000.

/proc/sys/vm/nr_pdflush_threads

該文件表示當前正在運行的pdflush進程數量,在I/O負載高的情況下,內核會自動增加更多的pdflush進程。

/proc/sys/vm/swappiness

swappiness的值的大小對如何使用swap分區是有着很大的聯繫的。swappiness=0的時候表示最大限度使用物理內存,然後纔是 swap空間,swappiness=100的時候表示積極的使用swap分區,並且把內存上的數據及時的搬運到swap空間裏面。此處可以使用echo 來修改該值,但是這種修改只是臨時的,系統重啓後還會恢復到60,要永久修改
GB上是60. 不過android有swap這個東西嗎?沒有把~

/proc/sys/vm/lowmem_reserve_ratio

Low memory/high memory/dma 是 linux 對內存進行的分類 DMA:0x00000000 - 0x00999999 (0-16M) LowMem:0x01000000 - 0x03799999 (16M - 896M) HighMem:0x03800000 - … 用戶用的內存一般是 high memory,low memory 是給內核用的。low memory 享有某些 特權,例如無法被寫入 swap 等等,但是當 low memory 用光的時候,系統就完蛋了,因此, low memory 要省着點用,這個選項就是來調節這個的,調節內核對於 low memory 的吝嗇程 度 5、lower_zone_protection 和 lowmem_reserve_ratio 一樣的功能,保留 low memory 中的連續內存,單位是 M, 默認是 0 的時候,爲 16M,可以設置大一點。

/proc/sys/vm/drop_caches

Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory,causing that memory to become free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are not freeable, the user should run “sync” first in order to make sure all cached objects are freed.
This tunable was added in 2.6.16.

這個可以釋放內存,默認爲0,如果echo 3 到該文件,明顯的cat /proc/meminfo free內存會增大,cache內存被釋放。

/proc/sys/vm/min_free_kbytes

/proc/sys/vm/min_free_order_shift

/proc/sys/vm/percpu_pagelist_fraction

/proc/sys/vm/max_map_count

/proc/sys/vm/laptop_mode

/proc/sys/vm/block_dump

/proc/sys/vm/vfs_cache_pressure

/proc/sys/vm/mmap_min_addr

/proc/sys/vm/scan_unevictable_pages

/proc/sys/fs/

/proc/sys/debug/

/proc/sys/dev/

/proc/sys/net/

/proc/sys/sunrpc/

/proc/bus/input/handlers

/proc/bus/input/devices

在/proc/bus/input下面創建兩個節點devices和handlers,通過打印這兩個節點的內容可以查看輸入子系統的設備驅動層信息和處理層信息。

這是GB apollo上的handlers信息。
N: Number=0 Name=kbd N: Number=1 Name=sysrq (filter) N: Number=2 Name=evdev Minor=64 N: Number=3 Name=cpufreq_ond

這是GB apollo上的input設備信息。
I: Bus=0019 Vendor=0001 Product=0001 Version=0001 N: Name=“surf_keypad” P: Phys=surf_keypad/input0 S: Sysfs=/devices/i2c-6/6-0055/pm8058-keypad/input/input0 U: Uniq= H: Handlers=kbd event0 cpufreq B: EV=13 B: KEY=e00 0 0 0 c0000 18 58000000 0 B: MSC=10
I: Bus=0000 Vendor=0000 Product=0000 Version=0000 N: Name=“msm-touchscreen” P: Phys= S: Sysfs=/devices/i2c-7/7-0055/marimba_tsadc/msm_touchscreen/input/input1 U: Uniq= H: Handlers=event1 cpufreq B: EV=b B: KEY=400 0 0 0 0 0 0 0 0 0 0 B: ABS=1000003
I: Bus=0000 Vendor=5413 Product=0001 Version=0002 N: Name=“W88_CTP” P: Phys=/dev/w88ctp S: Sysfs=/devices/virtual/input/input2 U: Uniq= H: Handlers=event2 cpufreq B: EV=b B: KEY=400 0 4 0 0 0 0 0 0 0 0 B: ABS=650100 1000003
I: Bus=0000 Vendor=0001 Product=0001 Version=0001 N: Name=“7k_handset” P: Phys= S: Sysfs=/devices/virtual/input/input3 U: Uniq= H: Handlers=kbd event3 cpufreq B: EV=23 B: KEY=1c0800 0 0 0 B: SW=14

/proc/tty/

tty的信息,這個需要的看一下就ok了

/proc/driver/rtc

rtc_time : 04:01:39 rtc_date : 1980-01-06 alrm_time : 00:00:00 alrm_date : 1900-01-** alarm_IRQ : no alrm_pending : no 24hr : yes 這是GB apollo上的rtc信息,這個應該可以檢查一下是否正確。

/proc/driver/snd-page-alloc

/proc/fs/

該目錄下有fs的信息,比如在ext4目錄下有幾個mmc分區的信息。

/proc/sysvipc/

/proc//

下面很多信息很有意義。
當用ps看到那個task有問題的時候可以進來看看該task的問題。

比較有用的幾個文件。

Status – 狀態信息
Stack – 棧信息

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章