public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Tom Zanussi <zanussi@comcast.net>
Cc: Ruth Ivimey-Cook <Ruth.Ivimey-Cook@ivimey.org>,
	Jan Evert van Grootheest <j.grootheest@euronext.nl>,
	Willy Tarreau <willy@w.ods.org>,
	Marcelo Tosatti <marcelo.tosatti@cyclades.com.br>,
	linux-kernel@vger.kernel.org
Subject: Re: log-buf-len dynamic
Date: Tue, 23 Sep 2003 19:53:20 +0200	[thread overview]
Message-ID: <20030923175320.GD1269@velociraptor.random> (raw)
In-Reply-To: <3F708576.4080203@comcast.net>

On Tue, Sep 23, 2003 at 12:40:06PM -0500, Tom Zanussi wrote:
> It may be a little over the top for 2.4, but I posted a patch for a 
> dynamically resizable printk a while back:
> 
> http://marc.theaimsgroup.com/?l=linux-kernel&m=105828314919697&w=2
> 
> I depends on relayfs, which I also posted at the same time.

I don't think we can merge this in 2.4 but it looks good for 2.6.
However note you can't close the overflow issue, you must still have an
high limit, but you can make lots more reliable that way, it's similar
to netlink anyways, that uses dynamic skb to avoid wasting ram. But it's too
invasive for 2.4, just to make a comparison look what my patch looks
like (it will get a bit more complicated because of the request not to
waste the 64k, you know we throw some hundred megs in the per-cpu
freelists so nobody could notice the 64k lost in the 16-way..):

diff -urNp --exclude CVS --exclude BitKeeper x-ref/kernel/printk.c x/kernel/printk.c
--- x-ref/kernel/printk.c	2003-08-26 00:13:17.000000000 +0200
+++ x/kernel/printk.c	2003-09-01 21:38:16.000000000 +0200
@@ -30,13 +30,13 @@
 #include <asm/uaccess.h>
 
 #if defined(CONFIG_MULTIQUAD) || defined(CONFIG_IA64)
-#define LOG_BUF_LEN	(65536)
+#define __LOG_BUF_LEN	(65536)
 #elif defined(CONFIG_ARCH_S390)
-#define LOG_BUF_LEN	(131072)
+#define __LOG_BUF_LEN	(131072)
 #elif defined(CONFIG_SMP)
-#define LOG_BUF_LEN	(32768)
+#define __LOG_BUF_LEN	(32768)
 #else	
-#define LOG_BUF_LEN	(16384)			/* This must be a power of two */
+#define __LOG_BUF_LEN	(16384)			/* This must be a power of two */
 #endif
 
 #define LOG_BUF_MASK	(LOG_BUF_LEN-1)
@@ -78,7 +78,9 @@ struct console *console_drivers;
  */
 static spinlock_t logbuf_lock = SPIN_LOCK_UNLOCKED;
 
