From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id CDCAE44183;
	Fri,  7 Jun 2024 16:33:18 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id BBE1042DC0;
	Fri,  7 Jun 2024 16:33:18 +0200 (CEST)
Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com
 [209.85.161.47]) by mails.dpdk.org (Postfix) with ESMTP id 62E8742D6B
 for <dev@dpdk.org>; Fri,  7 Jun 2024 16:33:17 +0200 (CEST)
Received: by mail-oo1-f47.google.com with SMTP id
 006d021491bc7-5b335681e82so326261eaf.2
 for <dev@dpdk.org>; Fri, 07 Jun 2024 07:33:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=iol.unh.edu; s=unh-iol; t=1717770797; x=1718375597; 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=Lw8tduGVkg362CegXvD87iX7E0OHkDWbfTlvpF1PAO0=;
 b=SXOiVxJenmbipqLAfkNwU8RfOBB6qX70F2erhXprLqtIKj3xDNM09CEWhSSsViVBCT
 8Xboh0h+xBxuR0Tk/pILGouSS1bUKFXkqxoRfwNKclO5IfQUXa8+EiqaNS7ZN4iPRreI
 THYyWbrqCN3lgWGltUT5J195KqXBlr0M4pTV8=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1717770797; x=1718375597;
 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=Lw8tduGVkg362CegXvD87iX7E0OHkDWbfTlvpF1PAO0=;
 b=gqC0+Y3JjWsiaImBO3UIW4NweEyqjATS7B+PlxO6Tts/C4rZLmUkjRzH+YouoLnc+O
 q1yaed6wWmzFipyRbpare6Xwi0ZIiww3LUa7OQ8kYVWW4YJEg82Moyx4R2+dbOj/XGM5
 /C+gVjw3hGGkSPR6MY/pQTah5HTyNKLnmLHmoy3erwH7OYkEDkFwlwwYZLg7ZwUUdUH9
 6dBkqiXlQw039WCuLTl2n2tOIIK7qvoQWmk4O5RkH6gTmB2Y3ReG3fFax4A6pTju6oam
 KxhGZfoY5lizUHRVSUIeKFY100VTPQl+TGuyo8YKi0yqj6Dl3/Zsi4yc7y1zAJIlDf/W
 5UzQ==
X-Gm-Message-State: AOJu0YzQ1Ytz9wplH7ISGKu4QV1QI8YJ4fnaRq+aOkh3dXxEq33w1/WE
 GL5wMqW8NHDiaNUfruXNLryW5DtlLXgWw5vy+NhYGuXX92h+XgG8ABMPxIR6gPU=
X-Google-Smtp-Source: AGHT+IEQO2ulzbuSdA2rpuBJlaXcN3F7O9rJ6NG3i1MNLQv04/Ksu7z/IsJ74jMlQOagqLUvCh/GGQ==
X-Received: by 2002:a05:6870:58c:b0:24f:ddd5:a21d with SMTP id
 586e51a60fabf-254649a6f97mr2774402fac.5.1717770796500; 
 Fri, 07 Jun 2024 07:33:16 -0700 (PDT)
Received: from localhost.unh.edu ([2606:4100:3880:1271:e2f8:4ec3:8bf3:864c])
 by smtp.gmail.com with ESMTPSA id
 af79cd13be357-7954fdd697fsm13108885a.91.2024.06.07.07.33.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 07:33:16 -0700 (PDT)
From: Nicholas Pratte <npratte@iol.unh.edu>
To: paul.szczepanek@arm.com, yoan.picchi@foss.arm.com,
 Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech,
 jspewock@iol.unh.edu, bruce.richardson@intel.com, luca.vizzarro@arm.com,
 probb@iol.unh.edu
Cc: dev@dpdk.org,
	Nicholas Pratte <npratte@iol.unh.edu>
Subject: [PATCH v9 2/2] dts: Change hugepage 'amount' to a different term
Date: Fri,  7 Jun 2024 10:31:20 -0400
Message-ID: <20240607143122.18968-6-npratte@iol.unh.edu>
X-Mailer: git-send-email 2.44.0
In-Reply-To: <20240430184533.29247-4-npratte@iol.unh.edu>
References: <20240430184533.29247-4-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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

The term 'amount' is used for uncountable nouns. Since total hugepages
is a discrete value (i.e. countable), the declaration of the 'amount'
key value pair should be changes to a different term in both the config
and the rest of the code.

Bugzilla ID: 1370

Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
 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 | 12 +++++-------
 dts/framework/testbed_model/node.py          |  2 +-
 dts/framework/testbed_model/os_session.py    |  8 +++-----
 7 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index 56c3ae6f4c..ce475776a7 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -36,7 +36,7 @@ nodes:
     use_first_core: false # tells DPDK to use any physical core
     memory_channels: 4 # tells DPDK to use 4 memory channels
     hugepages_2mb: # optional; if removed, will use system hugepage configuration
-        amount: 256
+        number_of: 256
         force_first_numa: false
     ports:
       # sets up the physical link between "SUT 1"@000:00:08.0 and "TG 1"@0000:00:08.0
@@ -72,7 +72,7 @@ nodes:
         peer_node: "SUT 1"
         peer_pci: "0000:00:08.1"
     hugepages_2mb: # optional; if removed, will use system hugepage configuration
