Documentation
¶
Overview ¶
Controlling which mappings are written to the core dump Since kernel 2.6.23, the Linux-specific /proc/pid/coredump_filter file can be used to control which memory segments are written to the core dump file in the event that a core dump is performed for the process with the corresponding process ID.
The value in the file is a bit mask of memory mapping types (see mmap(2)). If a bit is set in the mask, then memory mappings of the corresponding type are dumped; otherwise they are not dumped. The bits in this file have the following meanings:
bit 0 Dump anonymous private mappings. bit 1 Dump anonymous shared mappings. bit 2 Dump file-backed private mappings. bit 3 Dump file-backed shared mappings. bit 4 (since Linux 2.6.24) Dump ELF headers. bit 5 (since Linux 2.6.28) Dump private huge pages. bit 6 (since Linux 2.6.28) Dump shared huge pages. bit 7 (since Linux 4.4) Dump private DAX pages. bit 8 (since Linux 4.4) Dump shared DAX pages.
By default, the following bits are set: 0, 1, 4 (if the CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS kernel configuration option is enabled), and 5. This default can be modified at boot time using the coredump_filter boot option.
The value of this file is displayed in hexadecimal. (The default value is thus displayed as 33.)
Memory-mapped I/O pages such as frame buffer are never dumped, and virtual DSO pages are always dumped, regardless of the coredump_filter value.
A child process created via fork(2) inherits its parent's coredump_filter value; the coredump_filter value is preserved across an execve(2).
It can be useful to set coredump_filter in the parent shell before running a program, for example:
$ echo 0x7 > /proc/self/coredump_filter $ ./some_program
This file is provided only if the kernel was built with the CON‐ FIG_ELF_CORE configuration option.
http://man7.org/linux/man-pages/man7/user_namespaces.7.html 除了把 uid 改为 gid,所有地方和 uid_map 的相同
在内存不足(OOM)的情况下,系统根据各个进程的该文件的值来权衡要杀死的进程。 内核使用这个进行进程的 oom_score 值的位移操作:有效值在 -16 到 +15 的范围内,再加上特殊值 -17,它会为此进程完全禁用OOM查杀。 正分会增加这个过程被 OOM 杀手杀死的可能性; 负分数降低了可能性。 该文件的默认值为0; 新进程继承其父进程的oom_adj设置。 进程必须具有特权(CAP_SYS_RESOURCE)才能更新此文件。 从Linux 2.6.36开始,不推荐使用此文件,而使用/ proc / pid / oom_score_adj。
本文件可用于调整进程在 out-of-memory 的情况下被杀死的权重 该文件的有效值为 0(任何情况下都不 kill 该进程)~1000(一旦内存不足立即 kill 该进程),
该只读文件公开进程的执行域,由 personality(2) 设置。 该值以十六进制表示法显示。 访问该文件的权限由 ptrace 访问模式 PTRACE_MODE_ATTACH_FSCREDS 检查控制; 见ptrace(2)。
There is a numerical subdirectory for each running process; the subdirectory is named by the process ID. Each such subdirectory contains the following pseudo-files and directories.
注下面的时间或时刻都是从rq->clock中获得的,而这个值是由update_rq_clock底层cpu来更新的。并且很多信息是需要内核配置CONFIG_SCHEDSTATS才有。 大多数字段的计算在sched.c及sched_fair.c里,在这两个文件里搜索相应的字段就能得到相应的计算方法。
cpu_test (28733, #threads: 1) --------------------------------------------------------- se.exec_start : 2781299327.397282 //此进程最近被调度到的开始执行时刻(这个值是每次update_curr都进行更新) se.vruntime : 3144603.079903 //虚拟运行时间 se.sum_exec_runtime: 2843625.998498 //累计运行的物理时间时间 se.wait_start : 0.000000 //最近一次当前进程被入队的时刻 se.sleep_start : 0.000000 //此进程最近一次被从队列里取出,并被置S状态的时刻 se.block_start : 0.000000 //此进程最近一次被从队列里取出,并被置D状态的时刻 se.sleep_max : 0.000000 //最长处于S状态时间 se.block_max : 0.000000 //最长处于D状态时间 se.exec_max : 1.004266 //最长单次执行时间 se.slice_max : 998.456300 //曾经获得时间片的最长时间 se.wait_max : 0.455235 //最长在就绪队列里的等待时间 se.wait_sum : 15.615407 //累计在就绪队列里的等待时间 se.wait_count : 3147 //累计等待次数 se.iowait_sum : 215.825267 //io等待时间 se.iowait_count : 67 //io等待次数 io_schedule调用次数 sched_info.bkl_count: 0 //此进程大内核锁调用次数 se.nr_migrations : 0 //需要迁移当前进程到其他cpu时累加此字段 se.nr_migrations_cold: 0 se.nr_failed_migrations_affine: 194 //进程设置了cpu亲和,进程迁移时检查失败的次数 se.nr_failed_migrations_running: 0 se.nr_failed_migrations_hot: 0 //当前进程因为是cache hot导致迁移失败的次数 se.nr_forced_migrations : 0 //在当前进程cache hot下,由于负载均衡尝试多次失败,强行进行迁移的次数 se.nr_wakeups : 0 //被唤醒的累计次数(从不可运行到可运行) se.nr_wakeups_sync : 0 //同步唤醒次数,即a唤醒b,a立刻睡眠,b被唤醒的次数 se.nr_wakeups_migrate : 0 //被唤醒得到调度的当前cpu,不是之前睡眠的cpu的次数 se.nr_wakeups_local : 0 //被本地唤醒的次数(唤醒后在当前cpu上执行) se.nr_wakeups_remote : 0 //非本地唤醒累计次数 se.nr_wakeups_affine : 0 //考虑了任务的cache亲和性的唤醒次数 se.nr_wakeups_affine_attempts: 0 se.nr_wakeups_passive : 0 se.nr_wakeups_idle : 0 avg_atom : 903.886204 //本进程平均耗时sum_exec_runtime/ nr_switches avg_per_cpu : 0.000001 nr_switches : 3146 //主动切换和被动切换的累计次数 nr_voluntary_switches : 0 //主动切换次数(由于prev->state为不可运行状态引起的切换) nr_involuntary_switches : 3146 //被动切换次数 se.load.weight : 1024 //该se的load policy : 0 //调度策略 normal prio : 120 //优先级(nice=0) clock-delta : 51
allow: 允许包含进程pid的用户命名空间中的进程使用setgroups(2)系统调用 deny: 在该用户命名空间中不允许setgroups(2) 请注意,如果没有设置 /proc/pid/gid_map,则无论该文件的值是什么,都不允许调用setgroups(2)
Index ¶
- func AutoGroupRawData(pid string) string
- func CGroupRawData(pid string) string
- func CPUSetRawData(pid string) string
- func CWD(pid string) string
- func CoredumpFilterRawData(pid string) string
- func EnvironRawData(pid string) string
- func GidMapRawData(pid string) string
- func LimitsRawData(pid string) string
- func LoginUidRawData(pid string) string
- func MountInfoRawData(pid string) string
- func MountStatsRawData(pid string) string
- func MountsRawData(pid string) string
- func OOMAdj(pid string) int
- func OOMScore(pid string) int
- func OOMScoreAdj(pid string) int
- func PersonalityRawData(pid string) string
- func ProjidMapRawData(pid string) string
- func SchedRawData(pid string) string
- func SessionIDRawData(pid string) string
- func SetGroupRawData(pid string) string
- func StatusRawData(pid string) string
- func SyscallRawData(pid string) string
- func UidMapRawData(pid string) string
- type CmdlineInfo
- type Context
- type FDInfo
- type FDItem
- type IOInfo
- type LimitsInfo
- type MapFilesInfo
- type MapFilesItem
- type Mapping
- type MapsItem
- type NodePages
- type NumaMapsInfo
- type PidStatInfo
- type SchedInfo
- type SchedItem
- type SchedStatInfo
- type SmapsInfo
- type StackInfo
- type StatmInfo
- type StatusInfo
- type TaskInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoGroupRawData ¶
func CGroupRawData ¶
func CPUSetRawData ¶
func CoredumpFilterRawData ¶
func EnvironRawData ¶
func GidMapRawData ¶
func LimitsRawData ¶
func LoginUidRawData ¶
func MountInfoRawData ¶
func MountStatsRawData ¶
func MountsRawData ¶
func OOMScoreAdj ¶
func PersonalityRawData ¶
func ProjidMapRawData ¶
func SchedRawData ¶
func SessionIDRawData ¶
func SetGroupRawData ¶
func StatusRawData ¶
func SyscallRawData ¶
func UidMapRawData ¶
Types ¶
type CmdlineInfo ¶
type CmdlineInfo struct {
Cmdline string
}
func Cmdline ¶
func Cmdline(pid string) (CmdlineInfo, error)
type Context ¶
type Context struct {
Procfs string // proc filesystem mount point, default is /proc
}
var Ctx Context
type IOInfo ¶
type IOInfo struct { RChar uint64 // characters read. The number of bytes which this task has caused to be read from storage. This is simply the sum of bytes which this process passed to read(2) and similar system calls. It includes things such as terminal I/O and is unaffected by whether or not actual physical disk I/O was required (the read might have been satisfied from pagecache). WChar uint64 // characters written. The number of bytes which this task has caused, or shall cause to be written to disk. Similar caveats apply here as with rchar. SysCR uint64 // read syscalls. Attempt to count the number of read I/O operations—that is, system calls such as read(2) and pread(2). SysCW uint64 // Attempt to count the number of write I/O operations—that is, system calls such as write(2) and pwrite(2). ReadBytes uint64 // Attempt to count the number of bytes which this process really did cause to be fetched from the storage layer. This is accurate for block-backed filesystems. WriteBytes uint64 // Attempt to count the number of bytes which this process caused to be sent to the storage layer. CancelledWriteBytes uint64 // The big inaccuracy here is truncate. }
type LimitsInfo ¶
type LimitsInfo struct {
Limits []limitsItem
}
containe all info of /proc/pid/statm
func Limits ¶
func Limits(pid string) (LimitsInfo, error)
type MapFilesInfo ¶
type MapFilesInfo struct {
Mappings []MapFilesItem
}
func MapFiles ¶
func MapFiles(pid string) MapFilesInfo
type MapFilesItem ¶
type Mapping ¶
type Mapping struct { Addr string // 内存范围的起始地址 Policy string // 对该范围内存生效的内存策略,请注意,有效策略不一定是该内存范围的进程安装的策略。 具体而言,如果进程为该范围安装了“default”策略,则该范围的有效策略将是进程策略,其可能是也可能不是“default”。 Nodes []NodePages // 各个 NUMA 节点上分配的内存页数。 File string // 内存范围所对应的文件。 如果文件被映射为私有,则写访问可能已在此内存范围中生成COW(写时复制)页。 这些页面显示为匿名页面。 MapType string // 该字段可能为空,以下是可能的类型:Heap: 由堆使用的内存; Stack: 由栈使用的内存; Huge: Huge 内存范围,显示的是大页内存而不是常规页。 Anon int // 该范围内的匿名内存页数 Dirty int // 需要回写磁盘的页数 Mapped int // 映射的内存页面总数(如果和 dirty 以及 anon 的页数不同的话)。 MapMax int // 扫描期间遇到的最大mapcount(映射单个页面的进程数)。 这可以用作在给定存储器范围内发生的共享程度的指示符。 SwapCache int // 在交换设备上具有关联条目的页数。 Active int // 活动列表中的页数。仅当与此范围内的页数不同时,才会显示此字段。 这意味着存储器范围中存在一些非活动页面,这些页面很快就会被交换器从内存中删除。 WriteBack int // 当前正在回写到磁盘的页数 KernelPageSizeKB string // 内核页大小 }
type MapsItem ¶
type MapsItem struct { StartAddr string // 起始虚拟地址 EndAddr string // 终点虚拟地址 Perm string // 权限 Offset string // 偏移量 Dev string // 映像文件所在的磁盘的主设备号和次设备号 INode string // 映像文件的的磁盘节点(inode) File string // 文件/库/堆栈的路径 Size uint64 Rss uint64 Pss uint64 PrivateClean uint64 PrivateDirty uint64 Referenced uint64 Anonymous uint64 AnonHugePages uint64 PrivateHugetlb uint64 Swap uint64 SwapPss uint64 KernelPageSize uint64 MMUPageSize uint64 Locked uint64 VmFlags string }
type NodePages ¶
type NodePages struct { Node string // numa 节点名 NrPages string // nr_pages 只包含当前进程映射的内存。页面迁移和内存回收的临时内存可能不会映射在这里 }
指定的 NUMA 节点上分配的内存页数。
type NumaMapsInfo ¶
type NumaMapsInfo struct {
Mappings []Mapping
}
containe all info of /proc/pid/numa_maps
func NumaMaps ¶
func NumaMaps(pid string) (NumaMapsInfo, error)
type PidStatInfo ¶
type PidStatInfo struct { Pid int // 1. The process ID. Comm string // 2. The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out. State string // 3. One of the following characters, indicating process state: R/S/D/Z/T/t/W/X/x/K/W/P PPid int // 4. The PID of the parent of this process. PGrp int // 5. The process group ID of the process. Session int // 6. The session ID of the process TtyNr int // 7. The controlling terminal of the process. (The minor device number is contained in the combination of bits 31 to 20 and 7 to 0; the major device number is in bits 15 to 8.) TPGid int // 8. The ID of the foreground process group of the controlling terminal of the process. Flags uint64 // 9. The kernel flags word of the process. Minflt uint64 // 10. The number of minor faults the process has made which have not required loading a memory page from disk. CMinflt uint64 // 11. The number of minor faults that the process's waited-for children have made Majflt uint64 // 12. The number of major faults the process has made which have required loading a memory page from disk. CMajflt uint64 // 13. The number of major faults that the process's waited-for children have made. UTime uint64 // 14. Amount of time that this process has been scheduled in user mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). STime uint64 // 15. Amount of time that this process has been scheduled in kernel mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). CUTime int64 // 16. Amount of time that this process's waited-for children have been scheduled in user mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). CSTime int64 // 17. Amount of time that this process's waited-for children have been scheduled in kernel mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). Priority int64 // 18. (Explanation for Linux 2.6) For processes running a real-time scheduling policy Nice int64 // 19. The nice value (see setpriority(2)), a value in the range 19 (low priority) to -20 (high priority). NumThreads int64 // 20. Number of threads in this process (since Linux 2.6). Itrealvalue int64 // 21. The time in jiffies before the next SIGALRM is sent to the process due to an interval timer. StartTime uint64 // 22. The time the process started after system boot. In kernels before Linux 2.6, this value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)). VSize uint64 // 23. Virtual memory size in bytes. RSS int64 // 24. Resident Set Size: number of pages the process has in real memory. RSSLim uint64 // 25. Current soft limit in bytes on the rss of the process; see the description of RLIMIT_RSS in getrlimit(2). Startcode uint64 // 26. The address above which program text can run. EndCode uint64 // 27. The address below which program text can run. StartStack uint64 // 28. The address of the start (i.e., bottom) of the stack. KStkESP uint64 // 29. The current value of ESP (stack pointer), as found in the kernel stack page for the process. KStkEIP uint64 // 30. The current EIP (instruction pointer). Signal uint64 // 31. The bitmap of pending signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. Blocked uint64 // 32. The bitmap of blocked signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. SigIgnore uint64 // 33. The bitmap of ignored signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. SigCatch uint64 // 34. The bitmap of caught signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. WChan uint64 // 35. This is the "channel" in which the process is waiting. It is the address of a location in the kernel where the process is sleeping. The corresponding symbolic name can be found in /proc/[pid]/wchan. NSwap uint64 // 36. Number of pages swapped (not maintained). CNSwap uint64 // 37. Cumulative nswap for child processes (not maintained). ExitSignal int // 38. Signal to be sent to parent when we die. Processor int // 39. CPU number last executed on. RTPriority uint64 // 40. Real-time scheduling priority, a number in the range 1 to 99 for processes scheduled under a real-time policy, or 0, for non-real-time processes (see sched_setscheduler(2)). Policy uint64 // 41. Scheduling policy (see sched_setscheduler(2)). DelayacctBlkioTicks uint64 // 42. Aggregated block I/O delays, measured in clock ticks (centiseconds). GuestTime uint64 // 43. Guest time of the process (time spent running a virtual CPU for a guest operating system), measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). CGuestTime uint64 // 44. Guest time of the process's children, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). StartData uint64 // 45. Address above which program initialized and uninitialized (BSS) data are placed. EndData uint64 // 46. Address below which program initialized and uninitialized (BSS) data are placed. StartBrk uint64 // 47. Address above which program heap can be expanded with brk(2). ArgStart uint64 // 48. Address above which program command-line arguments (argv) are placed. ArgEnd uint64 // 49. Address below program command-line arguments (argv) are placed. EnvStart uint64 // 50. Address above which program environment is placed. EnvEnd uint64 // 51. Address below which program environment is placed. ExitCode int // 52. The thread's exit status in the form reported by waitpid(2). }
func Stat ¶
func Stat(pid string) (PidStatInfo, error)
type SchedStatInfo ¶
type SchedStatInfo struct { SumExecRuntime uint64 // time spent on the cpu, task->se.sum_exec_runtime, 累计运行的物理时间时间, se.sum_exec_runtime WaitSum uint64 // io 等待时间, se.wait_sum Switches uint64 // 主动切换和被动切换的累计次数, se->nr_switches }
func SchedStat ¶
func SchedStat(pid string) (SchedStatInfo, error)
type StatmInfo ¶
type StatmInfo struct { // 1. total program size (same as VmSize in /proc/[pid]/status) Size uint64 // 2. resident set size (same as VmRSS in /proc/[pid]/status) Resident uint64 Share uint64 // 4. text (code) Text uint64 // 5. library (unused in Linux 2.6) Lib uint64 // 6. data + stack Data uint64 // 7. dirty pages (unused in Linux 2.6) Dt uint64 }
containe all info of /proc/pid/statm
type StatusInfo ¶
type StatusInfo struct { Name string // Command run by this process. State string // Current state of the process. One of "R (running)", "S (sleeping)", "D (disk sleep)", "T (stopped)", "T (tracing stop)", "Z (zombie)", or "X (dead)". Tgid uint64 // Thread group ID (i.e., Process ID). Ngid uint64 Pid uint64 // Thread ID (see gettid(2)). PPid uint64 // PID of parent process. TracerPid []uint64 // PID of process tracing this process (0 if not being traced). Uid []uint64 // Real, effective, saved set, and filesystem UIDs (GIDs). Gid []uint64 // Real, effective, saved set, and filesystem UIDs (GIDs). FDSize uint64 // Number of file descriptor slots currently allocated. Groups []uint64 // Supplementary group list. NStgid uint64 // NSpid uint64 // NSpgid uint64 // NSsid uint64 // VmPeak uint64 // Peak virtual memory size. VmSize uint64 // Virtual memory size. VmLck uint64 // Locked memory size (see mlock(3)). VmPin uint64 // Pinned memory size (since Linux 3.2). These are pages that can't be moved because something needs to directly access physical memory. VmHWM uint64 // Peak resident set size ("high water mark"). VmRSS uint64 // Resident set size. VmData uint64 // Size of data VmStk uint64 // Size of stack VmExe uint64 // Size of text segments. VmLib uint64 // Shared library code size. VmPMD uint64 // Size of second-level page tables (since Linux 4.0). VmPTE uint64 // Page table entries size (since Linux 2.6.10). VmSwap uint64 // Swapped-out virtual memory size by anonymous private pages; shmem swap usage is not included (since Linux 2.6.34). HugetlbPages uint64 // Threads uint64 // Number of threads in process containing this thread. SigQ []uint64 // This field contains two slash-separated numbers that relate to queued signals for the real user ID of this process. The first of these is the number of currently queued signals for this real user ID, and the second is the resource limit on the number of queued signals for this process (see the description of RLIMIT_SIGPENDING in getrlimit(2)). SigPnd string // Number of signals pending for thread and for process as a whole (see pthreads(7) and signal(7)). ShdPnd string // Number of signals pending for process as a whole (see pthreads(7) and signal(7)). SigBlk string // Masks indicating signals being blocked (see signal(7)). SigIgn string // Masks indicating signals being ignored (see signal(7)). SigCgt string // Masks indicating signals being caught (see signal(7)). CapInh string // Masks of capabilities enabled in inheritable (see capabil‐ ities(7)). CapPrm string // Masks of capabilities enabled in permitted (see capabil‐ ities(7)). CapEff string // Masks of capabilities enabled in effective sets (see capabil‐ ities(7)). CapBnd string // Capability Bounding set (since Linux 2.6.26, see capabilities(7)). CapAmb string // Ambient capability set (since Linux 4.3, see capabilities(7)). Seccomp uint64 // Seccomp mode of the process (since Linux 3.8, see seccomp(2)). 0 means SECCOMP_MODE_DISABLED; 1 means SECCOMP_MODE_STRICT; 2 means SECCOMP_MODE_FILTER. This field is provided only if the kernel was built with the CONFIG_SECCOMP kernel configuration option enabled. CpusAllowed string // Mask of CPUs on which this process may run (since Linux 2.6.24, see cpuset(7)). CpusAllowedList string // Same as previous, but in "list format" (since Linux 2.6.26, see cpuset(7)). MemsAllowed string // Mask of memory nodes allowed to this process (since Linux 2.6.24, see cpuset(7)). MemsAllowedList string // Same as previous, but in "list format" (since Linux 2.6.26, see cpuset(7)). VoluntaryCtxtSwitches uint64 // Number of voluntary context switches (since Linux 2.6.23). NonVoluntarCtxtSwitches uint64 // Number of involuntary context switches (since Linux 2.6.23). }
func Status ¶
func Status(pid string) (StatusInfo, error)
Source Files
¶
- autogroup.go
- cgroup.go
- cmdline.go
- coredump_filter.go
- cpuset.go
- cwd.go
- environ.go
- fd.go
- gid_map.go
- io.go
- limits.go
- loginuid.go
- map_files.go
- mountinfo.go
- mounts.go
- mountstats.go
- numa_maps.go
- oom_adj.go
- oom_score.go
- oom_score_adj.go
- personality.go
- pid.go
- projid_map.go
- sched.go
- schedstat.go
- sessionid.go
- setgroups.go
- smaps.go
- stack.go
- stat.go
- statm.go
- status.go
- syscall.go
- task.go
- uid_map.go