blob: 7061ea4f0a3088b37f0159323a163d4b1703d6b0 (
plain)
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
\input{configpres}
\title{\lq Anwendung des Preempt RT Patches\rq}
\maketitle
\subsection{PREEMPT\_RT}
\subsubsection{Download und Anwenden}
\begin{frame}[fragile]
\frametitle{Besorgen und Anwenden des Preempt RT Patches}
\begin{lstlisting}
# Vanilla Kernel
wget http://www.kernel.org/pub/linux/kernel\
/v2.6/linux-2.6.29.5.tar.bz2
# Preempt RT Patch
wget http://www.kernel.org/pub/linux/kernel\
/projects/rt/patch-2.6.29.5-rt21.bz2
# Extract the kernel tree
tar xjvf linux-2.6.29.5.tar.bz2
# Patch the kernel tree
cd linux-2.6.29.5
bzcat ../patch-2.6.29.5-rt21.bz2 | patch -p1
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Besorgen und Anwenden des Preempt RT Patches}
\begin{lstlisting}
mkdir linux-2.6.29.5-rt21
cd linux-2.6.29.5-rt21
ketchup -f --no-gpg 2.6.29.5-rt21
\end{lstlisting}
\end{frame}
\subsubsection{Konfiguration}
\begin{frame}[fragile]
\frametitle{Konfigurieren und Übersetzen eines Preempt RT Kernels}
\begin{overprint}
\onslide<1>
\begin{lstlisting}
# external build directory
mkdir ../build
# base build on existing config
cp /boot/config-x-x-x ../build/.config
make O=../build oldconfig
\end{lstlisting}
\onslide<2>
\begin{lstlisting}
make O=../build menuconfig
\end{lstlisting}
\onslide<3>
\begin{figure}[ht!]
\centering
\includegraphics[height=0.5\textwidth]{images/menu_rt_001.png}
\end{figure}
\onslide<4>
\begin{figure}[ht!]
\centering
\includegraphics[height=0.5\textwidth]{images/menu_rt_002.png}
\end{figure}
\onslide<5>
\begin{figure}[ht!]
\centering
\includegraphics[height=0.5\textwidth]{images/menu_rt_003.png}
\end{figure}
\onslide<6>
\begin{figure}[ht!]
\centering
\includegraphics[height=0.5\textwidth]{images/menu_rt_004.png}
\end{figure}
\onslide<7>
\begin{lstlisting}
make O=../build
make O=../build modules
make O=../build install
make O=../build modules_install
\end{lstlisting}
\end{overprint}
\end{frame}
\subsubsection{Verifikation}
\begin{frame}
\frametitle{Testen eines Preempt RT Systems}
RT Tests:
\begin{itemize}
\item cyclictest
\item hwlatdetect
\item pi\_stress
\item signaltest
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Cyclictest}
\begin{itemize}
\item Ursprünglich entwickelt von Thomas Gleixner für Preempt RT Testing
\item High Resolution Timer Testsoftware
\item Setzt beliebige Anzahl von Realtime Tasks mit unterschiedlicher Priorität
und unterschiedlichen Intervallen auf
\item Viele Debuggingmöglichkeiten
\item Sehr Aussagekräftig, um Echtzeitverhalten auf einer bestimmten Plattform
zu beurteilen.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Lastszenarien}
Geeignete Lastszenarien, um Worst-Case Situationen nachstellen / provozieren zu
können:
\begin{itemize}
\item CPU Last: ''hackbench'', ursprünglich als Scheduler Benchmark geschrieben.
\item Interrupt Last: Floodping (''ping -F'')
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Pitfall!}
\begin{lstlisting}
cat /proc/sys/kernel/sched_rt_runtime_us
\end{lstlisting}
\begin{figure}[l!]
\centering
\includegraphics[height=0.4\textwidth]{images/pitfall.png}
\end{figure}
\end{frame}
\subsubsection{Applikationsentwicklung}
\begin{frame}
\frametitle{Echtzeitapplikationen mit Preempt RT}
\begin{columns}
\column[r]{7cm}
\begin{figure}[l!]
\centering
\includegraphics[height=0.4\textwidth]{images/thumb.png}
\end{figure}
\column[l]{8cm}
\huge
POSIX!
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Schedulingstrategien}
\begin{itemize}
\item SCHED\_FIFO: Static priority
\item SCHED\_RR: Round Robin mit Prioritäten
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Aufbau einer RT Applikation}
\begin{overprint}
\onslide<1>
Schedulingstrategie / Priorität
\begin{lstlisting}
struct sched_param param;
param.sched_priority = 80;
if(sched_setscheduler(0, SCHED_FIFO, ¶m)
== -1) {
perror("sched_setscheduler failed");
exit(-1);
}
\end{lstlisting}
\onslide<2>
Lock memory:
\begin{lstlisting}
if(mlockall(MCL_CURRENT|MCL_FUTURE) == -1) {
perror("mlockall failed");
exit(-2);
}
\end{lstlisting}
\onslide<3>
''Stack prefaulting''
\begin{lstlisting}
void stack_prefault(void) {
unsigned char dummy[MAX_SAFE_STACK];
memset(&dummy, 0, MAX_SAFE_STACK);
return;
}
\end{lstlisting}
\end{overprint}
\end{frame}
\subsubsection{Tracing / Latency hunting}
\begin{frame}[fragile]
\frametitle{Tracing / Latency hunting}
\begin{itemize}
\item FTrace
\item Cyclictest unterstützt Traces mittels FTrace
\item Unterschiedliche Tracer (müssen im Kernel aktiviert sein)
\item Kommunikation mit FTrace über Debugfs
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Cyclictest + FTrace}
\begin{lstlisting}[basicstyle=\ttfamily\fontsize{8}{10}\selectfont]
# mount DebugFS
mount -t debugs debugfs /sys/kernel/debug
# list available tracers
zi:~# cat /sys/kernel/debug/tracing/available_tracers
wakeup_rt wakeup preemptoff function sched_switch nop
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Cyclictest + FTrace}
\begin{lstlisting}[basicstyle=\ttfamily\fontsize{8}{10}\selectfont]
cyclictest -p80 -n -f -b 100
zi:~# less /mnt/debugfs/tracing/trace
# tracer: function
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
IRQ-129-772 [000] 4154503386.851178: __rt_mutex_adjust_prio
IRQ-129-772 [000] 4154503386.851186: __rt_mutex_adjust_prio
IRQ-129-772 [000] 4154503386.851189: task_setprio<-__rt_mut
[...]
\end{lstlisting}
\end{frame}
\input{tailpres}
|