From 46bba9d4e8c6dd654af7ad15e7a98a89c46203ac Mon Sep 17 00:00:00 2001
From: Jan Altenberg <jan@linutronix.de>
Date: Thu, 17 Jul 2014 14:50:34 +0200
Subject: Added an SMP Interrupt routing example and a QUICK introduction to
 CGROUPS

---
 .../linux-processes/pres_linux-processes_en.tex    | 129 +++++++++++++++++++++
 1 file changed, 129 insertions(+)

(limited to 'linux-basics/linux-processes/pres_linux-processes_en.tex')

diff --git a/linux-basics/linux-processes/pres_linux-processes_en.tex b/linux-basics/linux-processes/pres_linux-processes_en.tex
index 71c1344..79bb155 100644
--- a/linux-basics/linux-processes/pres_linux-processes_en.tex
+++ b/linux-basics/linux-processes/pres_linux-processes_en.tex
@@ -249,6 +249,135 @@ sched_setaffinity(pid, CPU_SETSIZE, &set);
 \end{lstlisting}
 \end{frame}
 
+\begin{frame}[fragile]
+\frametitle{SMP and interrupt routing}
+\begin{verbatim}
+$ ls /proc/irq/
+0  1  10  11  12  13  14  15  17  18  19  2  3	4  5  6  7  8  9  default_smp_affinity
+
+$ cat /proc/irq/default_smp_affinity
+3
+
+# Set default IRQ affinity to CPU0
+$ echo 1 > /proc/irq/default_smp_affinity
+
+# Set affinity for specific IRQ to CPU1
+$ echo 2 > /proc/irq/
+\end{verbatim}
+\end{frame}
+
+\subsection{Control Groups: CGROUPS}
+
+\begin{frame}
+\frametitle{CGROUPS}
+CGROUPS are a mechanism for partitioning and aggregating tasks
+into hierarchical groups. Each group has several options like
+CPU time, a specific set of CPUs, ...
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Using CGROUPS}
+\begin{verbatim}
+$ mount -t cgroup -o defaults none /sys/fs/cgroup
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{CGROUPS: Create a new groups}
+\begin{verbatim}
+$ cd /sys/fs/cgroup
+
+$ mkdir group_01
+
+$ mkdir group_02
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{CGROUPS: Setting up groups}
+\begin{verbatim}
+$ cd group_01
+
+# Set allowed CPUs
+$ echo 0 > cpuset.cpus
+
+# Set allowed memory nodes
+$ echo 0 > cpuset.mems
+
+# Limit CPU time
+$ echo 100 > cpu.shares
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{CGROUPS: Setting up groups}
+\begin{verbatim}
+$ cd group_02
+
+# Set allowed CPUs
+$ echo 0 > cpuset.cpus
+
+# Set allowed memory nodes
+$ echo 0 > cpuset.mems
+
+# Limit CPU time
+$ echo 900 > cpu.shares
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{CGROUPS: Setting up groups}
+Open two shells. In shell 1 do:
+\begin{verbatim}
+$ cd group_01
+
+# Add the current task to the group
+$ echo $$ > tasks
+
+# Create some noise
+$ while [ 1 ]; do echo bla > /dev/null; done;
+\end{verbatim}
+In shell 2:
+\begin{verbatim}
+$ cd group_02
+
+# Add the current task to the group
+$ echo $$ > tasks
+
+# Create some noise
+$ while [ 1 ]; do echo bla > /dev/null; done;
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{CGROUPS: Setting up groups}
+Now check the CPU usage with top
+\begin{verbatim}
+$ top
+[...]
+4285 root      20   0  4708 1864 1524 R   89  0.2   8:59.68 bash               
+4152 root      20   0  4720 1904 1548 R   10  0.2   4:02.00 bash  
+[...]
+\end{verbatim}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{CGROUPS: Who is using CGROUPS?}
+SystemD uses CGROUPS! Boot with SystemD and check SysFS:
+\begin{verbatim}
+$ cd /sys/kernel/cgroup
+
+$ ls
+blkio  cpu  cpuacct  cpu,cpuacct  cpuset  devices  freezer  net_cls  systemd
+
+$ ls -1 /sys/fs/cgroup/cpu,cpuacct/system/
+cron.service
+dbus.service
+exim4.service
+[...]
+\end{verbatim}
+\end{frame}
+
 \subsection{sources}
 \begin{frame}
 \begin{thebibliography}{1}
-- 
cgit v1.2.3

