]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/hugetlb: use str_plural() in report_hugepages()
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 30 Jun 2025 17:18:26 +0000 (19:18 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 13 Jul 2025 23:38:21 +0000 (16:38 -0700)
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)

Link: https://lkml.kernel.org/r/20250630171826.114008-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c

index 11d5668ff6e7b76c4856b4c1178088420b052917..db53ead8ac4340a7e8d5f19d0ac41751b941b1ea 100644 (file)
@@ -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>
@@ -3722,7 +3723,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);
        }