2 Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
15 * Neither the name of Intel Corporation nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .. _Multi-process_Support:
36 In the DPDK, multi-process support is designed to allow a group of DPDK processes
37 to work together in a simple transparent manner to perform packet processing,
38 or other workloads, on IntelĀ® architecture hardware.
39 To support this functionality,
40 a number of additions have been made to the core DPDK Environment Abstraction Layer (EAL).
42 The EAL has been modified to allow different types of DPDK processes to be spawned,
43 each with different permissions on the hugepage memory used by the applications.
44 For now, there are two types of process specified:
46 * primary processes, which can initialize and which have full permissions on shared memory
48 * secondary processes, which cannot initialize shared memory,
49 but can attach to pre- initialized shared memory and create objects in it.
51 Standalone DPDK processes are primary processes,
52 while secondary processes can only run alongside a primary process or
53 after a primary process has already configured the hugepage shared memory for them.
55 To support these two process types, and other multi-process setups described later,
56 two additional command-line parameters are available to the EAL:
58 * ``--proc-type:`` for specifying a given process instance as the primary or secondary DPDK instance
60 * ``--file-prefix:`` to allow processes that do not want to co-operate to have different memory regions
62 A number of example applications are provided that demonstrate how multiple DPDK processes can be used together.
63 These are more fully documented in the "Multi- process Sample Application" chapter
64 in the *DPDK Sample Application's User Guide*.
69 The key element in getting a multi-process application working using the DPDK is to ensure that
70 memory resources are properly shared among the processes making up the multi-process application.
71 Once there are blocks of shared memory available that can be accessed by multiple processes,
72 then issues such as inter-process communication (IPC) becomes much simpler.
74 On application start-up in a primary or standalone process,
75 the DPDK records to memory-mapped files the details of the memory configuration it is using - hugepages in use,
76 the virtual addresses they are mapped at, the number of memory channels present, etc.
77 When a secondary process is started, these files are read and the EAL recreates the same memory configuration
78 in the secondary process so that all memory zones are shared between processes and all pointers to that memory are valid,
79 and point to the same objects, in both processes.
83 Refer to `Multi-process Limitations`_ for details of
84 how Linux kernel Address-Space Layout Randomization (ASLR) can affect memory sharing.
86 .. _figure_multi_process_memory:
88 .. figure:: img/multi_process_memory.*
90 Memory Sharing in the DPDK Multi-process Sample Application
93 The EAL also supports an auto-detection mode (set by EAL ``--proc-type=auto`` flag ),
94 whereby an DPDK process is started as a secondary instance if a primary instance is already running.
99 Symmetric/Peer Processes
100 ~~~~~~~~~~~~~~~~~~~~~~~~
102 DPDK multi-process support can be used to create a set of peer processes where each process performs the same workload.
103 This model is equivalent to having multiple threads each running the same main-loop function,
104 as is done in most of the supplied DPDK sample applications.
105 In this model, the first of the processes spawned should be spawned using the ``--proc-type=primary`` EAL flag,
106 while all subsequent instances should be spawned using the ``--proc-type=secondary`` flag.
108 The simple_mp and symmetric_mp sample applications demonstrate this usage model.
109 They are described in the "Multi-process Sample Application" chapter in the *DPDK Sample Application's User Guide*.
111 Asymmetric/Non-Peer Processes
112 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114 An alternative deployment model that can be used for multi-process applications
115 is to have a single primary process instance that acts as a load-balancer or
116 server distributing received packets among worker or client threads, which are run as secondary processes.
117 In this case, extensive use of rte_ring objects is made, which are located in shared hugepage memory.
119 The client_server_mp sample application shows this usage model.
120 It is described in the "Multi-process Sample Application" chapter in the *DPDK Sample Application's User Guide*.
122 Running Multiple Independent DPDK Applications
123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125 In addition to the above scenarios involving multiple DPDK processes working together,
126 it is possible to run multiple DPDK processes side-by-side,
127 where those processes are all working independently.
128 Support for this usage scenario is provided using the ``--file-prefix`` parameter to the EAL.
130 By default, the EAL creates hugepage files on each hugetlbfs filesystem using the rtemap_X filename,
131 where X is in the range 0 to the maximum number of hugepages -1.
132 Similarly, it creates shared configuration files, memory mapped in each process, using the /var/run/.rte_config filename,
133 when run as root (or $HOME/.rte_config when run as a non-root user;
134 if filesystem and device permissions are set up to allow this).
135 The rte part of the filenames of each of the above is configurable using the file-prefix parameter.
137 In addition to specifying the file-prefix parameter,
138 any DPDK applications that are to be run side-by-side must explicitly limit their memory use.
139 This is done by passing the -m flag to each process to specify how much hugepage memory, in megabytes,
140 each process can use (or passing ``--socket-mem`` to specify how much hugepage memory on each socket each process can use).
144 Independent DPDK instances running side-by-side on a single machine cannot share any network ports.
145 Any network ports being used by one process should be blacklisted in every other process.
147 Running Multiple Independent Groups of DPDK Applications
148 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150 In the same way that it is possible to run independent DPDK applications side- by-side on a single system,
151 this can be trivially extended to multi-process groups of DPDK applications running side-by-side.
152 In this case, the secondary processes must use the same ``--file-prefix`` parameter
153 as the primary process whose shared memory they are connecting to.
157 All restrictions and issues with multiple independent DPDK processes running side-by-side
158 apply in this usage scenario also.
160 Multi-process Limitations
161 -------------------------
163 There are a number of limitations to what can be done when running DPDK multi-process applications.
164 Some of these are documented below:
166 * The multi-process feature requires that the exact same hugepage memory mappings be present in all applications.
167 The Linux security feature - Address-Space Layout Randomization (ASLR) can interfere with this mapping,
168 so it may be necessary to disable this feature in order to reliably run multi-process applications.
172 Disabling Address-Space Layout Randomization (ASLR) may have security implications,
173 so it is recommended that it be disabled only when absolutely necessary,
174 and only when the implications of this change have been understood.
176 * All DPDK processes running as a single application and using shared memory must have distinct coremask arguments.
177 It is not possible to have a primary and secondary instance, or two secondary instances,
178 using any of the same logical cores.
179 Attempting to do so can cause corruption of memory pool caches, among other issues.
181 * The delivery of interrupts, such as Ethernet* device link status interrupts, do not work in secondary processes.
182 All interrupts are triggered inside the primary process only.
183 Any application needing interrupt notification in multiple processes should provide its own mechanism
184 to transfer the interrupt information from the primary process to any secondary process that needs the information.
186 * The use of function pointers between multiple processes running based of different compiled binaries is not supported,
187 since the location of a given function in one process may be different to its location in a second.
188 This prevents the librte_hash library from behaving properly as in a multi-threaded instance,
189 since it uses a pointer to the hash function internally.
191 To work around this issue, it is recommended that multi-process applications perform the hash calculations by directly calling
192 the hashing function from the code and then using the rte_hash_add_with_hash()/rte_hash_lookup_with_hash() functions
193 instead of the functions which do the hashing internally, such as rte_hash_add()/rte_hash_lookup().
195 * Depending upon the hardware in use, and the number of DPDK processes used,
196 it may not be possible to have HPET timers available in each DPDK instance.
197 The minimum number of HPET comparators available to Linux* userspace can be just a single comparator,
198 which means that only the first, primary DPDK process instance can open and mmap /dev/hpet.
199 If the number of required DPDK processes exceeds that of the number of available HPET comparators,
200 the TSC (which is the default timer in this release) must be used as a time source across all processes instead of the HPET.