Skip to contentSkip to conversation

eal: remove plural syntax for single resource

PATCH In review Thomas Monjalon 2 participants 6 messages Sep 15, 2021 – Sep 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: remove plural syntax for single resource

Some comments and logs about cores, nodes and pages were using plural or hypotetic plural (s) form even if preceded by "0" or "no".

It is replaced with singular form where appropriate.

---
 lib/eal/common/eal_common_lcore.c | 13 +++++++++----
 lib/eal/common/rte_malloc.c       |  4 ++--
 lib/eal/linux/eal_hugepage_info.c |  4 ++--
 lib/eal/linux/eal_memory.c        |  4 ++--
 4 files changed, 15 insertions(+), 10 deletions(-)
lib/eal/common/eal_common_lcore.c +9 -4
index 66d6bad1a7..6778ecc98f 100644
@@ -191,9 +191,12 @@ rte_eal_cpu_init(void)
 	/* Set the count of enabled logical cores of the EAL configuration */
 	config->lcore_count = count;
 	RTE_LOG(DEBUG, EAL,
-		"Support maximum %u logical core(s) by configuration.\n",
-		RTE_MAX_LCORE);
-	RTE_LOG(INFO, EAL, "Detected %u lcore(s)\n", config->lcore_count);
+			"Support maximum %u logical core%s by configuration.\n",
+			RTE_MAX_LCORE,
+			RTE_MAX_LCORE > 1 ? "s" : "");
+	RTE_LOG(INFO, EAL, "Detected %u lcore%s\n",
+			config->lcore_count,
+			config->lcore_count > 1 ? "s" : "");
 
 	/* sort all socket id's in ascending order */
 	qsort(lcore_to_socket_id, RTE_DIM(lcore_to_socket_id),
@@ -208,7 +211,9 @@ rte_eal_cpu_init(void)
 					socket_id;
 		prev_socket_id = socket_id;
 	}
-	RTE_LOG(INFO, EAL, "Detected %u NUMA nodes\n", config->numa_node_count);
+	RTE_LOG(INFO, EAL, "Detected %u NUMA node%s\n",
+			config->numa_node_count,
+			config->numa_node_count > 1 ? "s" : "");
 
 	return 0;
 }
