linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: Use str_plural() in report_hugepages()
@ 2025-06-30 17:18 Thorsten Blum
  2025-07-01  3:52 ` Dev Jain
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Thorsten Blum @ 2025-06-30 17:18 UTC (permalink / raw)
  To: Muchun Song, Oscar Salvador, David Hildenbrand, Andrew Morton
  Cc: Thorsten Blum, linux-mm, linux-kernel

Use the string choice helper function str_plural() to simplify the code
and to fix the following Coccinelle/coccicheck warning reported by
string_choices.cocci:

  opportunity for str_plural(nrinvalid)

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 mm/hugetlb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9dc95eac558c..08abe7395f2f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -25,6 +25,7 @@
 #include <linux/mmdebug.h>
 #include <linux/sched/signal.h>
 #include <linux/rmap.h>
+#include <linux/string_choices.h>
 #include <linux/string_helpers.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
@@ -3724,7 +3725,7 @@ static void __init report_hugepages(void)
 			buf, h->nr_huge_pages);
 		if (nrinvalid)
 			pr_info("HugeTLB: %s page size: %lu invalid page%s discarded\n",
-					buf, nrinvalid, nrinvalid > 1 ? "s" : "");
+					buf, nrinvalid, str_plural(nrinvalid));
 		pr_info("HugeTLB: %d KiB vmemmap can be freed for a %s page\n",
 			hugetlb_vmemmap_optimizable_size(h) / SZ_1K, buf);
 	}
-- 
2.50.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-02  4:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-30 17:18 [PATCH] mm/hugetlb: Use str_plural() in report_hugepages() Thorsten Blum
2025-07-01  3:52 ` Dev Jain
2025-07-01  4:43 ` Anshuman Khandual
2025-07-01  8:35   ` Thorsten Blum
2025-07-02  4:00     ` Anshuman Khandual
2025-07-01 12:55 ` David Hildenbrand
2025-07-01 13:56 ` Oscar Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox