07 Feb, 2008

1 commit

  • Stop using unsigned _longs_ for printk buffer indexes. Log buffer is way
    smaller than 2 gigabytes and unsigned ints will work too . Indeed, they do
    work nicely on all 32-bit platforms where longs and ints are the same.

    With this patch, we have following size savings on amd64:

    text data bss dec hex filename
    5997 313 17736 24046 5dee 2.6.23.1.t64/kernel/printk.o
    5858 313 17700 23871 5d3f 2.6.23.1.printk.t64/kernel/printk.o

    Signed-off-by: Denys Vlasenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Denys Vlasenko
     

01 Feb, 2008

1 commit


30 Jan, 2008

1 commit


27 Jan, 2008

1 commit


26 Jan, 2008

4 commits

  • printk timestamps: use ktime_get().

    Some platforms have a functioning clocksource function only after
    they are done with early bootup, so delay this until out of
    SYSTEM_BOOTING state.

    it's also inherently safe now, as any bugs in this area will be
    caught by the printk recursion checks.

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • printk_clock() is obsolete - it has been replaced with cpu_clock().

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Stefano Brivio reported weird printk timestamp behavior during
    CPU frequency changes:

    http://bugzilla.kernel.org/show_bug.cgi?id=9475

    fix CONFIG_PRINT_TIME's reliance on sched_clock() and use cpu_clock()
    instead.

    Reported-and-bisected-by: Stefano Brivio
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • make printk more robust by allowing recursion only if there's a crash
    going on. Also add recursion detection.

    I've tested it with an artificially injected printk recursion - instead
    of a lockup or spontaneous reboot or other crash, the output was a well
    controlled:

    [ 41.057335] SysRq : BUG: recent printk recursion!
    [ 41.057335] loglevel0-8 reBoot Crashdump show-all-locks(D) tErm Full kIll saK showMem Nice powerOff showPc show-all-timers(Q) unRaw Sync showTasks Unmount shoW-blocked-tasks

    also do all this printk-debug logic with irqs disabled.

    Signed-off-by: Ingo Molnar
    Reviewed-by: Nick Piggin

    Ingo Molnar
     

29 Dec, 2007

1 commit

  • We're exporting an __init function, oops :-)

    The core issue here is that add_preferred_console() is marked
    as __init, this makes it impossible to invoke this thing from
    a driver probe routine which is what the Sparc serial drivers
    need to do.

    There is no harm in dropping the __init marker. This code will
    actually work properly when invoked from a modular driver,
    except that init will probably not pick up the console change
    without some other support code.

    Then we can drop the __init from sunserial_console_match()
    and we're no longer exporting an __init function to modules.

    Signed-off-by: David S. Miller

    David S. Miller
     

19 Oct, 2007

1 commit

  • Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
    the serial console from being suspended when the rest of the machine goes
    to sleep. This is incredibly useful for debugging power management-related
    things; however, having it as a compile-time option has proved to be
    incredibly inconvenient for us (OLPC). There are plenty of times that we
    want serial console to not suspend, but for the most part we'd like serial
    console to be suspended.

    This drops CONFIG_DISABLE_CONSOLE_SUSPEND, and replaces it with a kernel
    boot parameter (no_console_suspend). By default, the serial console will
    be suspended along with the rest of the system; by passing
    'no_console_suspend' to the kernel during boot, serial console will remain
    alive during suspend.

    For now, this is pretty serial console specific; further fixes could be
    applied to make this work for things like netconsole.

    Signed-off-by: Andres Salomon
    Acked-by: "Rafael J. Wysocki"
    Acked-by: Pavel Machek
    Cc: Nigel Cunningham
    Cc: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andres Salomon
     

17 Oct, 2007

