1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
\subsubsection{Pseudofs proc}
% ----------------------------
\begin{frame}
\frametitle{Basics}
\begin{itemize}
\item most important pseudofs
\item mount-point: /proc
\item early mount required
\item stable Kernel API extension
\begin{itemize}
\item process/thread information
\item kernel extension
\begin{itemize}
\item modules
\item drivers
\end{itemize}
\item system state/utilization (e.g. loadavg, interrupts)
\begin{itemize}
\item loadavg
\item interrupts
\end{itemize}
\item system behavior (e.g. memory over-commit)
\begin{itemize}
\item memory over-commit
\item network
\item irq affinity
\end{itemize}
\end{itemize}
\end{itemize}
\end{frame}
% The pseudo filesystem proc is an important API-extension of the linux
% kernel. It provides access to informations about the processes and
% threads, as well as other kenel-internal information, extensions and
% behaviour. The proc filesystem must be mounted as early as possible, right
% after userspace gets control from kernel.
% ----------------------------
\begin{frame}
\frametitle{Process information}
\begin{itemize}
\item one directory for each process
\item PID as directory name
\item /proc/self: link to process' own information
\item per process:
\begin{itemize}
\item maps: memory mappings
\item status/stat: process status (human/machine readable)
\item fd/fdinfo: (open) file descriptors
\item map\_files: mmap-ed files
\item mounts: filesystem mounts
\item task/<tid>: information about each thread
\end{itemize}
\item tools accessing process information in proc
\begin{itemize}
\item ps
\item top
\end{itemize}
\item prevent tool output parsing
\item direct access to process information is preferred
\end{itemize}
\end{frame}
% The informations about processes are provides in separate subdirectories,
% one for each process. The directory name is the PID number of the process.
% The link /proc/self can be used by processes to access its own process
% information.
% The file "maps" shows the memory mappings of a process. It lists all
% mappings, text segment, dynamic libraries, heap and stack.
% The file "status" contains informations about the process status in a
% human-readable form. The same information, but in machine readable form,
% is in file "stat".
% The directory "fd" and fd_info" contains information about the open file
% handles of the process.
% The directory "tasks" contain infomration about the threads of a process.
% ----------------------------
\begin{frame}
\frametitle{Kernel extensions}
\begin{itemize}
\item system-wide information
\item all files shows the current state of loaded extensions
\item extensions:
\begin{itemize}
\item modules: \\ a list of loaded modules
\item devices: \\ major-number-to-driver mapping
\item filesystems: \\ all currently supported filesystems
\end{itemize}
\end{itemize}
\end{frame}
% The kernel code can be extended by loadable modules. Ther are files in
% /proc, which informs about the currently loaded extensions. Each time an
% extension is added or removed, the content of these files may change.
% The file "modules" shows all modules, which are currently loaded. It also
% contains the start address of the text segment in memory, reference count
% and used-by information. The tool lsmod make use of this information.
% The file "devices" shows the mappings between the major numbers and the
% related device driver, separate for character and block devices.
% The file "filesystems" show all supported filesystems at the moment.
% ----------------------------
\begin{frame}
\frametitle{System State/Utilization}
\begin{itemize}
\item system-wide information
\item system state
\begin{itemize}
\item uptime: time since system start
\item config.gz: kernel configuration
\end{itemize}
\item system utilization
\begin{itemize}
\item loadavg: average system load (with some history)
\item interrupts: histogram of all interrupts (total and per CPU)
\item meminfo: memory information
\item buddyinfo: information about contiguous free pages
\end{itemize}
\end{itemize}
\end{frame}
% The system state and utilization is also available via filehandles in
% /proc.
% The file "loadavg" shows how many processes are schedulable at the same
% time and the history of this value.
% The file "interrupts" contains the histogram for all interrupts (total and
% per CPU).
% The file "meminfo" contains information about the system memory, the file
% "buddyinfo" contains a list of contiguous free pages in memory zones.
% The file "config.gz" contains the configuration, with which the kernel has
% been build. The file is compressed an can be extracted e.g. by zcat or
% zless.
% ----------------------------
\begin{frame}
\frametitle{System Behavior}
\begin{itemize}
\item System behavior: sub-directory /proc/sys
\begin{itemize}
\item use tool \textbf{sysctl} to change the values
\item settings at system start: \textbf{/etc/sysctl.conf} or \textbf{/etc/sysctl.d}
\end{itemize}
\item Interrupt routing: sub-directory /proc/irq
\begin{itemize}
\item system-wide affinity mask
\item per IRQ affinity mask
\item IRQs are only routed to the CPUs, which are set in the affinity mask bitfield
\end{itemize}
\end{itemize}
\end{frame}
% The subdirectory "sys" contains a large number of file handles, which can
% be used for fintune the system behaviour. The filehandles can be accessed
% directly, but it is highly recommended to use the tool "sysctl" instead.
% Most distributions supports settings at system start via /etc/sysctl.conf
% or /etc/sysctl.d.
% The subdirectory "irq" can be used, to configure the iterrupt routing to
% CPUs.
% ----------------------------
\subsubsection*{}
\begin{frame}
\frametitle{Resources}
\begin{itemize}
\item \href{https://www.kernel.org/doc/Documentation/filesystems/proc.txt}{Kernel: Documentation/filesystems/proc.txt}
\item \href{http://man7.org/linux/man-pages/man5/proc.5.html}{man 5 proc}
\item \href{http://man7.org/linux/man-pages/man8/sysctl.8.html}{man 8 sysctl}
\item \href{http://man7.org/linux/man-pages/man5/sysctl.conf.5.html}{man 5 sysctl.conf}
\end{itemize}
\end{frame}
|