The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller.
@ 2024-05-27  9:19 Xiang Gao
  2024-05-27 14:54 ` Petr Mladek
  0 siblings, 1 reply; 6+ messages in thread
From: Xiang Gao @ 2024-05-27  9:19 UTC (permalink / raw)
  To: pmladek; +Cc: rostedt, john.ogness, senozhatsky, linux-kernel, fengqi, xiaoa

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller.
  2024-05-27  9:19 [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller Xiang Gao
@ 2024-05-27 14:54 ` Petr Mladek
  2024-05-29  6:33   ` John Ogness
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2024-05-27 14:54 UTC (permalink / raw)
  To: Xiang Gao; +Cc: rostedt, john.ogness, senozhatsky, linux-kernel, fengqi, xiaoa

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller.
  2024-05-27 14:54 ` Petr Mladek
@ 2024-05-29  6:33   ` John Ogness
       [not found]     ` <1717404421510.qmo40jy5kubcunlrdknzajsf@android.mail.163.com>
  0 siblings, 1 reply; 6+ messages in thread
From: John Ogness @ 2024-05-29  6:33 UTC (permalink / raw)
  To: Petr Mladek, Xiang Gao; +Cc: rostedt, senozhatsky, linux-kernel, fengqi, xiaoa

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller.
       [not found]     ` <1717404421510.qmo40jy5kubcunlrdknzajsf@android.mail.163.com>
@ 2024-06-03 12:42       ` Petr Mladek
  2024-06-03 13:15         ` gxxa03070307
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2024-06-03 12:42 UTC (permalink / raw)
  To: gxxa03070307@gmail.com
  Cc: john.ogness, rostedt, senozhatsky, linux-kernel, fengqi,
	高翔

On Mon 2024-06-03 16:47:01, gxxa03070307@gmail.com wrote:
> I need to populate the temporary variable "caller" in "print_caller" func with the additional information. And it's no use defining a buf in out-of-tree patch.
> In out-of-tree patch, I can only add hooks (special cases), I can't change anything else, because it needs to be consistent with mainline linux.
> caller buf in mainline linux is it better to make the buf bigger and leave some space?

I do not understand. Why the buffer size has to be consistent with
mainline linux?

Really, it does not make much sense to upstream just this part
of your out-of-tree patch?

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller.
  2024-06-03 12:42       ` Petr Mladek
@ 2024-06-03 13:15         ` gxxa03070307
  2024-06-03 14:59           ` Petr Mladek
  0 siblings, 1 reply; 6+ messages in thread
From: gxxa03070307 @ 2024-06-03 13:15 UTC (permalink / raw)
  To: pmladek
  Cc: john.ogness, rostedt, senozhatsky, linux-kernel, fengqi,
	高翔


[-- Attachment #1.1: Type: text/plain, Size: 1441 bytes --]

https://android.googlesource.com/kernel/common/+/refs/heads/android15-6.6/kernel/printk/printk.c
We are based on google source code development, this is the link to google source code printk.c, which adds trace_android_vh_printk_caller, if we want to change the buf size must first merge into linux main line.
gxxa03070307@gmail.com
邮箱:gxxa03070307@gmail.com
---- Replied Message ----
From Petr Mladek<pmladek@suse.com> Date 06/03/2024 20:42 To gxxa03070307@gmail.com Cc john.ogness<john.ogness@linutronix.de>、rostedt<rostedt@goodmis.org>、senozhatsky<senozhatsky@chromium.org>、linux-kernel<linux-kernel@vger.kernel.org>、fengqi<fengqi@xiaomi.com>、高翔<gaoxiang19870307@163.com> Subject Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller. 
On Mon 2024-06-03 16:47:01, gxxa03070307@gmail.com wrote: 
> I need to populate the temporary variable "caller" in "print_caller" func with the additional information. And it's no use defining a buf in out-of-tree patch. 
> In out-of-tree patch, I can only add hooks (special cases), I can't change anything else, because it needs to be consistent with mainline linux. 
> caller buf in mainline linux is it better to make the buf bigger and leave some space? 
I do not understand. Why the buffer size has to be consistent with 
mainline linux? 
Really, it does not make much sense to upstream just this part 
of your out-of-tree patch? 
Best Regards, 
Petr

[-- Attachment #1.2: Type: text/html, Size: 6439 bytes --]

[-- Attachment #2: Screenshot_2024-06-03-21-02-27-142_com.android.browser-edit.jpg --]
[-- Type: image/jpeg, Size: 114111 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller.
  2024-06-03 13:15         ` gxxa03070307
@ 2024-06-03 14:59           ` Petr Mladek
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Mladek @ 2024-06-03 14:59 UTC (permalink / raw)
  To: gxxa03070307@gmail.com
  Cc: john.ogness, rostedt, senozhatsky, linux-kernel, fengqi,
	高翔

On Mon 2024-06-03 21:15:13, gxxa03070307@gmail.com wrote:
> https://android.googlesource.com/kernel/common/+/refs/heads/android15-6.6/kernel/printk/printk.c
> We are based on google source code development, this is the link to google source code printk.c, which adds trace_android_vh_printk_caller, if we want to change the buf size must first merge into linux main line.

trace_android_vh_printk_caller() is not in the mainline
=> there is no reason to change the buffer size in the mainline.

You might try to get the change of the buffer size into the android
google sources.

If you want an upstream support then please try to upstream
the entire solution.

But the use of trace_android_vh_printk_caller() is a hack. And upstream
will not support such hacks.

Best Regards,
Petr


> gxxa03070307@gmail.com
> 邮箱:gxxa03070307@gmail.com
> ---- Replied Message ----
> From Petr Mladek<pmladek@suse.com> Date 06/03/2024 20:42 To gxxa03070307@gmail.com Cc john.ogness<john.ogness@linutronix.de>、rostedt<rostedt@goodmis.org>、senozhatsky<senozhatsky@chromium.org>、linux-kernel<linux-kernel@vger.kernel.org>、fengqi<fengqi@xiaomi.com>、高翔<gaoxiang19870307@163.com> Subject Re: [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller. 
> On Mon 2024-06-03 16:47:01, gxxa03070307@gmail.com wrote: 
> > I need to populate the temporary variable "caller" in "print_caller" func with the additional information. And it's no use defining a buf in out-of-tree patch. 
> > In out-of-tree patch, I can only add hooks (special cases), I can't change anything else, because it needs to be consistent with mainline linux. 
> > caller buf in mainline linux is it better to make the buf bigger and leave some space? 
> I do not understand. Why the buffer size has to be consistent with 
> mainline linux? 
> Really, it does not make much sense to upstream just this part 
> of your out-of-tree patch? 
> Best Regards, 
> Petr



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-03 15:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27  9:19 [PATCH] printk: Increase PRINTK_PREFIX_MAX and the buf size in print_caller Xiang Gao
2024-05-27 14:54 ` Petr Mladek
2024-05-29  6:33   ` John Ogness
     [not found]     ` <1717404421510.qmo40jy5kubcunlrdknzajsf@android.mail.163.com>
2024-06-03 12:42       ` Petr Mladek
2024-06-03 13:15         ` gxxa03070307
2024-06-03 14:59           ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox