public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Joe Perches <joe@perches.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kay Sievers <kay@vrfy.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] printk: Shrink printk_sched buffer size, eliminate it when !CONFIG_PRINTK
Date: Wed, 6 Jun 2012 09:33:22 +0200	[thread overview]
Message-ID: <20120606073321.GH17808@gmail.com> (raw)
In-Reply-To: <1338315431.18974.10.camel@joe2Laptop>


* Joe Perches <joe@perches.com> wrote:

> The size of the per-cpu printk_sched buf is much larger
> than necessary.  The maximum sched message emitted is
> ~80 bytes. Shrink the allocation for this printk_sched
> buffer from 512 bytes to 128.
> 
> printk_sched creates an unnecessary per-cpu buffer when
> CONFIG_PRINTK is not enabled.  Remove it when appropriate
> so embedded uses save a bit of space too.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  kernel/printk.c |   14 ++++++++++----
>  1 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/printk.c b/kernel/printk.c
> index 32462d2..61cff0b 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -1726,24 +1726,30 @@ int is_console_locked(void)
>  }
>  
>  /*
> - * Delayed printk version, for scheduler-internal messages:
> + * Delayed printk version, for scheduler-internal messages.
> + * Not the normal 512 as it's a bit wasteful, sched messages are short,
> + * and 128 is more than sufficient for all current messages.
>   */
> -#define PRINTK_BUF_SIZE		512
> +#define PRINTK_SCHED_BUF_SIZE	128
>  
>  #define PRINTK_PENDING_WAKEUP	0x01
>  #define PRINTK_PENDING_SCHED	0x02
>  
>  static DEFINE_PER_CPU(int, printk_pending);
> -static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);
> +#ifdef CONFIG_PRINTK
> +static DEFINE_PER_CPU(char [PRINTK_SCHED_BUF_SIZE], printk_sched_buf);
> +#endif
>  
>  void printk_tick(void)
>  {
>  	if (__this_cpu_read(printk_pending)) {
>  		int pending = __this_cpu_xchg(printk_pending, 0);
> +#ifdef CONFIG_PRINTK
>  		if (pending & PRINTK_PENDING_SCHED) {
>  			char *buf = __get_cpu_var(printk_sched_buf);
>  			printk(KERN_WARNING "[sched_delayed] %s", buf);
>  		}
> +#endif
>  		if (pending & PRINTK_PENDING_WAKEUP)
>  			wake_up_interruptible(&log_wait);
>  	}
> @@ -2189,7 +2195,7 @@ int printk_sched(const char *fmt, ...)
>  	buf = __get_cpu_var(printk_sched_buf);
>  
>  	va_start(args, fmt);
> -	r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
> +	r = vsnprintf(buf, PRINTK_SCHED_BUF_SIZE, fmt, args);
>  	va_end(args);
>  
>  	__this_cpu_or(printk_pending, PRINTK_PENDING_SCHED);

The change makes sense but the further proliferation of #ifdefs 
is rather ugly and shows confusion: fundamentally, if we are 
going to cut out more printk functionality in the !CONFIG_PRINTK 
we might as well disable the whole thing, not just the 
printk_sched bits.

Thanks,

	Ingo

  parent reply	other threads:[~2012-06-06  7:33 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 16:16 Plumbers: Tweaking scheduler policy micro-conf RFP Vincent Guittot
2012-05-11 16:26 ` Steven Rostedt
2012-05-11 16:38   ` Vincent Guittot
2012-05-15  8:41     ` Juri Lelli
2012-05-15  0:53 ` Paul E. McKenney
2012-05-15  8:02 ` Vincent Guittot
2012-05-15  8:34   ` mou Chen
2012-05-15  9:07     ` Vincent Guittot
2012-05-15  9:17       ` Pantelis Antoniou
2012-05-15 10:28         ` Peter Zijlstra
2012-05-15 11:35           ` Pantelis Antoniou
2012-05-15 11:58             ` Peter Zijlstra
2012-05-15 12:32               ` Pantelis Antoniou
2012-05-15 12:59                 ` Peter Zijlstra
2012-05-19 14:58               ` Luming Yu
2012-05-15 20:26             ` valdis.kletnieks
2012-05-15 20:33               ` Peter Zijlstra
2012-05-16 12:08               ` Pantelis Antoniou
2012-05-15 12:23   ` Peter Zijlstra
2012-05-15 12:27     ` Peter Zijlstra
2012-05-15 12:57     ` Vincent Guittot
2012-05-15 13:00       ` Peter Zijlstra
2012-05-15 15:05         ` Vincent Guittot
2012-05-15 15:19           ` Paul E. McKenney
2012-05-15 15:27             ` Vincent Guittot
2012-05-15 15:35           ` Peter Zijlstra
2012-05-15 15:45             ` Peter Zijlstra
2012-05-16 18:30             ` Peter Zijlstra
2012-05-19 17:08               ` Linus Torvalds
2012-05-19 22:55                 ` Peter Zijlstra
2012-05-22  2:38                   ` Chen
2012-05-22  5:14                     ` Chen
2012-05-30  7:20                       ` Ingo Molnar
2012-05-23 15:03                     ` Ingo Molnar
2012-05-23 15:43                       ` Joe Perches
2012-05-23 15:50                         ` Ingo Molnar
2012-05-23 15:56                           ` Joe Perches
2012-05-23 15:59                             ` Ingo Molnar
2012-05-29 18:17                           ` [PATCH] printk: Shrink printk_sched buffer size, eliminate it when !CONFIG_PRINTK Joe Perches
2012-06-05 16:04                             ` Joe Perches
2012-06-06  7:25                               ` Ingo Molnar
2012-06-06  7:33                             ` Ingo Molnar [this message]
2012-06-06  7:42                               ` Joe Perches
2012-05-19 23:13                 ` Plumbers: Tweaking scheduler policy micro-conf RFP Peter Zijlstra
2012-05-19 23:22                 ` Peter Zijlstra
2012-05-21  7:16                   ` Ingo Molnar
2012-05-21 16:56                     ` Linus Torvalds
2012-05-16 18:49             ` Vaidyanathan Srinivasan
2012-05-16 19:40               ` Peter Zijlstra
2012-05-16 21:20             ` Vincent Guittot
     [not found]             ` <20120518161817.GE18312@e103034-lin.cambridge.arm.com>
2012-05-18 16:24               ` Morten Rasmussen
2012-05-18 16:39                 ` Peter Zijlstra
2012-05-18 16:46                 ` Pantelis Antoniou
2012-05-15 16:30           ` Vaidyanathan Srinivasan
2012-05-15 18:13             ` Vincent Guittot

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=20120606073321.GH17808@gmail.com \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=kay@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /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