[PATCH v2 4/5] mm: use va_format_call helper

Andrzej Hajda posted 5 patches 11 hours ago
[PATCH v2 4/5] mm: use va_format_call helper
Posted by Andrzej Hajda 11 hours ago
It simplifies the code and makes it more clear.

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
 mm/page_alloc.c | 14 ++++----------
 mm/slub.c       | 10 +---------
 2 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ed82ee55e66a..cd0b17ea4de0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3940,22 +3940,16 @@ static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask)
 
 void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
 {
-	struct va_format vaf;
-	va_list args;
 	static DEFINE_RATELIMIT_STATE(nopage_rs, 10*HZ, 1);
 
 	if ((gfp_mask & __GFP_NOWARN) ||
 	     !__ratelimit(&nopage_rs) ||
 	     ((gfp_mask & __GFP_DMA) && !has_managed_dma()))
 		return;
-
-	va_start(args, fmt);
-	vaf.fmt = fmt;
-	vaf.va = &args;
-	pr_warn("%s: %pV, mode:%#x(%pGg), nodemask=%*pbl",
-			current->comm, &vaf, gfp_mask, &gfp_mask,
-			nodemask_pr_args(nodemask));
-	va_end(args);
+	va_format_call(fmt, pr_warn,
+		       "%s: %pV, mode:%#x(%pGg), nodemask=%*pbl",
+		       current->comm, va_format_arg, gfp_mask, &gfp_mask,
+		       nodemask_pr_args(nodemask));
 
 	cpuset_print_current_mems_allowed();
 	pr_cont("\n");
diff --git a/mm/slub.c b/mm/slub.c
index 1a5fc3429042..786c5a4195d4 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1161,17 +1161,9 @@ static void slab_bug(struct kmem_cache *s, const char *fmt, ...)
 __printf(2, 3)
 static void slab_fix(struct kmem_cache *s, const char *fmt, ...)
 {
-	struct va_format vaf;
-	va_list args;
-
 	if (slab_add_kunit_errors())
 		return;
-
-	va_start(args, fmt);
-	vaf.fmt = fmt;
-	vaf.va = &args;
-	pr_err("FIX %s: %pV\n", s->name, &vaf);
-	va_end(args);
+	va_format_call(fmt, pr_err, "FIX %s: %pV\n", s->name, va_format_arg);
 }
 
 static void print_trailer(struct kmem_cache *s, struct slab *slab, u8 *p)

-- 
2.43.0