From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E3684A0032 for ; Fri, 24 Jun 2022 10:48:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D903D42824; Fri, 24 Jun 2022 10:48:37 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2057.outbound.protection.outlook.com [40.107.93.57]) by mails.dpdk.org (Postfix) with ESMTP id E534C427EC; Fri, 24 Jun 2022 10:48:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YCqAIZNPh69n3ROPqq25tvFKm2JRTIvEiELTu8w69wrw/+OPq+2Rz8Ll+MvC1xxVL00EzHjIk+6+i0DnpQ87i0z0AsA2LLhKCR94FcbKggnUsFmLnJLs24WyT3C5oEG28jSQ3RVTUJrrI5tq67qv34qhynS9o+vkG2m3RjETDayXNpUkEUre6K0Arm9ZbSjMr6tpAOPp8tuAvT8AbXbmgCit6VzoylwmRs0FYjlrR9eCH8eIu3zgzDsezndeO76SUxND4yQLtjLIZyyw/zErI7Dt62Fo0wVXbmXfq+ENzJ3zmFze0m/P41+2pNjesOdlCGoW87p5s8vSu1XEVj/jZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YTy5CX7hX47cHHWqSQMM67Fp3rcF40HIIQgJw6YJoUg=; b=PRx15ToiY4v+/69sTLLZzSQESlPL0/up6Im8MoogBHZRCPaKwU2ECFvzYr29A6ev6TLhamLpN6d7l8R6/BP5W7ukuFhjRr4gJf0vd3xBAx7PA4/L6DzmzSSN7jUvtOGt9ogRaiCQrEs7J4QjYdOK/XayqtO6aw5vU+s7JdVK7Z1/Ks2u8NWOV04JYIMs/t+IZY0ofAidkezJTzf8rwNP7BI9TJNO8LwEWBr8846tAVdpuyCZdsK4jcmde9JwdOlkpkVuYzment5IDCaBxQAsAVNVaK0L31XHBTEDiXsU9cLB1iHHYzRxUb8D0UDsUWFek388CM2vSrEceSA8+1A4HQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YTy5CX7hX47cHHWqSQMM67Fp3rcF40HIIQgJw6YJoUg=; b=CDAmSifebCAm+VUz2Ayr4uz/ifOIOUNe21ekcVp1Opz8buEmEhXgGymTdWpF8I35H4ThcUJpoz2Pl/SmNrOhn3kLBa6UtFBILxkNc0WFhTAW8pX0XaSk2Bg8nVv6cEtEwK8Gw2mneM8okUVxw1MkAuHc01Q6WIF1Xl0FolYTBlwkrINAMX/ekl45933TdHFp9Y8GxGNBIPNwr9qzB4pewasmTYFQrnHj0rajA6jog7FHio7vp9TsAPGO5Iy33sLHXDJGwx1ufHsLhVJdk9ObUdmSJZohyV+7M0C52SRi9b5aU7/k6fyvniBP6gcN8CeXthQlf3STyrHMXOy6Aq6AEg== Received: from DS7PR03CA0037.namprd03.prod.outlook.com (2603:10b6:5:3b5::12) by BY5PR12MB4836.namprd12.prod.outlook.com (2603:10b6:a03:1fc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Fri, 24 Jun 2022 08:48:32 +0000 Received: from DM6NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b5:cafe::93) by DS7PR03CA0037.outlook.office365.com (2603:10b6:5:3b5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17 via Frontend Transport; Fri, 24 Jun 2022 08:48:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT030.mail.protection.outlook.com (10.13.172.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5373.15 via Frontend Transport; Fri, 24 Jun 2022 08:48:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 24 Jun 2022 08:48:30 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 24 Jun 2022 01:48:29 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Fri, 24 Jun 2022 01:48:28 -0700 From: Dmitry Kozlyuk To: CC: , Anatoly Burakov Subject: [PATCH v3 3/5] doc: give specific instructions for running as non-root Date: Fri, 24 Jun 2022 11:48:15 +0300 Message-ID: <20220624084817.63145-4-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624084817.63145-1-dkozlyuk@nvidia.com> References: <20220617112508.3823291-1-dkozlyuk@nvidia.com> <20220624084817.63145-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d8d3f08-1091-48c6-426a-08da55be50d6 X-MS-TrafficTypeDiagnostic: BY5PR12MB4836:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?O7I355ln92zQh49AIjtPOIjXY3ENLOIc7Qo47+RrnZfDigDsHI6SzqwmgJ0P?= =?us-ascii?Q?/pWljdQEvaN+kz86FNhYZXyld4XiQilpAUgpMVbgnpdmWawGuN85miG7W8a+?= =?us-ascii?Q?9riNEAyEmaNhsc5N997pCsoO/ZxXpR4xGzv92pV2khglAMJLpi9OEYqLLW2n?= =?us-ascii?Q?uVE8uUwWj+o101EoTJfBb31MN1L/kYTT518tZoGRX9TeLyP1h0CEJkNBV2ss?= =?us-ascii?Q?4lR+ECPym3ec3pFhN08cbYfFtHajWqL5z1w2TTd4JDvZkouIrT1iZpgQhRp3?= =?us-ascii?Q?GEZjy2c5Q+1ErKLvof1w1E4afW6kpgNvxnsVJt39ZZvelpC6wywHFQp/OPXI?= =?us-ascii?Q?SfLz02PBv8qxVRTZaIe7VKf3XgliuQIoy6DMlp5mCgxdY416sammuN6uZ/ek?= =?us-ascii?Q?u9+1yGi6iZAIUQ3Dk1TtrFf6W0uiBqkboHi6jS1e4tyw6PQqceGc3o2Q31+s?= =?us-ascii?Q?EHY9Xc1mzJETRpGvwJ/dC9/iY/9DHz29uJvzoY7w32tcr926ajrTImE6V9yK?= =?us-ascii?Q?a403G6pJEN4KDWgUcktvEwLI+FbRlWXb+jF7nXYiC66ESBcFiYOTfycIiLZT?= =?us-ascii?Q?3t2RWjT7eUnNfebMTafO5p1mrmiN4sJTA/l2WzhfPeaNbp3jhsiSn+hfoc7O?= =?us-ascii?Q?6ek8D3sUybgWNhF1fBzkIc21RXm2Ea2MBa9F6bPhrTsSgm1IsNktgUyv9Ue7?= =?us-ascii?Q?2EFi3/rjv1AqEF3OY70AKmmn1chv4nsa2Amy9qA+pwAEswEbD6AHftgVFIll?= =?us-ascii?Q?42ykijSvSy0w2hv50Ek+Cprx8N62s/em0lSEQ2jLO65uufP/cKgbi4SEtp1P?= =?us-ascii?Q?lFgf6HGZAWBYkouU5dUOIe3otbqCb4qim7SHKNMgv7RPfOoYkkTBBztLjp5o?= =?us-ascii?Q?qdlovsEdNuqIWnxOBu+Nk2hDaHO95zl4Q+RwVnYQ5m5y9r+R+kqG9uGMgo79?= =?us-ascii?Q?KKT0mVzP3obtygb8Q6hoew=3D=3D?= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(346002)(136003)(376002)(396003)(46966006)(36840700001)(40470700004)(83380400001)(186003)(7696005)(41300700001)(2906002)(2616005)(47076005)(8936002)(478600001)(336012)(426003)(1076003)(55016003)(36756003)(82310400005)(40480700001)(40460700003)(356005)(82740400003)(54906003)(36860700001)(26005)(6286002)(8676002)(70206006)(5660300002)(70586007)(86362001)(6666004)(316002)(81166007)(6916009)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 08:48:31.3462 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d8d3f08-1091-48c6-426a-08da55be50d6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4836 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The guide to run DPDK applications as non-root in Linux did not provide specific instructions to configure the required access and did not explain why each bit is needed. The latter is important because running as non-root is one of the ways to tighten security and grant minimal permissions. Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk --- doc/guides/linux_gsg/enable_func.rst | 89 +++++++++++++------ .../prog_guide/env_abstraction_layer.rst | 2 + 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/doc/guides/linux_gsg/enable_func.rst b/doc/guides/linux_gsg/enable_func.rst index 1df3ab0255..0b57417c94 100644 --- a/doc/guides/linux_gsg/enable_func.rst +++ b/doc/guides/linux_gsg/enable_func.rst @@ -13,13 +13,63 @@ Enabling Additional Functionality Running DPDK Applications Without Root Privileges ------------------------------------------------- -In order to run DPDK as non-root, the following Linux filesystem objects' -permissions should be adjusted to ensure that the Linux account being used to -run the DPDK application has access to them: +The following sections describe generic requirements and configuration +for running DPDK applications as non-root. +There may be additional requirements documented for some drivers. -* All directories which serve as hugepage mount points, for example, ``/dev/hugepages`` +Hugepages +~~~~~~~~~ -* If the HPET is to be used, ``/dev/hpet`` +Hugepages must be reserved as root before running the application as non-root, +for example:: + + sudo dpdk-hugepages.py --reserve 1G + +If multi-process is not required, running with ``--in-memory`` +bypasses the need to access hugepage mount point and files within it. +Otherwise, hugepage directory must be made accessible +for writing to the unprivileged user. +A good way for managing multiple applications using hugepages +is to mount the filesystem with group permissions +and add a supplementary group to each application or container. + +One option is to use the script provided by this project:: + + export HUGEDIR=$HOME/huge-1G + mkdir -p $HUGEDIR + sudo dpdk-hugepages.py --mount --directory $HUGEDIR --owner `id -u`:`id -g` + +In production environment, the OS can manage mount points +(`systemd example `_). + +The ``hugetlb`` filesystem has additional options to guarantee or limit +the amount of memory that is possible to allocate using the mount point. +Refer to the `documentation `_. + +If the driver requires using physical addresses (PA), +the executable file must be granted additional capabilities: + +* ``SYS_ADMIN`` to read ``/proc/self/pagemaps`` +* ``IPC_LOCK`` to lock hugepages in memory + +.. code-block:: console + + setcap cap_ipc_lock,cap_sys_admin+ep + +If physical addresses are not accessible, +the following message will appear during EAL initialization:: + + EAL: rte_mem_virt2phy(): cannot open /proc/self/pagemap: Permission denied + +It is harmless in case PA are not needed. + +.. note:: + + Using ``vfio-pci`` kernel driver, if applicable, can eliminate the need + for physical addresses and therefore reduce the permission requirements. + +Resource Limits +~~~~~~~~~~~~~~~ When running as non-root user, there may be some additional resource limits that are imposed by the system. Specifically, the following resource limits may @@ -34,8 +84,13 @@ need to be adjusted in order to ensure normal DPDK operation: The above limits can usually be adjusted by editing ``/etc/security/limits.conf`` file, and rebooting. -Additionally, depending on which kernel driver is in use, the relevant -resources also should be accessible by the user running the DPDK application. +See `Hugepage Mapping `_ +section to learn how these limits affect EAL. + +Device Control +~~~~~~~~~~~~~~ + +If the HPET is to be used, ``/dev/hpet`` permissions must be adjusted. For ``vfio-pci`` kernel driver, the following Linux file system objects' permissions should be adjusted: @@ -45,26 +100,6 @@ permissions should be adjusted: * The directories under ``/dev/vfio`` that correspond to IOMMU group numbers of devices intended to be used by DPDK, for example, ``/dev/vfio/50`` -.. note:: - - The instructions below will allow running DPDK with ``igb_uio`` or - ``uio_pci_generic`` drivers as non-root with older Linux kernel versions. - However, since version 4.0, the kernel does not allow unprivileged processes - to read the physical address information from the pagemaps file, making it - impossible for those processes to be used by non-privileged users. In such - cases, using the VFIO driver is recommended. - -For ``igb_uio`` or ``uio_pci_generic`` kernel drivers, the following Linux file -system objects' permissions should be adjusted: - -* The userspace-io device files in ``/dev``, for example, ``/dev/uio0``, ``/dev/uio1``, and so on - -* The userspace-io sysfs config and resource files, for example for ``uio0``:: - - /sys/class/uio/uio0/device/config - /sys/class/uio/uio0/device/resource* - - Power Management and Power Saving Functionality ----------------------------------------------- diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 5f0748fba1..70fa099d30 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -228,6 +228,8 @@ Normally, these options do not need to be changed. can later be mapped into that preallocated VA space (if dynamic memory mode is enabled), and can optionally be mapped into it at startup. +.. _hugepage_mapping: + Hugepage Mapping ^^^^^^^^^^^^^^^^ -- 2.25.1