From: Yury Norov <yury.norov@gmail.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Russell King" <linux@armlinux.org.uk>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Madhavan Srinivasan" <maddy@linux.ibm.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"James Clark" <james.clark@linaro.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Len Brown" <lenb@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Chanwoo Choi" <cw00.choi@samsung.com>,
"MyungJoo Ham" <myungjoo.ham@samsung.com>,
"Kyungmin Park" <kyungmin.park@samsung.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Xu Yilun" <yilun.xu@intel.com>, "Tom Rix" <trix@redhat.com>,
"Moritz Fischer" <mdf@kernel.org>,
"Yicong Yang" <yangyicong@hisilicon.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Leon Romanovsky" <leon@kernel.org>,
"Dan Williams" <djbw@kernel.org>,
"Vishal Verma" <vishal.l.verma@intel.com>,
"Dave Jiang" <dave.jiang@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Shuai Xue" <xueshuai@linux.alibaba.com>,
"Will Deacon" <will@kernel.org>,
"Jiucheng Xu" <jiucheng.xu@amlogic.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Jing Zhang" <renyu.zj@linux.alibaba.com>,
"Xu Yang" <xu.yang_2@nxp.com>,
"Linu Cherian" <lcherian@marvell.com>,
"Gowthami Thiagarajan" <gthiagarajan@marvell.com>,
"Ji Sheng Teoh" <jisheng.teoh@starfivetech.com>,
"Khuong Dinh" <khuong@os.amperecomputing.com>,
"Daniel Lezcano" <daniel.lezcano@kernel.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>,
"Yury Norov" <yury.norov@gmail.com>,
"Kees Cook" <kees@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Aboorva Devarajan" <aboorvad@linux.ibm.com>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
"Ilkka Koskinen" <ilkka@os.amperecomputing.com>,
"Besar Wicaksono" <bwicaksono@nvidia.com>,
"Ma Ke" <make24@iscas.ac.cn>,
"Chengwen Feng" <fengchengwen@huawei.com>,
linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-perf-users@vger.kernel.org, linux-acpi@vger.kernel.org,
driver-core@lists.linux.dev, linux-pm@vger.kernel.org,
linux-rockchip@lists.infradead.org, linux-fpga@vger.kernel.org,
linux-rdma@vger.kernel.org, nvdimm@lists.linux.dev,
linux-pci@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-cxl@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 13/16] perf: Use sysfs_emit() for cpumask show callbacks
Date: Sat, 27 Jun 2026 13:49:27 -0400 [thread overview]
Message-ID: <akANJ-AT7nHpRMq-@yury> (raw)
In-Reply-To: <20260529130619.12f24264@pumpkin>
On Fri, May 29, 2026 at 01:06:19PM +0100, David Laight wrote:
> On Fri, 29 May 2026 12:05:08 +0100
> Robin Murphy <robin.murphy@arm.com> wrote:
>
> > On 2026-05-28 7:36 pm, Yury Norov wrote:
> > > These callbacks are sysfs show paths.
> > >
> > > Use sysfs_emit() and cpumask_pr_args() to emit the masks.
> > >
> > > This prepares for removing cpumap_print_to_pagebuf().
> >
> > TBH, looking at this diff I think it only shows the value of having a
> > helper to abstract the boilerplate...
> >
> > I'm not sure I agree with the argument of removing something entirely
> > just because it may occasionally be misused, but could we at least have
> > something like:
> >
> > #define sysfs_emit_cpumask(buf, mask) \
> > sysfs_emit((buf), "%*pbl\n", cpumask_pr_args(mask))
> >
> > to save the mess in all the many places where the current
> > cpumap_print_to_pagebuf() usage _is_ entirely appropriate?
This way you have to add 2 wrappers:
#define sysfs_emit_cpulist(buf, mask) \
sysfs_emit((buf), "%*pbl\n", cpumask_pr_args(mask))
and
#define sysfs_emit_cpumask(buf, mask) \
sysfs_emit((buf), "%*pb\n", cpumask_pr_args(mask))
There are people who complain even about DIV_ROUND_UP(), how hard it is
to keep all that helpers in memory, and all that things.
https://lore.kernel.org/all/20260304124805.GB2277644@noisy.programming.kicks-ass.net/
Disagree about DIV_ROUND_UP() (because yeah, I'm bad in math), but
this sysfs_emit_cpumask() is a complete syntax redundancy.
Once we have it, people will do this type of things:
tmp = kmalloc(PAGE_SIZE);
sysfs_emit_cpumask(tmp, mask);
sysfs_emit(buf, "my prefix: %s\n", tmp);
kfree(tmp);
Patch #1 in this series is one example. My series that removes
bitmap_print_to_pagebuf() will give you more:
https://lore.kernel.org/all/20260303200842.124996-2-ynorov@nvidia.com/
It doesn't mean that *you* will misuse the API. It means that *I* will
have to inspect the codebase for that type of bugs periodically.
So, the overall state is simple: we've got well-established
printf()-like functions that people know and understand, and we also
have exotic APIs here and there with a non-standard interface and a
clear potential to misuse. In this case, they have historical roots,
but now we don't need them.
> That has the advantage of letting you change how it is done (again)
> without having to find all the callers.
You mean things like silencing the prints or adding a prefix?
If you believe that perf subsystem would benefit from it - that's
OK. Just please keep it local. The kernel globally doesn't need to
'change how it is done' beyond the lib/vsprintf. The kernel really
needs people to use something that the other people are familiar with.
Thanks,
Yury
next prev parent reply other threads:[~2026-06-27 17:49 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 18:36 [PATCH 00/16] lib/cpumask: get rid of cpumap_print_to_pagebuf() Yury Norov
2026-05-28 18:36 ` [PATCH 01/16] psci: simplify hotplug_tests() Yury Norov
2026-05-29 12:24 ` Robin Murphy
2026-05-28 18:36 ` [PATCH 02/16] arm: Use sysfs_emit() for cpumask show callbacks Yury Norov
2026-05-28 18:36 ` [PATCH 03/16] powerpc: " Yury Norov
2026-05-28 18:36 ` [PATCH 04/16] x86/events: " Yury Norov
2026-05-28 18:36 ` [PATCH 05/16] ACPI: pad: Use sysfs_emit() for idlecpus show Yury Norov
2026-06-01 17:45 ` Rafael J. Wysocki
2026-05-28 18:36 ` [PATCH 06/16] cpu: Use sysfs_emit() for cpumask show callback Yury Norov
2026-05-28 18:36 ` [PATCH 07/16] devfreq: Use sysfs_emit() for cpumask show callbacks Yury Norov
2026-05-28 18:36 ` [PATCH 08/16] fpga: dfl-fme-perf: Use sysfs_emit() for cpumask show Yury Norov
2026-05-28 18:36 ` [PATCH 09/16] hwtracing: hisi_ptt: " Yury Norov
2026-05-28 18:36 ` [PATCH 10/16] RDMA/hfi1: Use sysfs_emit() for cpumask show helper Yury Norov
2026-05-28 18:36 ` [PATCH 11/16] nvdimm: Use sysfs_emit() for cpumask show callback Yury Norov
2026-06-02 0:38 ` Alison Schofield
2026-05-28 18:36 ` [PATCH 12/16] PCI/sysfs: Use sysfs_emit() for cpumask show callbacks Yury Norov
2026-05-28 18:36 ` [PATCH 13/16] perf: " Yury Norov
2026-05-29 11:05 ` Robin Murphy
2026-05-29 12:06 ` David Laight
2026-06-27 17:49 ` Yury Norov [this message]
2026-05-28 18:36 ` [PATCH 14/16] powercap: intel_rapl: Use sysfs_emit() for cpumask show Yury Norov
2026-06-01 17:57 ` Rafael J. Wysocki
2026-05-28 18:36 ` [PATCH 15/16] thermal: intel: Use sysfs_emit() for powerclamp cpumask Yury Norov
2026-06-01 18:00 ` Rafael J. Wysocki
2026-05-28 18:36 ` [PATCH 16/16] lib/bitmap-str: get rid of cpumap_print_to_pagebuf() Yury Norov
2026-05-28 19:18 ` [PATCH 00/16] lib/cpumask: " Andrew Morton
2026-05-28 19:26 ` Yury Norov
2026-05-28 19:29 ` Andrew Morton
2026-05-28 19:32 ` Yury Norov
2026-05-28 19:44 ` Ian Rogers
2026-05-28 19:52 ` Yury Norov
2026-05-28 20:02 ` Andrew Morton
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=akANJ-AT7nHpRMq-@yury \
--to=yury.norov@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=aboorvad@linux.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=bwicaksono@nvidia.com \
--cc=chleroy@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=dakr@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=david.laight.linux@gmail.com \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=djbw@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=fengchengwen@huawei.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=gthiagarajan@marvell.com \
--cc=heiko@sntech.de \
--cc=hpa@zytor.com \
--cc=ilkka@os.amperecomputing.com \
--cc=imx@lists.linux.dev \
--cc=ira.weiny@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jbrunet@baylibre.com \
--cc=jgg@ziepe.ca \
--cc=jic23@kernel.org \
--cc=jisheng.teoh@starfivetech.com \
--cc=jiucheng.xu@amlogic.com \
--cc=jolsa@kernel.org \
--cc=kees@kernel.org \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=khuong@os.amperecomputing.com \
--cc=kyungmin.park@samsung.com \
--cc=lcherian@marvell.com \
--cc=lenb@kernel.org \
--cc=leon@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rasmusvillemoes.dk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lpieralisi@kernel.org \
--cc=lukasz.luba@arm.com \
--cc=maddy@linux.ibm.com \
--cc=make24@iscas.ac.cn \
--cc=mark.rutland@arm.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=mdf@kernel.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=myungjoo.ham@samsung.com \
--cc=namhyung@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=npiggin@gmail.com \
--cc=nvdimm@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=renyu.zj@linux.alibaba.com \
--cc=ritesh.list@gmail.com \
--cc=robin.murphy@arm.com \
--cc=rui.zhang@intel.com \
--cc=s.hauer@pengutronix.de \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=trix@redhat.com \
--cc=vishal.l.verma@intel.com \
--cc=will@kernel.org \
--cc=xu.yang_2@nxp.com \
--cc=xueshuai@linux.alibaba.com \
--cc=yangyicong@hisilicon.com \
--cc=yilun.xu@intel.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