linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ring-buffer: make the const read-only 'type' static
@ 2025-07-14 16:08 Colin Ian King
  2025-07-14 16:15 ` Steven Rostedt
  2025-07-18 21:24 ` David Laight
  0 siblings, 2 replies; 4+ messages in thread
From: Colin Ian King @ 2025-07-14 16:08 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	linux-trace-kernel
  Cc: kernel-janitors, linux-kernel

Don't populate the read-only 'type' on the stack at run time,
instead make it static.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 00fc38d70e86..39aa1f50274f 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -4118,7 +4118,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_unlock_commit);
 
 static const char *show_irq_str(int bits)
 {
-	const char *type[] = {
+	static const char * type[] = {
 		".",	// 0
 		"s",	// 1
 		"h",	// 2
-- 
2.50.0


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

* Re: [PATCH] ring-buffer: make the const read-only 'type' static
  2025-07-14 16:08 [PATCH] ring-buffer: make the const read-only 'type' static Colin Ian King
@ 2025-07-14 16:15 ` Steven Rostedt
  2025-07-19  6:32   ` Christophe JAILLET
  2025-07-18 21:24 ` David Laight
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2025-07-14 16:15 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-trace-kernel,
	kernel-janitors, linux-kernel

On Mon, 14 Jul 2025 17:08:58 +0100
Colin Ian King <colin.i.king@gmail.com> wrote:

> Don't populate the read-only 'type' on the stack at run time,
> instead make it static.

Hmm, why not?

-- Steve

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

* Re: [PATCH] ring-buffer: make the const read-only 'type' static
  2025-07-14 16:08 [PATCH] ring-buffer: make the const read-only 'type' static Colin Ian King
  2025-07-14 16:15 ` Steven Rostedt
@ 2025-07-18 21:24 ` David Laight
  1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2025-07-18 21:24 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	linux-trace-kernel, kernel-janitors, linux-kernel

On Mon, 14 Jul 2025 17:08:58 +0100
Colin Ian King <colin.i.king@gmail.com> wrote:

> Don't populate the read-only 'type' on the stack at run time,
> instead make it static.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  kernel/trace/ring_buffer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 00fc38d70e86..39aa1f50274f 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -4118,7 +4118,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_unlock_commit);
>  
>  static const char *show_irq_str(int bits)
>  {
> -	const char *type[] = {
> +	static const char * type[] = {

Better would be:
	static const char type[][4] = {

  David

>  		".",	// 0
>  		"s",	// 1
>  		"h",	// 2


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

* Re: [PATCH] ring-buffer: make the const read-only 'type' static
  2025-07-14 16:15 ` Steven Rostedt
@ 2025-07-19  6:32   ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2025-07-19  6:32 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-trace-kernel,
	kernel-janitors, linux-kernel, Colin Ian King

Le 14/07/2025 à 18:15, Steven Rostedt a écrit :
> On Mon, 14 Jul 2025 17:08:58 +0100
> Colin Ian King <colin.i.king@gmail.com> wrote:
> 
>> Don't populate the read-only 'type' on the stack at run time,
>> instead make it static.
> 
> Hmm, why not?
> 
> -- Steve
> 
> 

This is more efficient because there is no need to copy things on the 
stack at run-time.

It also makes binary slightly smaller.

On my x86_64, with allmodconfig:
Before:
======
  229194	 924492	  35104	1188790	 1223b6	kernel/trace/ring_buffer.o

After:
=====
  228873	 924268	  35040	1188181	 122155	kernel/trace/ring_buffer.o

CJ

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

end of thread, other threads:[~2025-07-19  6:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 16:08 [PATCH] ring-buffer: make the const read-only 'type' static Colin Ian King
2025-07-14 16:15 ` Steven Rostedt
2025-07-19  6:32   ` Christophe JAILLET
2025-07-18 21:24 ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).