2 commits

  • Add two new functions for reading the kernel log buffer. The intention is for
    them to be used by recovery/dump/debug code so the kernel log can be easily
    retrieved/parsed in a crash scenario, but they are generic enough for other
    people to dream up other fun uses.

    [akpm@linux-foundation.org: buncha fixes]
    Signed-off-by: Mike Frysinger
    Cc: Robin Getz
    Cc: Greg Ungerer
    Cc: Russell King
    Cc: Paul Mundt
    Acked-by: Tim Bird
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     
  • Optionally add a boot delay after each kernel printk() call, crudely
    measured in milliseconds, with a maximum delay of 10 seconds per printk.

    Enable CONFIG_BOOT_PRINTK_DELAY=y and then add (e.g.):
    "lpj=loops_per_jiffy boot_delay=100"
    to the kernel command line.

    It has been useful in cases like "during boot, my machine just reboots or the
    screen goes black" by slowing down printk, (and adding initcall_debug), we can
    usually see the last thing that happened before the lights went out which is
    usually a valuable clue.

    [akpm@linux-foundation.org: not all architectures implement CONFIG_HZ]
    [akpm@linux-foundation.org: fix lots of stuff]
    [bunk@stusta.de: kernel/printk.c: make 2 variables static]
    [heiko.carstens@de.ibm.com: fix slow down printk on boot compile error]
    Signed-off-by: Randy Dunlap
    Signed-off-by: Dave Jones
    Signed-off-by: Adrian Bunk
    Signed-off-by: Heiko Carstens
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

22 Aug, 2007

1 commit


21 Aug, 2007

1 commit

  • This is a followup to the cleanups for earlyprintk patch from Gerd Hoffmann

    http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69331af79cf29e26d1231152a172a1a10c2df511

    This ensures that a bootconsole is unregistered if it is not replaced.
    The current implementation spews garbage out the bootconsole in this case,
    since the bootconsole structure is normally in the init section, and is
    freed, but still used.

    Signed-off-by: Robin Getz
    Acked-by: Gerd Hoffmann
    Acked-by: Paul Mundt
    Cc: Mike Frysinger
    Signed-off-by: Linus Torvalds

    Robin Getz
     

04 Aug, 2007

1 commit

  • the early setup function serial8250_console_early_setup() can be called
    from non __init code (eg. hotpluggable serial ports like serial_cs) so
    remove the __init from the call chain to avoid crashes.

    Signed-off-by: Daniel Ritz
    Cc: Yinghai Lu
    Signed-off-by: Linus Torvalds

    Daniel Ritz
     

17 Jul, 2007

5 commits

  • kernel/printk.c: document possible deadlock against scheduler

    The printk's comment states that it can be called from every context,
    which might lead to false illusion that it could be called from everywhere
    without any restrictions.

    This is however not true - a call to printk() could deadlock if called from
    scheduler code (namely from schedule(), wake_up(), etc) on runqueue lock
    when it tries to wake up klogd. Document this.

    Signed-off-by: Jiri Kosina
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiri Kosina
     
  • Allow printk_time to be enabled or disabled at boot time. Previously it
    could be enabled only, but not disabled.

    Change printk_time from an int to a bool since that's what it is. Make its
    logical (exposed) name just be "time" (was "printk_time").

    Note: Changes kernel boot option syntax from "time" to "printk.time=value".

    Since printk_time is declared as a module_param, it can also be
    changed at run-time by modifying
    /sys/module/printk/parameters/time
    to a value of 1/Y/y to enabled it or 0/N/n to disable it.

    Since printk_time is declared as a module_param, its value can also
    be set at boot-time by using
    linux printk.time=

    If the "time" boot option is used, print a message that it is deprecated
    and will be removed.

    Note its planned removal in feature-removal-schedule.txt.

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • Beacuse SERIAL_PORT_DFNS is removed from include/asm-i386/serial.h and
    include/asm-x86_64/serial.h. the serial8250_ports need to be probed late in
    serial initializing stage. the console_init=>serial8250_console_init=>
    register_console=>serial8250_console_setup will return -ENDEV, and console
    ttyS0 can not be enabled at that time. need to wait till uart_add_one_port in
    drivers/serial/serial_core.c to call register_console to get console ttyS0.
    that is too late.

    Make early_uart to use early_param, so uart console can be used earlier. Make
    it to be bootconsole with CON_BOOT flag, so can use console handover feature.
    and it will switch to corresponding normal serial console automatically.

    new command line will be:
    console=uart8250,io,0x3f8,9600n8
    console=uart8250,mmio,0xff5e0000,115200n8
    or
    earlycon=uart8250,io,0x3f8,9600n8
    earlycon=uart8250,mmio,0xff5e0000,115200n8

    it will print in very early stage:
    Early serial console at I/O port 0x3f8 (options '9600n8')
    console [uart0] enabled
    later for console it will print:
    console handover: boot [uart0] -> real [ttyS0]

    Signed-off-by:
    Cc: Andi Kleen
    Cc: Bjorn Helgaas
    Cc: Russell King
    Cc: Gerd Hoffmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     
  • for earlyprintk=ttyS0,9600 console=tty0 console=ttyS0,9600n8

    the handover will happen from earlyser0 to tty0. but what we want is to
    hand over to ttyS0.

    Later with serial-convert-early_uart-to-earlycon-for-8250.patch,

    console=tty0 console=uart8250,io,0x3f8,9600n8

    will handover to ttyS0 instead of tty0.

    Signed-off-by: Yinghai Lu
    Cc: Andi Kleen
    Cc: Bjorn Helgaas
    Cc: Russell King
    Cc: Gerd Hoffmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     
  • Change name to buf according to the usage as name + index

    Signed-off-by: Yinghai Lu
    Cc: Andi Kleen
    Cc: Bjorn Helgaas
    Cc: Russell King
    Cc: Gerd Hoffmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     

