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 E6C89A0093; Fri, 17 Jun 2022 13:25:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A0414281E; Fri, 17 Jun 2022 13:25:26 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2056.outbound.protection.outlook.com [40.107.220.56]) by mails.dpdk.org (Postfix) with ESMTP id 6AD11415D7; Fri, 17 Jun 2022 13:25:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JtUZlDexnRIVUhAtVaCTzbsPzmlbeMbowCs9hT5TJ6RN8V+YMwU8M3yUrEy70BSpV7rm823gDuiSKBCBs3DjtWa5SHFDyYKtMRax/0uxpywarH6q3N1fWxWPNYnQ7dE8vM/yzyZK4DY/b93q/qu7bXgQZNjqb8MzCTqZEug9WPuPaswDh6U8YVk2lKeOSZyL4myNh+UgytxjIQYoV7260CgwOkFsKP9RSlJotVL97rC035598qs15Me0tfhEtt2qansx835dELoCu0rjLExp3TMbtyGh5DVFi2l7PsXrj8lEsmb10NVHujYLL6hOlj7c2ISPA0NlO6uPSP2cCDsVcw== 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=KQbag4oLjCAdCMKynvco3BAzSkvOYSXPhM5JY++0a28=; b=LzfO8Az6mpfcFbmvKIrUDfJCtfxh8On+zbzGC59TEdTcLRULh2I764+ipiUAg9uPn+SnGcSfPhouem0UD+M2pF/wUEUVHdBF/i/7PyRhQvBUZkbTcIdHr81OjVdnaNTSnXX0b7MRaNMzxpLBPR4/GFzJZWPd30QN/Gr8Aiqb4vKZQnrnYj/8cbUZOQa3CmV+VLq1AOPcQh4Pa5KCM4Ut7Fhlo8M41z3xtk0FvYS1hYQ8301/UNSVzgXFYgeon3TXh0FLxWvRMiw6iQIIy0lR7qVQ3dgkVm1Hnto1jIkRf522Cm9la54Z5wKsNr7Q/wXBQSXBhRZdWHLSleS6RcMETg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=KQbag4oLjCAdCMKynvco3BAzSkvOYSXPhM5JY++0a28=; b=BwddUK7VuVCxu7QDpzkfO5mySCZ+k9Qux45JOWMhhR/wAVvoZ7nkHs2tUUnhbyIGGXSE0mX8Xs47cTJFV4pyXI7m1xA4Nev3L3UXSf9z6tWh1NIpFsv/S9imaOkxA+YlIkn+Ey1E//OWB6z51flB4hQYEhaatH1LYPpXF6pLUtJxRtDc9dtnUnCc+pr+TFN3P2Z6Wpl/3lHG38lkg46kGrgVXFw6lW5HwZWQZhJ/unr/Oj5tybNlq+iaiAcwtFmWU14hwPb/cTdYdMdKSMLnwu6Gvs79tEcwH58Lc3vN9YPFTR/Cp9brQiR0szCayOzsNT1vEUDQPlQJIF5VtTaIFA== Received: from BN9PR03CA0503.namprd03.prod.outlook.com (2603:10b6:408:130::28) by BYAPR12MB2728.namprd12.prod.outlook.com (2603:10b6:a03:61::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Fri, 17 Jun 2022 11:25:20 +0000 Received: from BN8NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::40) by BN9PR03CA0503.outlook.office365.com (2603:10b6:408:130::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15 via Frontend Transport; Fri, 17 Jun 2022 11:25:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT004.mail.protection.outlook.com (10.13.176.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5353.14 via Frontend Transport; Fri, 17 Jun 2022 11:25:19 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 17 Jun 2022 11:25:18 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.22; Fri, 17 Jun 2022 04:25:18 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Fri, 17 Jun 2022 04:25:17 -0700 From: Dmitry Kozlyuk To: CC: , Anatoly Burakov Subject: [PATCH v2 3/4] doc: give specific instructions for running as non-root Date: Fri, 17 Jun 2022 14:25:07 +0300 Message-ID: <20220617112508.3823291-4-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220617112508.3823291-1-dkozlyuk@nvidia.com> References: <20220607234949.2311884-1-dkozlyuk@nvidia.com> <20220617112508.3823291-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: dc2ef7d1-a0cf-432e-238f-08da50540faa X-MS-TrafficTypeDiagnostic: BYAPR12MB2728:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 75a8mHE/CsOo8jFqWPR1DsUQVo1w7ojt3c46qdTev38uFKqvnmKEUcq8WEXMBEAkYoHOf7dg9c/hiKqmV9egUTXEXOLa5RkercEoEam/cr5wLlsfuVEbyleg9awYVeS1Ai5jJ9vXQCqH1ZZ1hrLljanMPfxl6utBu97BEmFi2Vh+Z7qA1uW8ykOY9JXot8R8yAfetye0RdA7gAF3jQoObcH6rqBlqXpkWTi/Rtjkm0ogAlgFD0xCe6MW9dEMX24zKsFvo0S3hMVBpeYaHKSBCLJwdDv7PP+rHZZ+BB+DFsKPf/lv6LKazznkEqlQs/7WWFQLYFc6AfwKVudGzgT7+LPrDmRR4vovtpOioyjy/IekajzucAiiTa+kiKLoCWwK6f/lV55StHfK2vRC1Z7q/InUrowD/g5pM5OZQrKE0TtB4VIIA30Mx+z6xzCW4JzNUuVAm9s6ekIkpeI4m+zLn+euLv8hT6R/xHJONIwotX4Hr5m5cWul8qQe15SYCJEWeX2c54Zhwy2iwBCW4DNJzDfgrZELHFAnzO0XWijirMT9ODhV3V09A2L4m4d8uqWrbvEIi48ybppLAM2P338WnpLYNo24zk7/s4sVfnOKGTLaBBH3bxUrjl3Bjjm0n9W8XBXAObPA2IY/6UI8wll7w0pL/0r7G2Zw84w3Ka8JEiFxZ4kF0p/SehlFyWm9KFOzXWv42D9t91zlFyjwStN1UBusy1mZIC4x+6N1jXgYRRpOrcrR8OskVQ4Ar+/zkkERSiO92RI99D/pwsMlUpEARWq51yeaI4kO8uSK/wdVvmk13janx23GP5dH87+PRvbD1plVEYFrg8V+vNYV1hZXDg== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(36840700001)(46966006)(40470700004)(8936002)(6286002)(186003)(1076003)(426003)(5660300002)(40460700003)(6916009)(54906003)(498600001)(336012)(83380400001)(36756003)(2616005)(86362001)(36860700001)(82310400005)(6666004)(356005)(47076005)(70586007)(8676002)(70206006)(81166007)(26005)(55016003)(316002)(2906002)(4326008)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 11:25:19.4911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc2ef7d1-a0cf-432e-238f-08da50540faa 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2728 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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 | 67 +++++++++++++++++-- .../prog_guide/env_abstraction_layer.rst | 2 + 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/doc/guides/linux_gsg/enable_func.rst b/doc/guides/linux_gsg/enable_func.rst index 1df3ab0255..2f908e8b70 100644 --- a/doc/guides/linux_gsg/enable_func.rst +++ b/doc/guides/linux_gsg/enable_func.rst @@ -13,13 +13,58 @@ 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 runing 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. + +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,7 +79,15 @@ 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 +See `Hugepage Mapping `_ +secton to learn how these limits affect EAL. + +Device Control +~~~~~~~~~~~~~~ + +If the HPET is to be used, ``/dev/hpet`` permissions must be adjusted. + +Depending on which kernel driver is in use, the relevant resources also should be accessible by the user running the DPDK application. For ``vfio-pci`` kernel driver, the following Linux file system objects' @@ -64,6 +117,8 @@ system objects' permissions should be adjusted: /sys/class/uio/uio0/device/config /sys/class/uio/uio0/device/resource* +For ``virtio`` PMD in legacy mode, ``SYS_RAWIO`` capability is required +for ``iopl()`` call to enable access to PCI IO ports. 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