public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <andrzej.hajda@intel.com>
To: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	 John Ogness <john.ogness@linutronix.de>,
	 Sergey Senozhatsky <senozhatsky@chromium.org>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	 Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	 Brendan Jackman <jackmanb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,  Zi Yan <ziy@nvidia.com>,
	Christoph Lameter <cl@gentwo.org>,
	 David Rientjes <rientjes@google.com>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Harry Yoo <harry.yoo@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	 Andrzej Hajda <andrzej.hajda@intel.com>
Subject: [PATCH v2 0/5] printk: add macros to simplify handling struct va_format
Date: Mon, 01 Dec 2025 10:31:21 +0100	[thread overview]
Message-ID: <20251201-va_format_call-v2-0-2906f3093b60@intel.com> (raw)

This patchset contains patch abstracting out most common bits of va_format uses
into small macro. The macro works as a forwarder of variadic args to va_format
call.
Rough estimates based on dirty cocci script suggests about 180-230 users
could be converted, allowing to remove about 1100-1300 lines of code.
Of course, I do not plan to do it in mass. I just provide few patches to
show the usage and the potential.

Provided helper deals with variadic args to va_format conversion/forwarding.
Similar solution could be proposed also for variadic args to va_list conversion.
Common code:
    va_list args;
    va_start(args, fmt);
    ret = func(..., fmt, args);
    va_end(args);
    return ret;
Could be replaced with:
    ret = va_list_call(fmt, func, ..., fmt);
This is less rewarding (less lines to remove) but still looks promising. Also
separate helper should be created for functions without return value,
unless somebody knows trick how to do it in one macro:
    va_list_void_call(fmt, func, ..., fmt);
Any comments?

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
Changes in v2:
- added two patches simplifying handling of variadic args in drivers/core and mm
  in slightly less obvious cases, this way both mm and drivers/core do not use
  anymore hand rolled variadic -> va_format conversions.
- Link to v1: https://lore.kernel.org/r/20251126-va_format_call-v1-0-8a604a331730@intel.com

---
Andrzej Hajda (5):
      printk: add macros to simplify handling struct va_format
      drivers/core: use va_format_call helper
      drivers/core: simplify variadic args handling
      mm: use va_format_call helper
      mm: simplify variadic args handling

 drivers/base/core.c    | 82 ++++++++------------------------------------------
 include/linux/printk.h | 30 ++++++++++++++++++
 mm/page_alloc.c        | 14 +++------
 mm/slub.c              | 33 +++-----------------
 4 files changed, 52 insertions(+), 107 deletions(-)
---
base-commit: 37a098cc87aafdf4de147851cbf350bb66c51b45
change-id: 20251126-va_format_call-41053ef60fd7

Best regards,
--  
Andrzej Hajda <andrzej.hajda@intel.com>



             reply	other threads:[~2025-12-01  9:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01  9:31 Andrzej Hajda [this message]
2025-12-01  9:31 ` [PATCH v2 1/5] printk: add macros to simplify handling struct va_format Andrzej Hajda
2025-12-01  9:31 ` [PATCH v2 2/5] drivers/core: use va_format_call helper Andrzej Hajda
2025-12-01  9:31 ` [PATCH v2 3/5] drivers/core: simplify variadic args handling Andrzej Hajda
2025-12-02 15:51   ` Petr Mladek
2025-12-02 18:03     ` Hajda, Andrzej
2025-12-03 14:47       ` Andy Shevchenko
2025-12-03 18:07         ` Hajda, Andrzej
2025-12-01  9:31 ` [PATCH v2 4/5] mm: use va_format_call helper Andrzej Hajda
2025-12-01  9:31 ` [PATCH v2 5/5] mm: simplify variadic args handling Andrzej Hajda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251201-va_format_call-v2-0-2906f3093b60@intel.com \
    --to=andrzej.hajda@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=harry.yoo@oracle.com \
    --cc=jackmanb@google.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=pmladek@suse.com \
    --cc=rafael@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox