linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paulo Marques <pmarques@grupopie.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Alistair John Strachan <s0348365@sms.ed.ac.uk>,
	linux-kernel@vger.kernel.org,
	Arjan van de Ven <arjanv@infradead.org>
Subject: Re: Realtime Preemption, 2.6.12, Beginners Guide?
Date: Mon, 11 Jul 2005 14:28:37 +0100	[thread overview]
Message-ID: <42D27405.8070802@grupopie.com> (raw)
In-Reply-To: <20050709124105.GB4665@elte.hu>

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

Ingo Molnar wrote:
> (gdb) ####################################
> (gdb) # c013ebf4, stack size:  388 bytes #
> (gdb) ####################################
> (gdb) 0xc013ebf4 is in __print_symbol (kernel/kallsyms.c:234).

The attached patch fixes this partially by reducing the stack usage by
128 bytes. Compile, boot and run tested and apparently it works fine.

I didn't want to use kmalloc's in there because this function is
probably called from very "hard" contexts (kernel OOPS, stack overflow
dumps, etc.).

The stack usage could be reduced even further (I can do a patch for this
if needed) by changing the function to receive a "prefix" and a "suffix"
string instead of a format string.

The function could then simply do:
    printk(prefix);
    printk(symbol);
    printk(address);
    if (module) printk(module name);
    printk(suffix);

This way it wouldn't need to allocate a buffer big enough for the whole
string, just for one symbol name (128 bytes).

This is a much more intrusive change however (there are ~65 callers that
would need changing), so I leave the decision to more experienced hackers :)

-- 
Paulo Marques - www.grupopie.com

It is a mistake to think you can solve any major problems
just with potatoes.
Douglas Adams

