summaryrefslogtreecommitdiff
path: root/realtime/rt-internals/pres_rt-internals_en.tex
blob: baeb2e1c3e5f102f6ceee3ec5bb9fef70e1d73f9 (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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
% on the following slides, include icon in the left sidebar
\def\lximg{/usr/share/lx/icons/fueller.png}

\input{configpres}

\title{Linux Preempt-RT internals}
\maketitle

% stop displaying 'fueller.png' on the following slides
\def\lximg{none}

\subsection{Linux Real-Time history}
\begin{frame}[fragile]
\frametitle{Linux Real-Time history}
\begin{beamerboxesrounded}[shadow=true]{First projects in the late 1990s}
\begin{itemize}
\item KURT - Kansas University
\item RTAI - University of Milano
\item RTLinux - New Mexico Tech - Soccoro, New Mexico
\item Linux/RK - Carnegie Mellon Univeristy, Pittsburgh
\item QLinux - University of Massachusetts
\item DROPS - University of Dresden
\item ...
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Linux Real-Time history}
\begin{beamerboxesrounded}[shadow=true]{Approaches}
\begin{itemize}
\item Linux as the idle thread of a nano/micro kernel
\item Linux with implicit Real-Time properties
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Linux Real-Time history}
\begin{beamerboxesrounded}[shadow=true]{Opinion I}
\begin{quote}
With RTLinux, you have to split the app up into the hard realtime part
and the rest.
\newline
Which is, in my opinion, the only sane way to handle hard realtime. No
confusion about priority inversions, no crap.
\end{quote}
\begin{flushright}
Linus Torvalds - 2002
\end{flushright}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Linux Real-Time history}
\begin{beamerboxesrounded}[shadow=true]{Opinion II}
\begin{quote}
It is impossible to turn a General Purpose Operating System Kernel
into a Real-Time Operating System Kernel!
\end{quote}
\begin{flushright}
Unknown participant of a podium discussion about Linux Real-Time - 2004
\end{flushright}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Linux Real-Time history}
\begin{beamerboxesrounded}[shadow=true]{Preempt-RT}
\begin{itemize}
\item Started 2004 by Ingo Molnar
\item In kernel real-time approach
\item Driven by mainline kernel developers
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Linux Real-Time history}
\begin{beamerboxesrounded}[shadow=true]{Opinion III}
\begin{quote}
Controlling a laser with Linux is crazy, but everyone in this room is
crazy in his own way. So if you want to use Linux to control an
industrial welding laser, I have no problem with your using
PREEMPT\_RT.
\end{quote}
\begin{flushright}
Linus Torvalds - 2006
\end{flushright}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT goals}

\begin{frame}[fragile]
\frametitle{Preempt-RT goals}
\begin{beamerboxesrounded}[shadow=true]{What's the goal?}
\begin{itemize}
\item Full Linux kernel hardware support
\item Standard posix interface
\item No specialized user space ABI
\item Full reuse of existing tools
\item Scalability
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT goals}
\begin{beamerboxesrounded}[shadow=true]{What's the target application space?}
\begin{itemize}
\item The majority of Real-Time applications
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT properties}
\begin{frame}[fragile]
\frametitle{Preempt-RT properties}
\begin{beamerboxesrounded}[shadow=true]{Is it hard realtime?}
\begin{itemize}
\item Not by the requirement of mathematical proof
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT properties}
\begin{beamerboxesrounded}[shadow=true]{Is mathematical proof feasible?}
\begin{itemize}
\item Not for complex systems
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT properties}
\begin{beamerboxesrounded}[shadow=true]{Can it be verified?}
\begin{itemize}
\item Empirical verfication
\item Open and documented testing efforts (OSADL, RedHat)
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT technology}
\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Why is mainline not realtime capable?}
\begin{itemize}
\item Hard interrupt context
\item Soft interrupt context
\item Interrupt disabled regions
\item Preemption disabled regions
\item No protection against priority inversion
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Hard interrupt context}
\begin{itemize}
\item Runs with interrupts disabled
\item Executes driver interrupt handlers
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Soft interrupt context}
\begin{itemize}
\item Runs with preemption disabled, mostly on return from hard interrupt context
\item Executes driver and infrastructure callbacks
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Interrupt disabled regions}
\begin{itemize}
\item Mostly in context of spinlocks and rwlocks
\item Few places which require explicit interrupt disable
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Why spinlocked interrupt disabled regions}
\begin{table}
\begin{tabular}{ll}
 \textbf{thread} & \textbf{interrupt}    \\
  spin\_lock(lock); &                    \\
  interrupt         &                    \\
                    &  interrupt handler \\
                    &  spin\_lock(lock); \\
                    &  DEADLOCK!         \\
\end{tabular}
\end{table}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Preemption disabled regions}
\begin{itemize}
\item Mostly in context of spinlocks and rwlocks
\item Also protects per cpu variables
\item Few places which require explicit preemption disable
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Why spinlocked preempt disabled regions}
\begin{table}
\begin{tabular}{ll}
 \textbf{thread A} & \textbf{thread B}  \\
  spin\_lock(lock); &                   \\
  preemption        &                   \\
                    &  spin\_lock(lock);\\
                    &  DEADLOCK!        \\
