1. 29 6月, 2012 1 次提交
    • K
      printk: flush continuation lines immediately to console · 084681d1
      Kay Sievers 提交于
      Continuation lines are buffered internally, intended to merge the
      chunked printk()s into a single record, and to isolate potentially
      racy continuation users from usual terminated line users.
      
      This though, has the effect that partial lines are not printed to
      the console in the moment they are emitted. In case the kernel
      crashes in the meantime, the potentially interesting printed
      information would never reach the consoles.
      
      Here we share the continuation buffer with the console copy logic,
      and partial lines are always immediately flushed to the available
      consoles. They are still buffered internally to improve the
      readability and integrity of the messages and minimize the amount
      of needed record headers to store.
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Tested-by: NSteven Rostedt <rostedt@goodmis.org>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      084681d1
  2. 27 6月, 2012 2 次提交
  3. 26 6月, 2012 1 次提交
  4. 16 6月, 2012 3 次提交
  5. 13 6月, 2012 1 次提交
  6. 15 5月, 2012 1 次提交
    • K
      printk() - isolate KERN_CONT users from ordinary complete lines · c313af14
      Kay Sievers 提交于
      Arrange the continuation printk() buffering to be fully separated from the
      ordinary full line users.
      
      Limit the exposure to races and wrong printk() line merges to users of
      continuation only. Ordinary full line users racing against continuation
      users will no longer affect each other.
      
      Multiple continuation users from different threads, racing against each
      other will not wrongly be merged into a single line, but printed as
      separate lines.
      
      Test output of a kernel module which starts two separate threads which
      race against each other, one of them printing a single full terminated
      line:
        printk("(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)\n");
      
      The other one printing the line, every character separate in a
      continuation loop:
        printk("(C");
        for (i = 0; i < 58; i++)
                printk(KERN_CONT "C");
        printk(KERN_CONT "C)\n");
      
      Behavior of single and non-thread-aware printk() buffer:
        # modprobe printk-race
        printk test init
        (CC(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        C(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        CC(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        C(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        CC(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        C(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        C(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        CC(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        C(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        C(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC)
        (CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC)
      
      New behavior with separate and thread-aware continuation buffer:
        # modprobe printk-race
        printk test init
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC)
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
        (CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC)
        (CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC)
      
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Ted Ts'o <tytso@mit.edu>
      Cc: Ingo Molnar  <mingo@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Sasha Levin <levinsasha928@gmail.com>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c313af14
  7. 14 5月, 2012 1 次提交
  8. 12 5月, 2012 1 次提交
  9. 11 5月, 2012 1 次提交
  10. 10 5月, 2012 3 次提交
  11. 08 5月, 2012 3 次提交
    • K
      kmsg: use do_div() to divide 64bit integer · 5fc32490
      Kay Sievers 提交于
      On Tue, May 8, 2012 at 10:02 AM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
      > kernel/built-in.o: In function `devkmsg_read':
      > printk.c:(.text+0x27e8): undefined reference to `__udivdi3'
      > Most probably the "msg->ts_nsec / 1000" since
      > ts_nsec is a u64 and this is a 32 bit build ...
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fc32490
    • K
      kmsg: export printk records to the /dev/kmsg interface · e11fea92
      Kay Sievers 提交于
      Support for multiple concurrent readers of /dev/kmsg, with read(),
      seek(), poll() support. Output of message sequence numbers, to allow
      userspace log consumers to reliably reconnect and reconstruct their
      state at any given time. After open("/dev/kmsg"), read() always
      returns *all* buffered records. If only future messages should be
      read, SEEK_END can be used. In case records get overwritten while
      /dev/kmsg is held open, or records get faster overwritten than they
      are read, the next read() will return -EPIPE and the current reading
      position gets updated to the next available record. The passed
      sequence numbers allow the log consumer to calculate the amount of
      lost messages.
      
        [root@mop ~]# cat /dev/kmsg
        5,0,0;Linux version 3.4.0-rc1+ (kay@mop) (gcc version 4.7.0 20120315 ...
        6,159,423091;ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
        7,160,424069;pci_root PNP0A03:00: host bridge window [io  0x0000-0x0cf7] (ignored)
         SUBSYSTEM=acpi
         DEVICE=+acpi:PNP0A03:00
        6,339,5140900;NET: Registered protocol family 10
        30,340,5690716;udevd[80]: starting version 181
        6,341,6081421;FDC 0 is a S82078B
        6,345,6154686;microcode: CPU0 sig=0x623, pf=0x0, revision=0x0
        7,346,6156968;sr 1:0:0:0: Attached scsi CD-ROM sr0
         SUBSYSTEM=scsi
         DEVICE=+scsi:1:0:0:0
        6,347,6289375;microcode: CPU1 sig=0x623, pf=0x0, revision=0x0
      
      Cc: Karel Zak <kzak@redhat.com>
      Tested-by: NWilliam Douglas <william.douglas@intel.com>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e11fea92
    • K
      printk: convert byte-buffer to variable-length record buffer · 7ff9554b
      Kay Sievers 提交于
      - Record-based stream instead of the traditional byte stream
        buffer. All records carry a 64 bit timestamp, the syslog facility
        and priority in the record header.
      
      - Records consume almost the same amount, sometimes less memory than
        the traditional byte stream buffer (if printk_time is enabled). The record
        header is 16 bytes long, plus some padding bytes at the end if needed.
        The byte-stream buffer needed 3 chars for the syslog prefix, 15 char for
        the timestamp and a newline.
      
      - Buffer management is based on message sequence numbers. When records
        need to be discarded, the reading heads move on to the next full
        record. Unlike the byte-stream buffer, no old logged lines get
        truncated or partly overwritten by new ones. Sequence numbers also
        allow consumers of the log stream to get notified if any message in
        the stream they are about to read gets discarded during the time
        of reading.
      
      - Better buffered IO support for KERN_CONT continuation lines, when printk()
        is called multiple times for a single line. The use of KERN_CONT is now
        mandatory to use continuation; a few places in the kernel need trivial fixes
        here. The buffering could possibly be extended to per-cpu variables to allow
        better thread-safety for multiple printk() invocations for a single line.
      
      - Full-featured syslog facility value support. Different facilities
        can tag their messages. All userspace-injected messages enforce a
        facility value > 0 now, to be able to reliably distinguish them from
        the kernel-generated messages. Independent subsystems like a
        baseband processor running its own firmware, or a kernel-related
        userspace process can use their own unique facility values. Multiple
        independent log streams can co-exist that way in the same
        buffer. All share the same global sequence number counter to ensure
        proper ordering (and interleaving) and to allow the consumers of the
        log to reliably correlate the events from different facilities.
      Tested-by: NWilliam Douglas <william.douglas@intel.com>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ff9554b
  12. 15 3月, 2012 1 次提交
  13. 13 3月, 2012 1 次提交
  14. 06 3月, 2012 1 次提交
    • M
      kmsg_dump: don't run on non-error paths by default · c22ab332
      Matthew Garrett 提交于
      Since commit 04c6862c ("kmsg_dump: add kmsg_dump() calls to the
      reboot, halt, poweroff and emergency_restart paths"), kmsg_dump() gets
      run on normal paths including poweroff and reboot.
      
      This is less than ideal given pstore implementations that can only
      represent single backtraces, since a reboot may overwrite a stored oops
      before it's been picked up by userspace.  In addition, some pstore
      backends may have low performance and provide a significant delay in
      reboot as a result.
      
      This patch adds a printk.always_kmsg_dump kernel parameter (which can also
      be changed from userspace).  Without it, the code will only be run on
      failure paths rather than on normal paths.  The option can be enabled in
      environments where there's a desire to attempt to audit whether or not a
      reboot was cleanly requested or not.
      Signed-off-by: NMatthew Garrett <mjg@redhat.com>
      Acked-by: NSeiji Aguchi <seiji.aguchi@hds.com>
      Cc: Seiji Aguchi <seiji.aguchi@hds.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Marco Stornelli <marco.stornelli@gmail.com>
      Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c22ab332
  15. 14 2月, 2012 1 次提交
  16. 13 1月, 2012 2 次提交
  17. 09 12月, 2011 1 次提交
  18. 14 11月, 2011 3 次提交
  19. 01 11月, 2011 4 次提交
  20. 13 9月, 2011 1 次提交
  21. 26 8月, 2011 1 次提交
  22. 10 8月, 2011 1 次提交
  23. 14 7月, 2011 1 次提交
  24. 22 6月, 2011 1 次提交
  25. 07 6月, 2011 1 次提交
  26. 25 5月, 2011 1 次提交
    • M
      printk: allocate kernel log buffer earlier · 162a7e75
      Mike Travis 提交于
      On larger systems, because of the numerous ACPI, Bootmem and EFI messages,
      the static log buffer overflows before the larger one specified by the
      log_buf_len param is allocated.  Minimize the overflow by allocating the
      new log buffer as soon as possible.
      
      On kernels without memblock, a later call to setup_log_buf from
      kernel/init.c is the fallback.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: fix CONFIG_PRINTK=n build]
      Signed-off-by: NMike Travis <travis@sgi.com>
      Cc: Yinghai Lu <yhlu.kernel@gmail.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Jack Steiner <steiner@sgi.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      162a7e75
  27. 23 3月, 2011 1 次提交