lib/eal/common/rte_malloc.c +2 -2
index 9d39e58c08..04cbb0078b 100644
@@ -65,10 +65,10 @@ malloc_socket(const char *type, size_t size, unsigned int align,
 	if (size == 0 || (align && !rte_is_power_of_2(align)))
 		return NULL;
 
-	/* if there are no hugepages and if we are not allocating from an
+	/* if there are no hugepage and if we are not allocating from an
 	 * external heap, use memory from any socket available. checking for
 	 * socket being external may return -1 in case of invalid socket, but
-	 * that's OK - if there are no hugepages, it doesn't matter.
+	 * that's OK - if there are no hugepage, it doesn't matter.
 	 */
 	if (rte_malloc_heap_socket_is_external(socket_arg) != 1 &&
 				!rte_eal_has_hugepages())
lib/eal/linux/eal_hugepage_info.c +2 -2
index d97792cade..5673784186 100644
@@ -117,7 +117,7 @@ get_num_hugepages(const char *subdir, size_t sz)
 		over_pages = 0;
 
 	if (num_pages == 0 && over_pages == 0)
-		RTE_LOG(WARNING, EAL, "No available %zu kB hugepages reported\n",
+		RTE_LOG(WARNING, EAL, "No available %zu kB hugepage reported\n",
 				sz >> 10);
 
 	num_pages += over_pages;
@@ -158,7 +158,7 @@ get_num_hugepages_on_node(const char *subdir, unsigned int socket, size_t sz)
 		return 0;
 
 	if (num_pages == 0)
-		RTE_LOG(WARNING, EAL, "No free %zu kB hugepages reported on node %u\n",
+		RTE_LOG(WARNING, EAL, "No free %zu kB hugepage reported on node %u\n",
 				sz >> 10, socket);
 
 	/*
lib/eal/linux/eal_memory.c +2 -2
index 03a4f2dd2d..d73d233a7d 100644
@@ -1002,7 +1002,7 @@ remap_needed_hugepages(struct hugepage_file *hugepages, int n_pages)
 		cur = &hugepages[cur_page];
 		prev = cur_page == 0 ? NULL : &hugepages[cur_page - 1];
 
-		/* if size is zero, no more pages left */
+		/* if size is zero, no more page left */
 		if (cur->size == 0)
 			break;
 
@@ -1550,7 +1550,7 @@ eal_legacy_hugepage_attach(void)
 		struct rte_memseg_list *msl;
 		struct rte_memseg *ms;
 
-		/* if size is zero, no more pages left */
+		/* if size is zero, no more page left */
 		if (map_sz == 0)
 			break;
 
Signature · 1 line
2.33.0
#1 lore raw
Quoted 22 lines · Thomas Monjalon

Some comments and logs about cores, nodes and pages were using plural or hypotetic plural (s) form even if preceded by "0" or "no".

It is replaced with singular form where appropriate.

---
 lib/eal/common/eal_common_lcore.c | 13 +++++++++----
 lib/eal/common/rte_malloc.c       |  4 ++--
 lib/eal/linux/eal_hugepage_info.c |  4 ++--
 lib/eal/linux/eal_memory.c        |  4 ++--
 4 files changed, 15 insertions(+), 10 deletions(-)
lib/eal/common/eal_common_lcore.c +0 -0
index 66d6bad1a7..6778ecc98f 100644
@@ -191,9 +191,12 @@ rte_eal_cpu_init(void)
 	/* Set the count of enabled logical cores of the EAL configuration */
 	config->lcore_count = count;
 	RTE_LOG(DEBUG, EAL,

lib/eal/common/eal_common_lcore.c rte_eal_cpu_init(void) · line 200

Quoted 10 lines
lib/eal/common/eal_common_lcore.c +6 -3
-		"Support maximum %u logical core(s) by configuration.\n",
-		RTE_MAX_LCORE);
-	RTE_LOG(INFO, EAL, "Detected %u lcore(s)\n", config->lcore_count);
+			"Support maximum %u logical core%s by configuration.\n",
+			RTE_MAX_LCORE,
+			RTE_MAX_LCORE > 1 ? "s" : "");
+	RTE_LOG(INFO, EAL, "Detected %u lcore%s\n",
+			config->lcore_count,
+			config->lcore_count > 1 ? "s" : "");
 

Personally, I'd take the view that these values are so unlikely to be ever 1, that I'd leave them always pluralized rather than add the complexity.

lib/eal/common/eal_common_lcore.c rte_eal_cpu_init(void) · line 217

Quoted 11 lines
lib/eal/common/eal_common_lcore.c +3 -1
 	/* sort all socket id's in ascending order */
 	qsort(lcore_to_socket_id, RTE_DIM(lcore_to_socket_id),
@@ -208,7 +211,9 @@ rte_eal_cpu_init(void)
 					socket_id;
 		prev_socket_id = socket_id;
 	}
-	RTE_LOG(INFO, EAL, "Detected %u NUMA nodes\n", config->numa_node_count);
+	RTE_LOG(INFO, EAL, "Detected %u NUMA node%s\n",
+			config->numa_node_count,
+			config->numa_node_count > 1 ? "s" : "");
 

Ok.
However, as a general suggestion, is it easier to sidestep all this singular/plural decisions just by using "label: <value>" type syntax, e.g. for here:
"Detected NUMA nodes: 1"
When printed in such a form there is no expectation of singular ever being used.

lib/eal/common/rte_malloc.c malloc_socket(const char *type, size_t size, unsigned int align, · line 68

Quoted 12 lines
lib/eal/common/eal_common_lcore.c +0 -0
 	return 0;
 }
lib/eal/common/rte_malloc.c +1 -1
index 9d39e58c08..04cbb0078b 100644
@@ -65,10 +65,10 @@ malloc_socket(const char *type, size_t size, unsigned int align,
 	if (size == 0 || (align && !rte_is_power_of_2(align)))
 		return NULL;
 
-	/* if there are no hugepages and if we are not allocating from an
+	/* if there are no hugepage and if we are not allocating from an

This needs to be kept in the plural. Also applies to the instances below...

lib/eal/common/rte_malloc.c malloc_socket(const char *type, size_t size, unsigned int align, · line 72

Quoted 5 lines
lib/eal/common/rte_malloc.c +1 -1
 	 * external heap, use memory from any socket available. checking for
 	 * socket being external may return -1 in case of invalid socket, but
-	 * that's OK - if there are no hugepages, it doesn't matter.
+	 * that's OK - if there are no hugepage, it doesn't matter.
 	 */

<snip for brevity>

#2 lore raw

PATCH v2 1/1 eal: reword logs for CPU and NUMA counts

In reply to Thomas Monjalon

Some logs about cores and nodes were using hypotetic plural (s) form. A fixed plural form with value at the end is preferred.

---
v2: keep plural form as suggested by Bruce

---
 lib/eal/common/eal_common_lcore.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/common/eal_common_lcore.c +4 -4
index 66d6bad1a7..b38bb46d44 100644
@@ -191,9 +191,9 @@ rte_eal_cpu_init(void)
 	/* Set the count of enabled logical cores of the EAL configuration */
 	config->lcore_count = count;
 	RTE_LOG(DEBUG, EAL,
-		"Support maximum %u logical core(s) by configuration.\n",
-		RTE_MAX_LCORE);
-	RTE_LOG(INFO, EAL, "Detected %u lcore(s)\n", config->lcore_count);
+			"Maximum logical cores by configuration: %u\n",
+			RTE_MAX_LCORE);
+	RTE_LOG(INFO, EAL, "Detected CPU lcores: %u\n",config->lcore_count);
 
 	/* sort all socket id's in ascending order */
 	qsort(lcore_to_socket_id, RTE_DIM(lcore_to_socket_id),
@@ -208,7 +208,7 @@ rte_eal_cpu_init(void)
 					socket_id;
 		prev_socket_id = socket_id;
 	}
-	RTE_LOG(INFO, EAL, "Detected %u NUMA nodes\n", config->numa_node_count);
+	RTE_LOG(INFO, EAL, "Detected NUMA nodes: %u\n", config->numa_node_count);
 
 	return 0;
 }
Signature · 1 line
2.33.0
#3 lore raw

Re: [dpdk-dev] [PATCH v2] eal: reword logs for CPU and NUMA counts

16/09/2021 12:32, Thomas Monjalon:

Quoted 15 lines

Some logs about cores and nodes were using hypotetic plural (s) form. A fixed plural form with value at the end is preferred.

---
v2: keep plural form as suggested by Bruce

---
 lib/eal/common/eal_common_lcore.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/common/eal_common_lcore.c +0 -0
index 66d6bad1a7..b38bb46d44 100644

lib/eal/common/eal_common_lcore.c rte_eal_cpu_init(void) · line 196

Quoted 9 lines
lib/eal/common/eal_common_lcore.c +3 -3
@@ -191,9 +191,9 @@ rte_eal_cpu_init(void)
 	/* Set the count of enabled logical cores of the EAL configuration */
 	config->lcore_count = count;
 	RTE_LOG(DEBUG, EAL,
-		"Support maximum %u logical core(s) by configuration.\n",
-		RTE_MAX_LCORE);
-	RTE_LOG(INFO, EAL, "Detected %u lcore(s)\n", config->lcore_count);
+			"Maximum logical cores by configuration: %u\n",
+			RTE_MAX_LCORE);
+	RTE_LOG(INFO, EAL, "Detected CPU lcores: %u\n",config->lcore_count);

space missing above, consider it as fixed ;)

Quoted 13 lines
lib/eal/common/eal_common_lcore.c +1 -1
 	/* sort all socket id's in ascending order */
 	qsort(lcore_to_socket_id, RTE_DIM(lcore_to_socket_id),
@@ -208,7 +208,7 @@ rte_eal_cpu_init(void)
 					socket_id;
 		prev_socket_id = socket_id;
 	}
-	RTE_LOG(INFO, EAL, "Detected %u NUMA nodes\n", config->numa_node_count);
+	RTE_LOG(INFO, EAL, "Detected NUMA nodes: %u\n", config->numa_node_count);
 
 	return 0;
 }
#4 lore raw

Re: [dpdk-dev] [PATCH v2] eal: reword logs for CPU and NUMA counts

Quoted 11 lines · Thomas Monjalon

16/09/2021 12:32, Thomas Monjalon:

Quoted 10 lines

Some logs about cores and nodes were using hypotetic plural (s) form. A fixed plural form with value at the end is preferred.

---
v2: keep plural form as suggested by Bruce

---
 lib/eal/common/eal_common_lcore.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
author Applied
#5 lore raw

Re: [dpdk-dev] [PATCH v2] eal: reword logs for CPU and NUMA counts

16/09/2021 12:41, Bruce Richardson:

Quoted 10 lines · Thomas Monjalon
Quoted 7 lines

16/09/2021 12:32, Thomas Monjalon:

Quoted 6 lines

Some logs about cores and nodes were using hypotetic plural (s) form. A fixed plural form with value at the end is preferred.

---
v2: keep plural form as suggested by Bruce

Applied