\end{tabular}
\end{table}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{spinlocks}
\begin{itemize}
\item RT separates them into spinlock and raw\_spinlock
\item raw\_spinlock in RT is identical to mainline
\item spinlock in RT is replaced by a "'sleeping"' spinlock
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Reader/Writer locks}
\begin{itemize}
\item rwlock in RT is replaced by a "'sleeping"' spinlock
\item Readercount in RT is limited to 1
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Lock replacement requires}
\begin{itemize}
\item Forced interrupt threading
\item Forced soft interrupt threading
\item Substitution of percpu constructs
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Lock replacement requires}
Preservation of migration disable. In mainline migration is disabled by
\begin{itemize}
\item interrupt disable
\item preempt disable
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Priority inversion}
\begin{center}
\includegraphics[scale=0.4]{images/pinv.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Priority inheritance}
\begin{center}
\includegraphics[scale=0.4]{images/pinh.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Priority inheritance}
\begin{itemize}
\item Kernelimplementation: rtmutex
\item Nested lock boosting
\item User space interface: futex (pthread\_mutex)
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Lock replacement}
\begin{itemize}
\item Wrapper around rtmutex
\item Adaptive spinning for spinlocks and rwlocks
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Lock replacement}
All locking primitives are replaced except
\begin{itemize}
\item raw\_spinlock
\item semaphore
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Why are semaphores special?}
\begin{itemize}
\item No strict owner semantics
\item No owner, no boosting
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Further changes}
\begin{itemize}
\item per cpu locks
\item preemptible RCU
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Per CPU locks}
Protect regions which are in mainline protected by
\begin{itemize}
\item preemption disable
\item interrupt disable
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Preemptible RCU}
What's RCU?
\begin{itemize}
\item Read Copy Update
\item Scalability replacement for reader/writer locks
\item Restricted bulk refcounting
\item Poor mans garbage collector
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Preemptible RCU}
What's RCU?
\begin{center}
\includegraphics[scale=0.4]{images/GracePeriodGood.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Preemptible RCU}
RCU versus rwlocks
\begin{center}
\includegraphics[scale=0.4]{images/rwlockRCUupdate.jpg}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT technology}
\begin{beamerboxesrounded}[shadow=true]{Preemptible RCU}
\begin{itemize}
\item Original RCU implementation relied on preempt disable
\item Preemptible implementation is in mainline
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT source impact}

\begin{frame}[fragile]
\frametitle{Preempt-RT source impact}
\begin{beamerboxesrounded}[shadow=true]{Kernel source structure}
\begin{center}
\includegraphics[scale=0.35]{images/ksource.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT source impact}
\begin{beamerboxesrounded}[shadow=true]{Kernel source structure RT patch}
\begin{center}
\includegraphics[scale=0.4]{images/rtsource.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT source impact}
\begin{beamerboxesrounded}[shadow=true]{Architecture source structure}
\begin{center}
\includegraphics[scale=0.35]{images/asource.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT source impact}
\begin{beamerboxesrounded}[shadow=true]{Architecture source structure, RT patch}
\begin{center}
\includegraphics[scale=0.35]{images/rtarch.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT source impact}
\begin{beamerboxesrounded}[shadow=true]{Core source structure}
\begin{center}
\includegraphics[scale=0.35]{images/kdirsource.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT source impact}
\begin{beamerboxesrounded}[shadow=true]{Core source structure, RT patch}
\begin{center}
\includegraphics[scale=0.4]{images/rtkernel.png}
\end{center}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT downsides}

\begin{frame}[fragile]
\frametitle{Preempt-RT downsides}
\begin{beamerboxesrounded}[shadow=true]{Determinism comes with a prize}
\begin{itemize}
\item Reduced throughput
\item Measurable I/O performance impact
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT influence on mainline Linux}

\begin{frame}[fragile]
\frametitle{Preempt-RT influence on mainline Linux}
\begin{beamerboxesrounded}[shadow=true]{Most of it is upstream}
\begin{itemize}
\item More than 95\% of the development has been merged
\item Only the hard to solve issues are left
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\begin{frame}[fragile]
\frametitle{Preempt-RT influence on mainline Linux}
\begin{beamerboxesrounded}[shadow=true]{What has been achieved?}
\begin{itemize}
\item Generic interrupt subsystem
\item Generic timekeeping subsystem
\item Generic timer subsystem
\item High resolution timers
\item NOHZ infrastructure
\item Preemptible RCU
\item Consolidated locking infrastructure
\item Lock dependency validator
\item Tracing
\item ...
\end{itemize}
\end{beamerboxesrounded}
\end{frame}

\subsection{Preempt-RT and Linus Torvalds}

\begin{frame}[fragile]
\frametitle{Preempt-RT}
\begin{beamerboxesrounded}[shadow=true]{Famous last words}
\begin{quote}
And yeah, I still think the hard-RT people are mostly crazy.
\end{quote}
\begin{flushright}
Linus Torvalds - 2010
\end{flushright}
\end{beamerboxesrounded}
\end{frame}

\input{tailpres}