[PATCH 3/3] mm: use va_format_call helper

Andrzej Hajda
2025-11-26T11:37:41Z

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 ed82ee55e66afffafcf6360b13da410119f2898d..cd0b17ea4de0a3262fae117fac7f427a7396978f 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 1a5fc34290421ea32e6f5bba8acc87b53a9774b5..786c5a4195d44d5c40b3c9009ff52a3b836bfe23 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