09 May, 2007

2 commits

  • Remove includes of where it is not used/needed.
    Suggested by Al Viro.

    Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc,
    sparc64, and arm (all 59 defconfigs).

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • The console subsystem already has an idea of a boot console, using the
    CON_BOOT flag. The implementation has some flaws though. The major
    problem is that presence of a boot console makes register_console() ignore
    any other console devices (unless explicitly specified on the kernel
    command line).

    This patch fixes the console selection code to *not* consider a boot
    console a full-featured one, so the first non-boot console registering will
    become the default console instead. This way the unregister call for the
    boot console in the register_console() function actually triggers and the
    handover from the boot console to the real console device works smoothly.
    Added a printk for the handover, so you know which console device the
    output goes to when the boot console stops printing messages.

    The disable_early_printk() call is obsolete with that patch, explicitly
    disabling the early console isn't needed any more as it works automagically
    with that patch.

    I've walked through the tree, dropped all disable_early_printk() instances
    found below arch/ and tagged the consoles with CON_BOOT if needed. The
    code is tested on x86, sh (thanks to Paul) and mips (thanks to Ralf).

    Changes to last version: Rediffed against -rc3, adapted to mips cleanups by
    Ralf, fixed "udbg-immortal" cmd line arg on powerpc.

    Signed-off-by: Gerd Hoffmann
    Acked-by: Paul Mundt
    Acked-by: Ralf Baechle
    Cc: Andi Kleen
    Cc: Alan Cox
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Paul Mackerras
    Cc: Benjamin Herrenschmidt
    Cc: Jeremy Fitzhardinge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gerd Hoffmann
     

18 Feb, 2007

1 commit


12 Feb, 2007

3 commits

  • The order of locking between lockdep_off/on() and local_irq_save/restore() in
    vprintk() should be changed.

    * In kernel/printk.c :

    vprintk() does :

    preempt_disable()
    local_irq_save()
    lockdep_off()
    spin_lock(&logbuf_lock)
    spin_unlock(&logbuf_lock)
    if(!down_trylock(&console_sem))
    up(&console_sem)
    lockdep_on()
    local_irq_restore()
    preempt_enable()

    The goals here is to make sure we do not call printk() recursively from
    kernel/lockdep.c:__lock_acquire() (called from spin_* and down/up) nor from
    kernel/lockdep.c:trace_hardirqs_on/off() (called from local_irq_restore/save).
    It can then potentially call printk() through mark_held_locks/mark_lock.

    It correctly protects against the spin_lock call and the up/down call, but it
    does not protect against local_irq_restore. It could cause infinite recursive
    printk/trace_hardirqs_on() calls when printk() is called from the
    mark_lock() error handing path.

    We should change the locking so it becomes correct :

    preempt_disable()
    lockdep_off()
    local_irq_save()
    spin_lock(&logbuf_lock)
    spin_unlock(&logbuf_lock)
    if(!down_trylock(&console_sem))
    up(&console_sem)
    local_irq_restore()
    lockdep_on()
    preempt_enable()

    Signed-off-by: Mathieu Desnoyers
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mathieu Desnoyers
     
  • Remove hack with printing space to wake up klogd. Use explicit
    wake_up_klogd().

    See earlier discussion
    http://groups.google.com/group/fa.linux.kernel/browse_frm/thread/75f496668409f58d/1a8f28983a51e1ff?lnk=st&q=wake_up_klogd+group%3Afa.linux.kernel&rnum=2#1a8f28983a51e1ff

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kirill Korotaev
     
  • A variety of (mostly) innocuous fixes to the embedded kernel-doc content in
    source files, including:

    * make multi-line initial descriptions single line
    * denote some function names, constants and structs as such
    * change erroneous opening '/*' to '/**' in a few places
    * reword some text for clarity

    Signed-off-by: Robert P. J. Day
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