-        amount: 256
+        number_of: 256
         force_first_numa: false
     traffic_generator:
         type: SCAPY
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index b6f820e39e..81dd321b18 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -127,11 +127,11 @@ class HugepageConfiguration:
     r"""The hugepage configuration of :class:`~framework.testbed_model.node.Node`\s.
 
     Attributes:
-        amount: The number of hugepages.
+        number_of: The number of hugepages to allocate.
         force_first_numa: If :data:`True`, the hugepages will be configured on the first NUMA node.
     """
 
-    amount: int
+    number_of: int
     force_first_numa: bool
 
 
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f4d7199523..71c893662a 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -150,9 +150,9 @@
       "type": "object",
       "description": "Optional hugepage configuration. If not specified, hugepages won't be configured and DTS will use system configuration.",
       "properties": {
-        "amount": {
+        "number_of": {
           "type": "integer",
-          "description": "The amount of hugepages to configure. Hugepage size will be the system default."
+          "description": "The number of hugepages to configure. Hugepage size will be the system default."
         },
         "force_first_numa": {
           "type": "boolean",
@@ -161,7 +161,7 @@
       },
       "additionalProperties": false,
       "required": [
-        "amount"
+        "number_of"
       ]
     },
     "mac_address": {
diff --git a/dts/framework/config/types.py b/dts/framework/config/types.py
index 016e0c3dbd..5c9d659901 100644
--- a/dts/framework/config/types.py
+++ b/dts/framework/config/types.py
@@ -37,7 +37,7 @@ class HugepageConfigurationDict(TypedDict):
     """Allowed keys and values."""
 
     #:
-    amount: int
+    number_of: int
     #:
     force_first_numa: bool
 
diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
index d0f7cfa77c..99abc21353 100644
--- a/dts/framework/testbed_model/linux_session.py
+++ b/dts/framework/testbed_model/linux_session.py
@@ -84,9 +84,7 @@ def get_dpdk_file_prefix(self, dpdk_prefix: str) -> str:
         """Overrides :meth:`~.os_session.OSSession.get_dpdk_file_prefix`."""
         return dpdk_prefix
 
-    def setup_hugepages(
-        self, hugepage_count: int, hugepage_size: int, force_first_numa: bool
-    ) -> None:
+    def setup_hugepages(self, number_of: int, hugepage_size: int, force_first_numa: bool) -> None:
         """Overrides :meth:`~.os_session.OSSession.setup_hugepages`."""
         self._logger.info("Getting Hugepage information.")
         hugepages_total = self._get_hugepages_total(hugepage_size)
@@ -97,10 +95,10 @@ def setup_hugepages(
             raise ConfigurationError("hugepage size not supported by operating system")
         self._numa_nodes = self._get_numa_nodes()
 
-        if force_first_numa or hugepages_total < hugepage_count:
+        if force_first_numa or hugepages_total < number_of:
             # 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(number_of, hugepage_size, force_first_numa)
         else:
             self._logger.info("Hugepages already configured.")
         self._mount_huge_pages()
@@ -138,7 +136,7 @@ def _supports_numa(self) -> bool:
         # there's no reason to do any numa specific configuration)
         return len(self._numa_nodes) > 1
 
-    def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool) -> None:
+    def _configure_huge_pages(self, number_of: int, size: int, force_first_numa: bool) -> None:
         self._logger.info("Configuring Hugepages.")
         hugepage_config_path = f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
         if force_first_numa and self._supports_numa():
@@ -149,7 +147,7 @@ def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool)
                 f"/hugepages-{size}kB/nr_hugepages"
             )
 
-        self.send_command(f"echo {amount} | tee {hugepage_config_path}", privileged=True)
+        self.send_command(f"echo {number_of} | tee {hugepage_config_path}", privileged=True)
 
     def update_ports(self, ports: list[Port]) -> None:
         """Overrides :meth:`~.os_session.OSSession.update_ports`."""
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index 3f2a727c3b..6818a057d0 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -266,7 +266,7 @@ def _setup_hugepages(self) -> None:
         """
         if self.config.hugepages:
             self.main_session.setup_hugepages(
-                self.config.hugepages.amount,
+                self.config.hugepages.number_of,
                 self.main_session.hugepage_size,
                 self.config.hugepages.force_first_numa,
             )
diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py
index 19dcf5f963..bba4aca9ce 100644
--- a/dts/framework/testbed_model/os_session.py
+++ b/dts/framework/testbed_model/os_session.py
@@ -347,18 +347,16 @@ def get_dpdk_file_prefix(self, dpdk_prefix: str) -> str:
         """
 
     @abstractmethod
-    def setup_hugepages(
-        self, hugepage_count: int, hugepage_size: int, force_first_numa: bool
-    ) -> None:
+    def setup_hugepages(self, number_of: int, hugepage_size: int, force_first_numa: bool) -> None:
         """Configure hugepages on the node.
 
         Get the node's Hugepage Size, configure the specified count of hugepages
         if needed and mount the hugepages if needed.
 
         Args:
-            hugepage_count: Configure this many hugepages.
+            number_of: Configure this many hugepages.
             hugepage_size: Configure hugepages of this size.
-            force_first_numa:  If :data:`True`, configure hugepages just on the first numa node.
+            force_first_numa:  If :data:`True`, configure just on the first numa node.
         """
 
     @abstractmethod
-- 
2.44.0