mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@nvidia.com>
To: Yury Norov <yury.norov@gmail.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Cc: Yury Norov <ynorov@nvidia.com>,
	Thorsten Blum <thorsten.blum@linux.dev>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@intel.com>,
	William Kucharski <william.kucharski@linux.dev>
Subject: [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
Date: Tue, 19 May 2026 12:30:56 -0400	[thread overview]
Message-ID: <20260519163058.953690-2-ynorov@nvidia.com> (raw)
In-Reply-To: <20260519163058.953690-1-ynorov@nvidia.com>

In preparation for removing bitmap_print_to_pagebuf(), switch
cpumap_print_to_pagebuf() to using scnprintf("%*pbl").

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 include/linux/cpumask.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

There's ongoing discussion about moving the offset_in_page() out of mm.h to
a separate lightweight header [1] and bringing the rest_of_page() helper in
addition to offset_in_page(). If that happens, cpumask.h should include the
new header and drop opencoding part.

[1] https://lore.kernel.org/all/20260517123428.1181981-4-thorsten.blum@linux.dev/
[2] https://lore.kernel.org/all/20260304012717.201797-1-ynorov@nvidia.com/


diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 80211900f373..d3cda0544954 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -13,8 +13,10 @@
 #include <linux/cpumask_types.h>
 #include <linux/gfp_types.h>
 #include <linux/numa.h>
+#include <linux/sprintf.h>
 #include <linux/threads.h>
 #include <linux/types.h>
+#include <vdso/page.h>
 
 #include <asm/bug.h>
 
@@ -1326,8 +1328,9 @@ static __always_inline bool cpu_dying(unsigned int cpu)
 static __always_inline ssize_t
 cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
 {
-	return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask),
-				      nr_cpu_ids);
+	/* Opencode offset_in_page(buf) to not include linux/mm.h */
+	return scnprintf(buf, PAGE_SIZE - ((unsigned long)buf & ~PAGE_MASK),
+			 list ? "%*pbl\n" : "%*pb\n", cpumask_pr_args(mask));
 }
 
 /**
-- 
2.51.0


  reply	other threads:[~2026-05-19 16:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 16:30 [PATCH 0/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
2026-05-19 16:30 ` Yury Norov [this message]
2026-06-01 18:55   ` [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf() Andy Shevchenko
2026-05-19 16:30 ` [PATCH 2/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov

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=20260519163058.953690-2-ynorov@nvidia.com \
    --to=ynorov@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=david@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=ljs@kernel.org \
    --cc=thorsten.blum@linux.dev \
    --cc=william.kucharski@linux.dev \
    --cc=yury.norov@gmail.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

all inboxes | Powered by JetHome®