summaryrefslogtreecommitdiffstats
path: root/documentation/book-enea-linux-users-guide/doc/cpu_isolation.xml
blob: e259c00c9bcf6235a3263ca5904f6c1577f1b10b (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
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<section condition="f_ci" id="enea-linux-realtime-cpu-isolation">
  <title>CPU Isolation</title>

  <note>
    <para>The level of feature support is target specific. Look up the <link
    linkend="feature-matrix">Feature Compatibility Matrix</link> to see how
    your target supports this feature.</para>
  </note>

  <para><emphasis role="bold">CPU isolation</emphasis><indexterm>
      <primary>CPU isolation</primary>
    </indexterm><indexterm>
      <primary>isolation</primary>
    </indexterm> facilitates predictable task scheduling, hence real-time
  properties, by protecting SMP<indexterm>
      <primary>SMP</primary>
    </indexterm> CPUs<indexterm>
      <primary>CPU</primary>
    </indexterm> from being disturbed by unnecessary interrupts and unwanted
  tasks. The isolated CPUs are granted a tickless environment, and are
  excluded from load balancing. Any CPU except for CPU 0 can be
  isolated.</para>

  <para>Depending on the capabilities of the kernel for the specific target,
  the isolated CPUs can obtain a tickless or nearly tickless environment. A
  tickless environment means that isolated CPUs get no ticks at all (0 Hz).
  Nearly tickless environment means that isolated CPUs are still disturbed by
  ticks once a second (1 Hz).</para>

  <para>The CPU isolation process involves several steps until a CPU is fully
  isolated. Enea Linux simplifies this process for you by implementing in the
  distribution kernel patching and configuration, and providing a script that
  performs the partitioning in runtime.</para>

  <orderedlist>
    <listitem>
      <para>Install <emphasis role="italic">partrt</emphasis> in Enea
      Linux</para>
    </listitem>

    <listitem>
      <para><phrase id="enea-linux-realtime-cpu-isolation-boot">Load and
      boot</phrase> Enea Linux on target as described in the <link
      linkend="enea-linux-target">Target Guide</link>, but also add the boot
      parameters <literal>isolcpus</literal><indexterm>
          <primary>isolcpus</primary>
        </indexterm> and <literal>nohz</literal><indexterm>
          <primary>nohz</primary>
        </indexterm> telling which CPUs to isolate.</para>

      <para>If booted by U-Boot:</para>

      <programlisting>setenv bootargs &lt;other params&gt; <emphasis
          role="bold">isolcpus=2,3 nohz_full=2,3</emphasis></programlisting>

      <para>If booted by PXE:</para>

      <programlisting>append &lt;other params&gt; <emphasis role="bold">isolcpus=2,3 nohz_full=2,3</emphasis></programlisting>
    </listitem>

    <listitem>
      <para>After booting the Linux kernel, execute the <emphasis
      role="bold">partrt</emphasis><indexterm>
          <primary>partrt</primary>
        </indexterm> script to create real-time partitions for the isolated
      CPUs. Each CPU is coded as a binary number. The argument to partrt is an
      OR-ed bit mask of the CPU/s to add to the real-time partition, here
      0100<subscript>2</subscript> (CPU 2) OR 1000<subscript>2</subscript>
      (CPU 3) = 1100<subscript>2</subscript> (0xc).</para>

      <programlisting>$ partrt create 0xc</programlisting>

      <para>CPUs 2 and 3 now provide an optimal real-time environment for your
      application.</para>
    </listitem>
  </orderedlist>
</section>