kernel/printk/internal.h | 2 +- kernel/printk/printk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
From: xiaoa <gaoxiang19870307@163.com>
Sometimes we need to add our own hooks to carry more caller information
to improve debug efficiency, but currently the buf in print caller is
too small.
Signed-off-by: xiaoa <gaoxiang19870307@163.com>
---
kernel/printk/internal.h | 2 +-
kernel/printk/printk.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 6c2afee5ef62..27a3cc11289c 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -23,7 +23,7 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
#ifdef CONFIG_PRINTK
#ifdef CONFIG_PRINTK_CALLER
-#define PRINTK_PREFIX_MAX 48
+#define PRINTK_PREFIX_MAX 64
#else
#define PRINTK_PREFIX_MAX 32
#endif
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 420fd310129d..2d7f003113f7 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1331,7 +1331,7 @@ static size_t print_time(u64 ts, char *buf)
#ifdef CONFIG_PRINTK_CALLER
static size_t print_caller(u32 id, char *buf)
{
- char caller[12];
+ char caller[32];
snprintf(caller, sizeof(caller), "%c%u",
id & 0x80000000 ? 'C' : 'T', id & ~0x80000000);
--
2.34.1
On Mon 2024-05-27 17:19:29, Xiang Gao wrote:
> Sometimes we need to add our own hooks to carry more caller information
> to improve debug efficiency, but currently the buf in print caller is
> too small.
> --- a/kernel/printk/internal.h
> +++ b/kernel/printk/internal.h
> @@ -23,7 +23,7 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
> #ifdef CONFIG_PRINTK
>
> #ifdef CONFIG_PRINTK_CALLER
> -#define PRINTK_PREFIX_MAX 48
> +#define PRINTK_PREFIX_MAX 64
> #else
> #define PRINTK_PREFIX_MAX 32
> #endif
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 420fd310129d..2d7f003113f7 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1331,7 +1331,7 @@ static size_t print_time(u64 ts, char *buf)
> #ifdef CONFIG_PRINTK_CALLER
> static size_t print_caller(u32 id, char *buf)
> {
> - char caller[12];
> + char caller[32];
Could you provide more details, please?
How exactly do you add your own hooks?
If you need to modify the code to add the extra info, you could also
modify the buffer size.
The buffer is big enough for the info printed by the upstream code.
I do understand why we should do this change upstream.
> snprintf(caller, sizeof(caller), "%c%u",
> id & 0x80000000 ? 'C' : 'T', id & ~0x80000000);
Best Regards,
Petr
On 2024-05-27, Petr Mladek <pmladek@suse.com> wrote: > If you need to modify the code to add the extra info, you could also > modify the buffer size. Exactly this. Your out-of-tree patch to add extra info should also make the necessary changes to the buffer sizes. It is your out-of-tree patch that is broken, not mainline Linux. John Ogness
© 2016 - 2026 Red Hat, Inc.