-static char log_buf[LOG_BUF_LEN];
+static char __log_buf[__LOG_BUF_LEN];
+static char * log_buf = __log_buf;
+static int LOG_BUF_LEN = __LOG_BUF_LEN;
 #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
 
 /*
@@ -151,6 +153,39 @@ static int __init console_setup(char *st
 
 __setup("console=", console_setup);
 
+static int __init log_buf_len_setup(char *str)
+{
+	unsigned long size = simple_strtoul(str, &str, 0);
+
+	if (size & (size-1))
+		printk("log_buf_len: invalid size - needs a power of two\n");
+
+	spin_lock_irq(&logbuf_lock);
+	if (size > LOG_BUF_LEN) {
+		unsigned long start, end, dest_idx, offset;
+
+		LOG_BUF_LEN = size;
+		log_buf = alloc_exact(LOG_BUF_LEN);
+
+		offset = start = min(con_start, log_start);
+		end = log_end;
+		dest_idx = 0;
+		while (start != end) {
+			log_buf[dest_idx] = __log_buf[start & (__LOG_BUF_LEN - 1)];
+			start++;
+			dest_idx++;
+		}
+		log_start -= offset;
+		con_start -= offset;
+		log_end -= offset;
+	}
+	spin_unlock_irq(&logbuf_lock);
+
+	return 1;
+}
+
+__setup("log_buf_len=", log_buf_len_setup);
+
 /*
  * Commands to do_syslog:
  *

Andrea - If you prefer relying on open source software, check these links:
	    rsync.kernel.org::pub/scm/linux/kernel/bkcvs/linux-2.[45]/
	    http://www.cobite.com/cvsps/
	    svn://svn.kernel.org/linux-2.[46]/trunk

  reply	other threads:[~2003-09-23 17:53 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-22 19:48 log-buf-len dynamic Andrea Arcangeli
2003-09-23  1:51 ` Matthew Wilcox
2003-09-23 21:08   ` Andrea Arcangeli
2003-09-23  4:28 ` Willy Tarreau
2003-09-23 12:49   ` Andrea Arcangeli
2003-09-23 14:06     ` Willy Tarreau
2003-09-23 14:44       ` Andrea Arcangeli
2003-09-23 15:01         ` Jan Evert van Grootheest
2003-09-23 15:41           ` Andrea Arcangeli
2003-09-23 16:09             ` Willy Tarreau
2003-09-23 16:26               ` Andrea Arcangeli
2003-09-23 16:56             ` Ruth Ivimey-Cook
2003-09-23 17:40               ` Tom Zanussi
2003-09-23 17:53                 ` Andrea Arcangeli [this message]
2003-09-23 21:37                   ` Andrew Morton
2003-09-23 22:22                     ` Andrea Arcangeli
2003-09-24  0:15                       ` Andrew Morton
2003-09-24  0:38                         ` Andrea Arcangeli
2003-09-23 16:06           ` Willy Tarreau
2003-09-23 16:23             ` Andrea Arcangeli
2003-09-23 19:02               ` Willy Tarreau
2003-09-23 22:34                 ` Andrea Arcangeli
2003-09-23 23:29                   ` Willy Tarreau
2003-09-23 23:48                     ` Andrea Arcangeli
2003-09-23 23:50                       ` Willy Tarreau
2003-09-23 12:46 ` Daniel Jacobowitz
2003-09-25 13:40 ` marcelo
2003-09-26 20:26   ` Andrea Arcangeli
     [not found] <20030923142706.54b2428a.davem@redhat.com>
2003-09-23 21:53 ` Linus Torvalds
2003-09-23 22:15   ` Andrea Arcangeli
2003-09-23 22:54     ` Linus Torvalds
2003-09-24  0:36       ` Andrea Arcangeli
2003-09-24  1:19         ` Larry McVoy
2003-09-24  2:04           ` andrea
2003-09-24  2:29             ` Larry McVoy
2003-09-24  2:39               ` Andrea Arcangeli
2003-09-24  3:16                 ` Larry McVoy
2003-09-24  3:31                   ` Rik van Riel
2003-09-24  3:45                     ` Larry McVoy
2003-09-24  3:54                       ` Linus Torvalds
2003-09-24  4:12                         ` Rik van Riel
2003-09-24 21:11                           ` yodaiken
2003-09-24 13:09                       ` Alan Cox
2003-09-24 18:56                         ` Jörn Engel
2003-09-24  3:46                   ` Andrea Arcangeli
2003-09-24  4:02                     ` Larry McVoy
2003-09-24  4:06                     ` Rik van Riel
2003-09-24  2:36             ` Linus Torvalds
2003-09-24  2:48               ` Andrea Arcangeli
2003-09-24  3:06                 ` Linus Torvalds
2003-09-24  3:28                   ` Andrea Arcangeli
2003-09-24  3:38                     ` Linus Torvalds
2003-09-24  3:56                       ` Andrea Arcangeli
2003-09-24  4:26                         ` viro
2003-09-24  3:42                     ` Rik van Riel
2003-09-24  3:11                 ` David S. Miller
2003-09-24 14:43               ` Roman Zippel
2003-09-25  4:08                 ` Miles Bader
2003-09-25  4:20                   ` Nick Piggin
2003-09-25 17:15               ` Eric W. Biederman
2003-09-25 17:30                 ` Linus Torvalds
2003-09-25 17:57                   ` Jeff Garzik
2003-09-25 18:22                   ` Jörn Engel
2003-09-25 18:33                     ` Randy.Dunlap
2003-09-25 18:36                     ` Larry McVoy
2003-09-25 19:02                       ` Jörn Engel
2003-09-25 18:28                   ` Charles Cazabon
2003-09-25 18:29                     ` Larry McVoy
2003-09-25 20:15                       ` David Lang
2003-09-25 20:27                         ` Larry McVoy
2003-09-29  8:56                       ` Rob Landley
2003-09-29 11:24                         ` John Bradford
2003-09-29 12:30                           ` Rob Landley
2003-09-29 15:22                             ` John Bradford
2003-09-29 13:20                           ` Rik van Riel
2003-09-29 13:23                           ` Valdis.Kletnieks
2003-09-29 15:03                             ` Larry McVoy
2003-09-29 18:21                           ` Hua Zhong
2003-09-29 15:07                         ` Larry McVoy
2003-09-25 19:23                   ` Eric W. Biederman
2003-09-25 17:31                 ` Christoph Hellwig
2003-09-25 19:28                   ` Erik Andersen
2003-09-25 17:36                 ` Dave Jones
2003-09-25 18:34                   ` Larry McVoy
2003-09-25 18:35                   ` Eric W. Biederman
2003-09-25 18:49                 ` Larry McVoy
2003-09-25 20:02                   ` Eric W. Biederman
2003-09-25 23:36                   ` Pau Aliagas
2003-09-26  2:25                 ` Miles Bader
2003-09-26  4:38                   ` Davide Libenzi
2003-09-26 17:09                 ` John Goerzen
2003-09-24  7:56       ` Pau Aliagas
  -- strict thread matches above, loose matches on Subject: below --
2003-09-24 17:39 Ken Ryan
2003-09-25 19:43 Mudama, Eric
2003-09-26 13:24 Samium Gromoff
2003-09-26 14:49 ` viro

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=20030923175320.GD1269@velociraptor.random \
    --to=andrea@suse.de \
    --cc=Ruth.Ivimey-Cook@ivimey.org \
    --cc=j.grootheest@euronext.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com.br \
    --cc=willy@w.ods.org \
    --cc=zanussi@comcast.net \
    /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