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 – 栈信息

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值