xref: /dpdk/doc/guides/linux_gsg/enable_func.rst (revision 592ab76f9f0f41993bebb44da85c37750a93ece9)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2010-2014 Intel Corporation.
3
4.. include:: <isonum.txt>
5
6.. _Enabling_Additional_Functionality:
7
8Enabling Additional Functionality
9=================================
10
11.. _Running_Without_Root_Privileges:
12
13Running DPDK Applications Without Root Privileges
14-------------------------------------------------
15
16In order to run DPDK as non-root, the following Linux filesystem objects'
17permissions should be adjusted to ensure that the Linux account being used to
18run the DPDK application has access to them:
19
20*   All directories which serve as hugepage mount points, for example, ``/dev/hugepages``
21
22*   If the HPET is to be used,  ``/dev/hpet``
23
24When running as non-root user, there may be some additional resource limits
25that are imposed by the system. Specifically, the following resource limits may
26need to be adjusted in order to ensure normal DPDK operation:
27
28* RLIMIT_LOCKS (number of file locks that can be held by a process)
29
30* RLIMIT_NOFILE (number of open file descriptors that can be held open by a process)
31
32* RLIMIT_MEMLOCK (amount of pinned pages the process is allowed to have)
33
34The above limits can usually be adjusted by editing
35``/etc/security/limits.conf`` file, and rebooting.
36
37Additionally, depending on which kernel driver is in use, the relevant
38resources also should be accessible by the user running the DPDK application.
39
40For ``vfio-pci`` kernel driver, the following Linux file system objects'
41permissions should be adjusted:
42
43* The VFIO device file, ``/dev/vfio/vfio``
44
45* The directories under ``/dev/vfio`` that correspond to IOMMU group numbers of
46  devices intended to be used by DPDK, for example, ``/dev/vfio/50``
47
48.. note::
49
50    The instructions below will allow running DPDK with ``igb_uio`` or
51    ``uio_pci_generic`` drivers as non-root with older Linux kernel versions.
52    However, since version 4.0, the kernel does not allow unprivileged processes
53    to read the physical address information from the pagemaps file, making it
54    impossible for those processes to be used by non-privileged users. In such
55    cases, using the VFIO driver is recommended.
56
57For ``igb_uio`` or ``uio_pci_generic`` kernel drivers, the following Linux file
58system objects' permissions should be adjusted:
59
60*   The userspace-io device files in  ``/dev``, for example,  ``/dev/uio0``, ``/dev/uio1``, and so on
61
62*   The userspace-io sysfs config and resource files, for example for ``uio0``::
63
64       /sys/class/uio/uio0/device/config
65       /sys/class/uio/uio0/device/resource*
66
67
68Power Management and Power Saving Functionality
69-----------------------------------------------
70
71Enhanced Intel SpeedStep\ |reg| Technology must be enabled in the platform BIOS if the power management feature of DPDK is to be used.
72Otherwise, the sys file folder ``/sys/devices/system/cpu/cpu0/cpufreq`` will not exist, and the CPU frequency- based power management cannot be used.
73Consult the relevant BIOS documentation to determine how these settings can be accessed.
74
75For example, on some Intel reference platform BIOS variants, the path to Enhanced Intel SpeedStep\ |reg| Technology is::
76
77   Advanced
78     -> Processor Configuration
79     -> Enhanced Intel SpeedStep\ |reg| Tech
80
81In addition, C3 and C6 should be enabled as well for power management. The path of C3 and C6 on the same platform BIOS is::
82
83   Advanced
84     -> Processor Configuration
85     -> Processor C3 Advanced
86     -> Processor Configuration
87     -> Processor C6
88
89Using Linux Core Isolation to Reduce Context Switches
90-----------------------------------------------------
91
92While the threads used by a DPDK application are pinned to logical cores on the system,
93it is possible for the Linux scheduler to run other tasks on those cores also.
94To help prevent additional workloads from running on those cores,
95it is possible to use the ``isolcpus`` Linux kernel parameter to isolate them from the general Linux scheduler.
96
97For example, if DPDK applications are to run on logical cores 2, 4 and 6,
98the following should be added to the kernel parameter list:
99
100.. code-block:: console
101
102    isolcpus=2,4,6
103
104.. _High_Precision_Event_Timer:
105
106High Precision Event Timer (HPET) Functionality
107-----------------------------------------------
108
109DPDK can support the system HPET as a timer source rather than the system default timers,
110such as the core Time-Stamp Counter (TSC) on x86 systems.
111To enable HPET support in DPDK:
112
113#. Ensure that HPET is enabled in BIOS settings.
114#. Enable ``HPET_MMAP`` support in kernel configuration.
115   Note that this my involve doing a kernel rebuild,
116   as many common linux distributions do *not* have this setting
117   enabled by default in their kernel builds.
118#. Enable DPDK support for HPET by using the build-time meson option ``use_hpet``,
119   for example, ``meson configure -Duse_hpet=true``
120
121For an application to use the ``rte_get_hpet_cycles()`` and ``rte_get_hpet_hz()`` API calls,
122and optionally to make the HPET the default time source for the rte_timer library,
123the ``rte_eal_hpet_init()`` API call should be called at application initialization.
124This API call will ensure that the HPET is accessible,
125returning an error to the application if it is not.
126
127For applications that require timing APIs, but not the HPET timer specifically,
128it is recommended that the ``rte_get_timer_cycles()`` and ``rte_get_timer_hz()``
129API calls be used instead of the HPET-specific APIs.
130These generic APIs can work with either TSC or HPET time sources,
131depending on what is requested by an application call to ``rte_eal_hpet_init()``,
132if any, and on what is available on the system at runtime.
133