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 416D443E2C; Tue, 9 Apr 2024 19:29:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12F82402EB; Tue, 9 Apr 2024 19:29:51 +0200 (CEST) Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) by mails.dpdk.org (Postfix) with ESMTP id 88B2B402C7 for ; Tue, 9 Apr 2024 19:29:49 +0200 (CEST) Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-22ec8db3803so443574fac.1 for ; Tue, 09 Apr 2024 10:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1712683789; x=1713288589; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2LkRJl0nzbaWyEjd/4HkfnZ6RCSoaNSZX7Bs9QnHEMc=; b=S0KZi6bL6Urxcqx28GTFdYSmjKxA7EaLeh5UWLVi5oD5IqAa71HzL6+CyqViYPeZeJ fQlcegMV9KPAI7iAlp0gXOLufq1QfHdBIpkfQPPAitZCftoe0no/adSdGlBRBUmqJXQw 7VCqVxHDtplEI6pgM7AG2Q+eDzGxoEPPU1ncg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712683789; x=1713288589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2LkRJl0nzbaWyEjd/4HkfnZ6RCSoaNSZX7Bs9QnHEMc=; b=tBZDuM7WRQqxAD2soBAHOEoqGPog+BItwyxkEF9YmYhDd2WET161FHKwzTxp4dkrvQ 3+B9N4rX52G0VVYZfH7KyfKO+Xn0nnCPIm7uQUGpZ3B584h5Vd0y/d0MPOHHnkFhSMKe eVjT5CMwtZs0jbOH/uxjd26S4iRN6Ver5/VVniqAFdEwbl8QeAQL5UAVQX9+VjhK0PFt Samd9kmIlafqG0Kxew6wPvR2oRo8nZsW4AEeAGAwxRdRfD4LvQKTkk4fzOl2t/5OGtGs bKHN3LosoSEmv8Yno6lni0mLpsEy6yvpmZsFs/2Bga8qiDwB3P9RDdHzGP8X79BzY9Px 1AYw== X-Gm-Message-State: AOJu0Yy1o/xIWhChYZ78O3mksv/Szl9xJ4rm7MuVjRQWvp81i6EPMDWo Bb/xQzdMHq2V2DnyaYVaoXSgAiT3DAS+520AsNt6ZY6BH5f7ot/dNY7rTBBlv6g= X-Google-Smtp-Source: AGHT+IF1T4qIlabz4u62Isc5AuzI2nriXQaWefr92t/1E7qHlG0cmvjfO6PPINyRaXOtbQsaUWbISg== X-Received: by 2002:a05:6871:e01c:b0:22e:88bd:6b26 with SMTP id by28-20020a056871e01c00b0022e88bd6b26mr237159oac.3.1712683788728; Tue, 09 Apr 2024 10:29:48 -0700 (PDT) Received: from d121028.iol.unh.edu ([2606:4100:3880:1271:e2f8:4ec3:8bf3:864c]) by smtp.gmail.com with ESMTPSA id pi34-20020a05620a37a200b0078bdce0acecsm4299919qkn.80.2024.04.09.10.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 10:29:47 -0700 (PDT) From: Nicholas Pratte To: paul.szczepanek@arm.com, bruce.richardson@intel.com, yoan.picchi@foss.arm.com, juraj.linkes@pantheon.tech, jspewock@iol.unh.edu, thomas@monjalon.net, mb@smartsharesystems.com, wathsala.vithanage@arm.com, probb@iol.unh.edu, Honnappa.Nagarahalli@arm.com Cc: dev@dpdk.org, Nicholas Pratte Subject: [PATCH v2] dts: Change hugepage runtime config to 2MB Exclusively Date: Tue, 9 Apr 2024 13:28:11 -0400 Message-ID: <20240409172811.27866-1-npratte@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404153106.19047-1-npratte@iol.unh.edu> References: <20240404153106.19047-1-npratte@iol.unh.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 previous implementation configures and allocates hugepage sizes based on a system default. This can lead to two problems: overallocation of hugepages (which may crash the remote host), and configuration of hugepage sizes that are not recommended during runtime. This new implementation allows only 2MB hugepage allocation during runtime; any other unique hugepage size must be configured by the end-user for initializing DTS. If the amount of 2MB hugepages requested exceeds the amount of 2MB hugepages already configured on the system, then the system will remount hugepages to cover the difference. If the amount of hugepages requested is either less than or equal to the amount already configured on the system, then nothing is done. Bugzilla ID: 1370 Signed-off-by: Nicholas Pratte Reviewed-by: Jeremy Spewock --- dts/conf.yaml | 4 ++-- dts/framework/config/__init__.py | 4 ++-- dts/framework/config/conf_yaml_schema.json | 6 +++--- dts/framework/config/types.py | 2 +- dts/framework/testbed_model/linux_session.py | 15 ++++++--------- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/dts/conf.yaml b/dts/conf.yaml index 8068345dd5..56c3ae6f4c 100644 --- a/dts/conf.yaml +++ b/dts/conf.yaml @@ -35,7 +35,7 @@ nodes: lcores: "" # use all the available logical cores use_first_core: false # tells DPDK to use any physical core memory_channels: 4 # tells DPDK to use 4 memory channels - hugepages: # optional; if removed, will use system hugepage configuration + hugepages_2mb: # optional; if removed, will use system hugepage configuration amount: 256 force_first_numa: false ports: @@ -71,7 +71,7 @@ nodes: os_driver: rdma peer_node: "SUT 1" peer_pci: "0000:00:08.1" - hugepages: # optional; if removed, will use system hugepage configuration + hugepages_2mb: # optional; if removed, will use system hugepage configuration amount: 256 force_first_numa: false traffic_generator: diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py index 4cb5c74059..b6f820e39e 100644 --- a/dts/framework/config/__init__.py +++ b/dts/framework/config/__init__.py @@ -255,8 +255,8 @@ def from_dict( Either an SUT or TG configuration instance. """ hugepage_config = None - if "hugepages" in d: - hugepage_config_dict = d["hugepages"] + if "hugepages_2mb" in d: + hugepage_config_dict = d["hugepages_2mb"] if "force_first_numa" not in hugepage_config_dict: hugepage_config_dict["force_first_numa"] = False hugepage_config = HugepageConfiguration(**hugepage_config_dict) diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json index 4731f4511d..f4d7199523 100644 --- a/dts/framework/config/conf_yaml_schema.json +++ b/dts/framework/config/conf_yaml_schema.json @@ -146,7 +146,7 @@ "compiler" ] }, - "hugepages": { + "hugepages_2mb": { "type": "object", "description": "Optional hugepage configuration. If not specified, hugepages won't be configured and DTS will use system configuration.", "properties": { @@ -253,8 +253,8 @@ "type": "integer", "description": "How many memory channels to use. Optional, defaults to 1." }, - "hugepages": { - "$ref": "#/definitions/hugepages" + "hugepages_2mb": { + "$ref": "#/definitions/hugepages_2mb" }, "ports": { "type": "array", diff --git a/dts/framework/config/types.py b/dts/framework/config/types.py index 1927910d88..016e0c3dbd 100644 --- a/dts/framework/config/types.py +++ b/dts/framework/config/types.py @@ -46,7 +46,7 @@ class NodeConfigDict(TypedDict): """Allowed keys and values.""" #: - hugepages: HugepageConfigurationDict + hugepages_2mb: HugepageConfigurationDict #: name: str #: diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py index 5d24030c3d..37f5eacb21 100644 --- a/dts/framework/testbed_model/linux_session.py +++ b/dts/framework/testbed_model/linux_session.py @@ -15,7 +15,7 @@ from typing_extensions import NotRequired -from framework.exception import RemoteCommandExecutionError +from framework.exception import ConfigurationError, RemoteCommandExecutionError from framework.utils import expand_range from .cpu import LogicalCore @@ -87,25 +87,22 @@ def get_dpdk_file_prefix(self, dpdk_prefix: str) -> str: def setup_hugepages(self, hugepage_count: int, force_first_numa: bool) -> None: """Overrides :meth:`~.os_session.OSSession.setup_hugepages`.""" self._logger.info("Getting Hugepage information.") - hugepage_size = self._get_hugepage_size() + if "hugepages-2048kB" not in self.send_command("ls /sys/kernel/mm/hugepages").stdout: + raise ConfigurationError("2MB hugepages not supported by operating system") hugepages_total = self._get_hugepages_total() self._numa_nodes = self._get_numa_nodes() - if force_first_numa or hugepages_total != hugepage_count: + if force_first_numa or hugepages_total < hugepage_count: # when forcing numa, we need to clear existing hugepages regardless # of size, so they can be moved to the first numa node - self._configure_huge_pages(hugepage_count, hugepage_size, force_first_numa) + self._configure_huge_pages(hugepage_count, 2048, force_first_numa) else: self._logger.info("Hugepages already configured.") self._mount_huge_pages() - def _get_hugepage_size(self) -> int: - hugepage_size = self.send_command("awk '/Hugepagesize/ {print $2}' /proc/meminfo").stdout - return int(hugepage_size) - def _get_hugepages_total(self) -> int: hugepages_total = self.send_command( - "awk '/HugePages_Total/ { print $2 }' /proc/meminfo" + "cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" ).stdout return int(hugepages_total) -- 2.44.0