[-- Attachment #2: kallsyms_reduce_stack.patch --]
[-- Type: text/x-patch, Size: 1075 bytes --]

--- ./kernel/kallsyms.c.orig	2005-07-11 12:32:32.000000000 +0100
+++ ./kernel/kallsyms.c	2005-07-11 12:34:42.000000000 +0100
@@ -232,23 +232,21 @@ const char *kallsyms_lookup(unsigned lon
 /* Replace "%s" in format with address, or returns -errno. */
 void __print_symbol(const char *fmt, unsigned long address)
 {
-	char *modname;
+	char *modname, *bufend;
 	const char *name;
 	unsigned long offset, size;
-	char namebuf[KSYM_NAME_LEN+1];
 	char buffer[sizeof("%s+%#lx/%#lx [%s]") + KSYM_NAME_LEN +
 		    2*(BITS_PER_LONG*3/10) + MODULE_NAME_LEN + 1];

-	name = kallsyms_lookup(address, &size, &offset, &modname, namebuf);
+	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);

 	if (!name)
 		sprintf(buffer, "0x%lx", address);
 	else {
+		bufend = strchr(buffer, '\0');
+		bufend += sprintf(bufend, "+%#lx/%#lx", offset, size);
 		if (modname)
-			sprintf(buffer, "%s+%#lx/%#lx [%s]", name, offset,
-				size, modname);
-		else
-			sprintf(buffer, "%s+%#lx/%#lx", name, offset, size);
+			sprintf(bufend, " [%s]", modname);
 	}
 	printk(fmt, buffer);
 }


  parent reply	other threads:[~2005-07-11 13:28 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-06 11:57 Realtime Preemption, 2.6.12, Beginners Guide? Alistair John Strachan
2005-07-06 12:51 ` Alistair John Strachan
2005-07-06 13:39   ` Ingo Molnar
2005-07-06 15:58     ` Alistair John Strachan
2005-07-06 16:28       ` Ingo Molnar
2005-07-06 16:31         ` Alistair John Strachan
2005-07-06 13:31 ` Ingo Molnar
2005-07-06 15:55   ` Alistair John Strachan
2005-07-06 16:24     ` Ingo Molnar
2005-07-06 16:37       ` Alistair John Strachan
2005-07-06 16:56         ` Alistair John Strachan
2005-07-06 17:01           ` Ingo Molnar
2005-07-06 17:14             ` Alistair John Strachan
2005-07-06 17:27               ` Ingo Molnar
2005-07-06 18:23                 ` Alistair John Strachan
2005-07-06 18:38                   ` Ingo Molnar
2005-07-06 18:41                     ` Ingo Molnar
2005-07-06 19:47                       ` Alistair John Strachan
2005-07-06 20:44                         ` Ingo Molnar
2005-07-06 21:00                           ` Alistair John Strachan
2005-07-06 21:02                             ` Ingo Molnar
2005-07-06 22:15                               ` Alistair John Strachan
2005-07-06 23:08                                 ` Fernando Lopez-Lezcano
2005-07-07  6:04                                   ` Michal Schmidt
2005-07-07 10:25                                     ` Ingo Molnar
2005-07-07  9:46                           ` Alistair John Strachan
2005-07-07 11:21                             ` Alistair John Strachan
2005-07-07 11:29                               ` Ingo Molnar
2005-07-07 11:37                                 ` Alistair John Strachan
2005-07-07 11:42                                   ` Ingo Molnar
2005-07-07 12:15                                     ` Alistair John Strachan
2005-07-07 12:29                                       ` Ingo Molnar
2005-07-07 13:38                                         ` Alistair John Strachan
2005-07-07 12:33                                       ` Alistair John Strachan
2005-07-08  9:47                                     ` Alistair John Strachan
2005-07-08 11:46                                       ` Ingo Molnar
2005-07-08 18:38                                         ` Alistair John Strachan
2005-07-08 19:12                                           ` USB storage does not work with 3GB of RAM, but does with 2G of RAM Jon Schindler
2005-07-08 19:25                                           ` Realtime Preemption, 2.6.12, Beginners Guide? Ingo Molnar
2005-07-08 19:31                                           ` Ingo Molnar
2005-07-08 19:34                                             ` Ingo Molnar
2005-07-08 19:48                                           ` Ingo Molnar
2005-07-08 19:55                                             ` Alistair John Strachan
2005-07-08 20:45                                             ` Alistair John Strachan
2005-07-09 11:58                                               ` Ingo Molnar
2005-07-09 14:07                                                 ` Alistair John Strachan
2005-07-09 14:55                                                   ` Ingo Molnar
2005-07-09 15:57                                                   ` Ingo Molnar
2005-07-09 16:02                                                     ` Ingo Molnar
2005-07-09 16:04                                                     ` Alistair John Strachan
2005-07-11 13:55                                                       ` Alistair John Strachan
2005-07-11 14:12                                                         ` Ingo Molnar
2005-07-11 14:16                                                           ` Ingo Molnar
2005-07-11 14:38                                                             ` Alistair John Strachan
2005-07-11 14:43                                                               ` Ingo Molnar
2005-07-11 15:50                                                                 ` Alistair John Strachan
2005-07-13 14:45                                                                   ` Ingo Molnar
2005-07-13 15:30                                                                     ` Ingo Molnar
2005-07-14 19:58                                                                       ` Alistair John Strachan
2005-07-14 20:16                                                                         ` Lee Revell
2005-07-15 22:12                                                                           ` Alistair John Strachan
2005-07-12  2:56                                                               ` Lee Revell
2005-07-11 15:07                                                             ` Ingo Molnar
2005-07-12 20:09                                                               ` Lee Revell
2005-07-12 21:01                                                                 ` Chuck Harding
2005-07-13 10:39                                                                   ` Ingo Molnar
2005-07-13 12:29                                                                     ` Gene Heskett
2005-07-13 14:01                                                                     ` K.R. Foley
2005-07-13 19:41                                                                       ` Chuck Harding
2005-07-13 19:45                                                                         ` Ingo Molnar
2005-07-14 13:39                                                                           ` K.R. Foley
2005-07-14 12:50                                                                       ` Karsten Wiese
2005-07-14 13:56                                                                         ` K.R. Foley
2005-07-14 14:10                                                                           ` K.R. Foley
2005-07-14 14:11                                                                             ` K.R. Foley
2005-07-14 19:49                                                                         ` Chuck Harding
2005-07-16 17:15                                                                         ` Ingo Molnar
2005-07-16 19:01                                                                           ` K.R. Foley
2005-07-17 12:07                                                                           ` Karsten Wiese
2005-07-18 15:46                                                                             ` K.R. Foley
2005-07-19 11:14                                                                             ` Karsten Wiese
2005-07-19 13:35                                                                               ` Gene Heskett
2005-07-19 13:57                                                                               ` Ingo Molnar
2005-07-19 15:19                                                                                 ` Gene Heskett
2005-07-19 23:00                                                                                   ` Karsten Wiese
2005-07-09 12:41                                               ` Ingo Molnar
2005-07-09 12:46                                                 ` Ingo Molnar
2005-07-09 13:05                                                 ` Ingo Molnar
2005-07-11 22:48                                                   ` William Weston
2005-07-12 13:53                                                     ` Ingo Molnar
2005-07-09 13:13                                                 ` Ingo Molnar
2005-07-09 13:26                                                 ` Ingo Molnar
2005-07-10 19:01                                                   ` PCMCIA stack reduction patch [Was: Re: Realtime Preemption, 2.6.12, Beginners Guide?] Dominik Brodowski
2005-07-09 13:36                                                 ` Realtime Preemption, 2.6.12, Beginners Guide? Ingo Molnar
2005-07-11 13:28                                                 ` Paulo Marques [this message]
2005-07-08 11:48                                       ` Ingo Molnar
2005-07-08 17:42                                         ` Alistair John Strachan
2005-07-08 17:48                                           ` Jakub Jelinek
2005-07-08 18:12                                             ` Alistair John Strachan
     [not found] <20050713063310.GA12661@elte.hu>
2005-07-13 10:30 ` karsten wiese
2005-07-13 18:38   ` Chuck Harding

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=42D27405.8070802@grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=arjanv@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=s0348365@sms.ed.ac.uk \
    /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;
as well as URLs for NNTP newsgroup(s).