23 Dec, 2006

1 commit


08 Dec, 2006

3 commits


04 Nov, 2006

1 commit

  • printk_ratelimit() has global state which makes it not useful for callers
    which wish to perform ratelimiting at a particular frequency.

    Add a printk_timed_ratelimit() which utilises caller-provided state storage to
    permit more flexibility.

    This function can in fact be used for things other than printk ratelimiting
    and is perhaps poorly named.

    Cc: Ulrich Drepper
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

12 Oct, 2006

1 commit

  • Bug reported and fixed by Tilman Schmidt : if lockdep is
    enabled then log messages make it to /var/log/messages belatedly. The
    reason is a missed wakeup of klogd.

    Initially there was only a lockdep_internal() protection against lockdep
    recursion within vprintk() - it grew the 'outer' lockdep_off()/on()
    protection only later on. But that lockdep_off() made the
    release_console_sem() within vprintk() always happen under the
    lockdep_internal() condition, causing the bug.

    The right solution to remove the inner protection against recursion here -
    the outer one is enough.

    Signed-off-by: Ingo Molnar
    Cc: Tilman Schmidt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ingo Molnar
     

26 Sep, 2006

1 commit


06 Aug, 2006

1 commit

  • Reported by: Dave Jones

    Whilst printk'ing to both console and serial console, I got this...
    (2.6.18rc1)

    BUG: sleeping function called from invalid context at kernel/sched.c:4438
    in_atomic():0, irqs_disabled():1

    Call Trace:
    [] show_trace+0xaa/0x23d
    [] dump_stack+0x15/0x17
    [] __might_sleep+0xb2/0xb4
    [] __cond_resched+0x15/0x55
    [] cond_resched+0x3b/0x42
    [] console_conditional_schedule+0x12/0x14
    [] fbcon_redraw+0xf6/0x160
    [] fbcon_scroll+0x5d9/0xb52
    [] scrup+0x6b/0xd6
    [] lf+0x24/0x44
    [] vt_console_print+0x166/0x23d
    [] __call_console_drivers+0x65/0x76
    [] _call_console_drivers+0x5e/0x62
    [] release_console_sem+0x14b/0x232
    [] fb_flashcursor+0x279/0x2a6
    [] run_workqueue+0xa8/0xfb
    [] worker_thread+0xef/0x122
    [] kthread+0x100/0x136
    [] child_rip+0x8/0x12

    This can occur when release_console_sem() is called but the log
    buffer still has contents that need to be flushed. The console drivers
    are called while the console_may_schedule flag is still true. The
    might_sleep() is triggered when fbcon calls console_conditional_schedule().

    Fix by setting console_may_schedule to zero earlier, before the call to the
    console drivers.

    Signed-off-by: Antonino Daplas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Antonino A. Daplas
     

11 Jul, 2006

1 commit


04 Jul, 2006

1 commit


01 Jul, 2006

1 commit


26 Jun, 2006

2 commits

  • Currently, enabling/disabling printk timestamps is only possible through
    reboot (bootparam) or recompile. I normally do not run with timestamps
    (since syslog handles that in a good manner), but for measuring small
    kernel delays (e.g. irq probing - see parport thread) I needed subsecond
    precision, but then again, just for some minutes rather than all kernel
    messages to come. The following patch adds a module_param() with which the
    timestamps can be en-/disabled in a live system through
    /sys/modules/printk/parameters/printk_time.

    Signed-off-by: Jan Engelhardt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Engelhardt
     
  • Currently printk is no use for early debugging because it refuses to
    actually print anything to the console unless
    cpu_online(smp_processor_id()) is true.

    The stated explanation is that console drivers may require per-cpu
    resources, or otherwise barf, because the system is not yet setup
    correctly. Fair enough.

    However some console drivers might be quite happy running early during
    boot, in fact we have one, and so it'd be nice if printk understood that.

    So I added a flag (which I would have called CON_BOOT, but that's taken)
    called CON_ANYTIME, which indicates that a console is happy to be called
    anytime, even if the cpu is not yet online.

    Tested on a Power 5 machine, with both a CON_ANYTIME driver and a bogus
    console driver that BUG()s if called while offline. No problems AFAICT.
    Built for i386 UP & SMP.

    Signed-off-by: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Ellerman
     

20 Jun, 2006

1 commit