* [PATCH] netconsole: Fix compiler warnings when PRINTK_EXECUTION_CTX is disabled
@ 2026-03-09 12:12 Chelsy Ratnawat
2026-03-09 12:21 ` Breno Leitao
0 siblings, 1 reply; 2+ messages in thread
From: Chelsy Ratnawat @ 2026-03-09 12:12 UTC (permalink / raw)
To: leitao, andrew+netdev, edumazet, kuba
Cc: davem, pabeni, john.ogness, netdev, Chelsy Ratnawat
The netconsole change that started using nbcon_write_context for CPU
and task information assumes CONFIG_PRINTK_EXECUTION_CTX is enabled.
However, when this option is disabled, struct nbcon_write_context does
not contain the cpu and comm fields, causing compilation failures:
error: 'struct nbcon_write_context' has no member named 'cpu'
error: 'struct nbcon_write_context' has no member named 'comm'
Guard access to these fields and fall back to raw_smp_processor_id()
and current->comm when PRINTK_EXECUTION_CTX is disabled.
Fixes: 79ba362b4337 ("netconsole: Use printk context for CPU and task information")
Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
---
drivers/net/netconsole.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 3c9acd6e49e8..bbd39b2e7a36 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1494,17 +1494,30 @@ static void populate_configfs_item(struct netconsole_target *nt,
static int sysdata_append_cpu_nr(struct netconsole_target *nt, int offset,
struct nbcon_write_context *wctxt)
{
+ int cpu;
+#ifdef CONFIG_PRINTK_EXECUTION_CTX
+ cpu = wctxt->cpu;
+#else
+ cpu = raw_smp_processor_id();
+#endif
+
return scnprintf(&nt->sysdata[offset],
MAX_EXTRADATA_ENTRY_LEN, " cpu=%u\n",
- wctxt->cpu);
+ cpu);
}
static int sysdata_append_taskname(struct netconsole_target *nt, int offset,
struct nbcon_write_context *wctxt)
{
+ const char *comm;
+#ifdef CONFIG_PRINTK_EXECUTION_CTX
+ comm = wctxt->comm;
+#else
+ comm = current->comm;
+#endif
return scnprintf(&nt->sysdata[offset],
MAX_EXTRADATA_ENTRY_LEN, " taskname=%s\n",
- wctxt->comm);
+ comm);
}
static int sysdata_append_release(struct netconsole_target *nt, int offset)
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] netconsole: Fix compiler warnings when PRINTK_EXECUTION_CTX is disabled
2026-03-09 12:12 [PATCH] netconsole: Fix compiler warnings when PRINTK_EXECUTION_CTX is disabled Chelsy Ratnawat
@ 2026-03-09 12:21 ` Breno Leitao
0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2026-03-09 12:21 UTC (permalink / raw)
To: Chelsy Ratnawat
Cc: andrew+netdev, edumazet, kuba, davem, pabeni, john.ogness, netdev
Hello Chelsy,
On Mon, Mar 09, 2026 at 05:12:33AM -0700, Chelsy Ratnawat wrote:
> The netconsole change that started using nbcon_write_context for CPU
> and task information assumes CONFIG_PRINTK_EXECUTION_CTX is enabled.
in fact, NETCONSOLE_DYNAMIC selects CONFIG_PRINTK_EXECUTION_CTX. In
other words, were you able to get NETCONSOLE_DYNAMIC without having
CONFIG_PRINTK_EXECUTION_CTX set?
> However, when this option is disabled, struct nbcon_write_context does
> not contain the cpu and comm fields, causing compilation failures:
>
> error: 'struct nbcon_write_context' has no member named 'cpu'
> error: 'struct nbcon_write_context' has no member named 'comm'
>
> Guard access to these fields and fall back to raw_smp_processor_id()
> and current->comm when PRINTK_EXECUTION_CTX is disabled.
Please don't do it. We want to disable NETCONSOLE_DYNAMIC to be enabled
(thus, not using ->cpu and ->comm) if CONFIG_PRINTK_EXECUTION_CTX is not
set.
Thanks for the report,
--breno
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-09 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 12:12 [PATCH] netconsole: Fix compiler warnings when PRINTK_EXECUTION_CTX is disabled Chelsy Ratnawat
2026-03-09 12:21 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox