09 Sep, 2021

1 commit

  • Fix kernel-doc warnings in dump_stack.c:

    lib/dump_stack.c:97: warning: Function parameter or member 'log_lvl' not described in 'dump_stack_lvl'
    lib/dump_stack.c:97: warning: expecting prototype for dump_stack(). Prototype was for dump_stack_lvl() instead

    Link: https://lkml.kernel.org/r/20210809051643.17567-1-rdunlap@infradead.org
    Signed-off-by: Randy Dunlap
    Cc: Andrew Morton
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

09 Jul, 2021

1 commit

  • Add the running kernel's build ID[1] to the stacktrace information header.
    This makes it simpler for developers to locate the vmlinux with full
    debuginfo for a particular kernel stacktrace. Combined with
    scripts/decode_stracktrace.sh, a developer can download the correct
    vmlinux from a debuginfod[2] server and find the exact file and line
    number for the functions plus offsets in a stacktrace.

    This is especially useful for pstore crash debugging where the kernel
    crashes are recorded in the pstore logs and the recovery kernel is
    different or the debuginfo doesn't exist on the device due to space
    concerns (the data can be large and a security concern). The stacktrace
    can be analyzed after the crash by using the build ID to find the matching
    vmlinux and understand where in the function something went wrong.

    Example stacktrace from lkdtm:

    WARNING: CPU: 4 PID: 3255 at drivers/misc/lkdtm/bugs.c:83 lkdtm_WARNING+0x28/0x30 [lkdtm]
    Modules linked in: lkdtm rfcomm algif_hash algif_skcipher af_alg xt_cgroup uinput xt_MASQUERADE
    CPU: 4 PID: 3255 Comm: bash Not tainted 5.11 #3 aa23f7a1231c229de205662d5a9e0d4c580f19a1
    Hardware name: Google Lazor (rev3+) with KB Backlight (DT)
    pstate: 00400009 (nzcv daif +PAN -UAO -TCO BTYPE=--)
    pc : lkdtm_WARNING+0x28/0x30 [lkdtm]

    The hex string aa23f7a1231c229de205662d5a9e0d4c580f19a1 is the build ID,
    following the kernel version number. Put it all behind a config option,
    STACKTRACE_BUILD_ID, so that kernel developers can remove this
    information if they decide it is too much.

    Link: https://lkml.kernel.org/r/20210511003845.2429846-5-swboyd@chromium.org
    Link: https://fedoraproject.org/wiki/Releases/FeatureBuildId [1]
    Link: https://sourceware.org/elfutils/Debuginfod.html [2]
    Signed-off-by: Stephen Boyd
    Cc: Jiri Olsa
    Cc: Alexei Starovoitov
    Cc: Jessica Yu
    Cc: Evan Green
    Cc: Hsin-Yi Wang
    Cc: Petr Mladek
    Cc: Steven Rostedt
    Cc: Andy Shevchenko
    Cc: Matthew Wilcox
    Cc: Baoquan He
    Cc: Borislav Petkov
    Cc: Catalin Marinas
    Cc: Dave Young
    Cc: Ingo Molnar
    Cc: Konstantin Khlebnikov
    Cc: Rasmus Villemoes
    Cc: Sasha Levin
    Cc: Sergey Senozhatsky
    Cc: Thomas Gleixner
    Cc: Vivek Goyal
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     

30 Jun, 2021

2 commits

  • Merge misc updates from Andrew Morton:
    "191 patches.

    Subsystems affected by this patch series: kthread, ia64, scripts,
    ntfs, squashfs, ocfs2, kernel/watchdog, and mm (gup, pagealloc, slab,
    slub, kmemleak, dax, debug, pagecache, gup, swap, memcg, pagemap,
    mprotect, bootmem, dma, tracing, vmalloc, kasan, initialization,
    pagealloc, and memory-failure)"

    * emailed patches from Andrew Morton : (191 commits)
    mm,hwpoison: make get_hwpoison_page() call get_any_page()
    mm,hwpoison: send SIGBUS with error virutal address
    mm/page_alloc: split pcp->high across all online CPUs for cpuless nodes
    mm/page_alloc: allow high-order pages to be stored on the per-cpu lists
    mm: replace CONFIG_FLAT_NODE_MEM_MAP with CONFIG_FLATMEM
    mm: replace CONFIG_NEED_MULTIPLE_NODES with CONFIG_NUMA
    docs: remove description of DISCONTIGMEM
    arch, mm: remove stale mentions of DISCONIGMEM
    mm: remove CONFIG_DISCONTIGMEM
    m68k: remove support for DISCONTIGMEM
    arc: remove support for DISCONTIGMEM
    arc: update comment about HIGHMEM implementation
    alpha: remove DISCONTIGMEM and NUMA
    mm/page_alloc: move free_the_page
    mm/page_alloc: fix counting of managed_pages
    mm/page_alloc: improve memmap_pages dbg msg
    mm: drop SECTION_SHIFT in code comments
    mm/page_alloc: introduce vm.percpu_pagelist_high_fraction
    mm/page_alloc: limit the number of pages on PCP lists when reclaim is active
    mm/page_alloc: scale the number of pages that are batch freed
    ...

    Linus Torvalds
     
  • dump_stack() is used for many different cases, which may require a log
    level consistent with other kernel messages surrounding the dump_stack()
    call. Without that, certain systems that are configured to ignore the
    default level messages will miss stack traces in critical error reports.

    This patch introduces dump_stack_lvl() that behaves similarly to
    dump_stack(), but accepts a custom log level. The old dump_stack()
    becomes equal to dump_stack_lvl(KERN_DEFAULT).

    A somewhat similar patch has been proposed in 2012:
    https://lore.kernel.org/lkml/1332493269.2359.9.camel@hebo/ , but wasn't
    merged.

    [elver@google.com: add missing dump_stack_lvl() stub if CONFIG_PRINTK=n]
    Link: https://lkml.kernel.org/r/YJ0KAM0hQev1AmWe@elver.google.com

    Link: https://lkml.kernel.org/r/20210506105405.3535023-1-glider@google.com
    Signed-off-by: Alexander Potapenko
    Reviewed-by: Marco Elver
    Cc: Petr Mladek
    Cc: Ingo Molnar
    Cc: he, bo
    Cc: Yanmin Zhang
    Cc: Prasad Sodagudi
    Cc: Dmitry Vyukov
    Cc: Sergey Senozhatsky
    Cc: Steven Rostedt
    Cc: Andrey Ryabinin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     

22 Jun, 2021

1 commit

  • dump_stack() implements its own cpu-reentrant spinning lock to
    best-effort serialize stack traces in the printk log. However,
    there are other functions (such as show_regs()) that can also
    benefit from this serialization.

    Move the cpu-reentrant spinning lock (cpu lock) into new helper
    functions printk_cpu_lock_irqsave()/printk_cpu_unlock_irqrestore()
    so that it is available for others as well. For !CONFIG_SMP the
    cpu lock is a NOP.

    Note that having multiple cpu locks in the system can easily
    lead to deadlock. Code needing a cpu lock should use the
    printk cpu lock, since the printk cpu lock could be acquired
    from any code and any context.

    Also note that it is not necessary for a cpu lock to disable
    interrupts. However, in upcoming work this cpu lock will be used
    for emergency tasks (for example, atomic consoles during kernel
    crashes) and any interruptions while holding the cpu lock should
    be avoided if possible.

    Signed-off-by: John Ogness
    Reviewed-by: Sergey Senozhatsky
    Reviewed-by: Petr Mladek
    [pmladek@suse.com: Backported on top of 5.13-rc1.]
    Signed-off-by: Petr Mladek
    Link: https://lore.kernel.org/r/20210617095051.4808-2-john.ogness@linutronix.de

    John Ogness
     

11 Nov, 2020

1 commit

  • Crashes in stop-machine are hard to connect to the calling code, add a
    little something to help with that.

    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Valentin Schneider
    Reviewed-by: Daniel Bristot de Oliveira
    Link: https://lkml.kernel.org/r/20201023102346.116513635@infradead.org

    Peter Zijlstra
     

10 Jun, 2020

2 commits

  • Now the last users of show_stack() got converted to use an explicit log
    level, show_stack_loglvl() can drop it's redundant suffix and become once
    again well known show_stack().

    Signed-off-by: Dmitry Safonov
    Signed-off-by: Andrew Morton
    Link: http://lkml.kernel.org/r/20200418201944.482088-51-dima@arista.com
    Signed-off-by: Linus Torvalds

    Dmitry Safonov
     
  • Align the last users of show_stack() by KERN_DEFAULT as the surrounding
    headers/messages.

    Signed-off-by: Dmitry Safonov
    Signed-off-by: Andrew Morton
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Will Deacon
    Link: http://lkml.kernel.org/r/20200418201944.482088-50-dima@arista.com
    Signed-off-by: Linus Torvalds

    Dmitry Safonov
     

07 Nov, 2019

1 commit

  • In the current code, we use the atomic_cmpxchg() to serialize the output
    of the dump_stack(), but this implementation suffers the thundering herd
    problem. We have observed such kind of livelock on a Marvell cn96xx
    board(24 cpus) when heavily using the dump_stack() in a kprobe handler.
    Actually we can let the competitors to wait for the releasing of the
    lock before jumping to atomic_cmpxchg(). This will definitely mitigate
    the thundering herd problem. Thanks Linus for the suggestion.

    [akpm@linux-foundation.org: fix comment]
    Link: http://lkml.kernel.org/r/20191030031637.6025-1-haokexin@gmail.com
    Fixes: b58d977432c8 ("dump_stack: serialize the output from dump_stack()")
    Signed-off-by: Kevin Hao
    Suggested-by: Linus Torvalds
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kevin Hao
     

15 Mar, 2018

1 commit

  • dump_stack related stuff should belong to lib/dump_stack.c thus move them
    there. Also conditionally compile lib/dump_stack.c since dump_stack code
    does not make sense if printk is disabled.

    Link: http://lkml.kernel.org/r/20180213072834.GA24784@dhcp-128-65.nay.redhat.com
    To: Steven Rostedt
    Cc: linux-kernel@vger.kernel.org
    Cc: akpm@linux-foundation.org
    Cc: Andi Kleen
    Signed-off-by: Dave Young
    Suggested-by: Steven Rostedt
    Suggested-by: Sergey Senozhatsky
    Reviewed-by: Sergey Senozhatsky
    Signed-off-by: Petr Mladek

    Dave Young
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

02 Mar, 2017

1 commit


06 Feb, 2016

1 commit

  • Some servers experienced fatal deadlocks because of a combination of
    bugs, leading to multiple cpus calling dump_stack().

    The checksumming bug was fixed in commit 34ae6a1aa054 ("ipv6: update
    skb->csum when CE mark is propagated").

    The second problem is a faulty locking in dump_stack()

    CPU1 runs in process context and calls dump_stack(), grabs dump_lock.

    CPU2 receives a TCP packet under softirq, grabs socket spinlock, and
    call dump_stack() from netdev_rx_csum_fault().

    dump_stack() spins on atomic_cmpxchg(&dump_lock, -1, 2), since
    dump_lock is owned by CPU1

    While dumping its stack, CPU1 is interrupted by a softirq, and happens
    to process a packet for the TCP socket locked by CPU2.

    CPU1 spins forever in spin_lock() : deadlock

    Stack trace on CPU1 looked like :

    NMI backtrace for cpu 1
    RIP: _raw_spin_lock+0x25/0x30
    ...
    Call Trace:

    tcp_v6_rcv+0x243/0x620
    ip6_input_finish+0x11f/0x330
    ip6_input+0x38/0x40
    ip6_rcv_finish+0x3c/0x90
    ipv6_rcv+0x2a9/0x500
    process_backlog+0x461/0xaa0
    net_rx_action+0x147/0x430
    __do_softirq+0x167/0x2d0
    call_softirq+0x1c/0x30
    do_softirq+0x3f/0x80
    irq_exit+0x6e/0xc0
    smp_call_function_single_interrupt+0x35/0x40
    call_function_single_interrupt+0x6a/0x70

    printk+0x4d/0x4f
    printk_address+0x31/0x33
    print_trace_address+0x33/0x3c
    print_context_stack+0x7f/0x119
    dump_trace+0x26b/0x28e
    show_trace_log_lvl+0x4f/0x5c
    show_stack_log_lvl+0x104/0x113
    show_stack+0x42/0x44
    dump_stack+0x46/0x58
    netdev_rx_csum_fault+0x38/0x3c
    __skb_checksum_complete_head+0x6e/0x80
    __skb_checksum_complete+0x11/0x20
    tcp_rcv_established+0x2bd5/0x2fd0
    tcp_v6_do_rcv+0x13c/0x620
    sk_backlog_rcv+0x15/0x30
    release_sock+0xd2/0x150
    tcp_recvmsg+0x1c1/0xfc0
    inet_recvmsg+0x7d/0x90
    sock_recvmsg+0xaf/0xe0
    ___sys_recvmsg+0x111/0x3b0
    SyS_recvmsg+0x5c/0xb0
    system_call_fastpath+0x16/0x1b

    Fixes: b58d977432c8 ("dump_stack: serialize the output from dump_stack()")
    Signed-off-by: Eric Dumazet
    Cc: Alex Thorlton
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Dumazet
     

06 May, 2014

1 commit


07 Aug, 2013

1 commit


04 Jul, 2013

1 commit

  • Add functionality to serialize the output from dump_stack() to avoid
    mangling of the output when dump_stack is called simultaneously from
    multiple cpus.

    [akpm@linux-foundation.org: fix comment indenting, avoid inclusion of files - use where possiblem fix uniprocessor build (__dump_stack undefined), remove unneeded ifdef around smp.h inclusion]
    Signed-off-by: Alex Thorlton
    Reported-by: Russ Anderson
    Reviewed-by: Robin Holt
    Cc: Vineet Gupta
    Cc: David S. Miller
    Cc: Richard Kuo
    Cc: Jesper Nilsson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alex Thorlton
     

01 May, 2013

1 commit

  • Both dump_stack() and show_stack() are currently implemented by each
    architecture. show_stack(NULL, NULL) dumps the backtrace for the
    current task as does dump_stack(). On some archs, dump_stack() prints
    extra information - pid, utsname and so on - in addition to the
    backtrace while the two are identical on other archs.

    The usages in arch-independent code of the two functions indicate
    show_stack(NULL, NULL) should print out bare backtrace while
    dump_stack() is used for debugging purposes when something went wrong,
    so it does make sense to print additional information on the task which
    triggered dump_stack().

    There's no reason to require archs to implement two separate but mostly
    identical functions. It leads to unnecessary subtle information.

    This patch expands the dummy fallback dump_stack() implementation in
    lib/dump_stack.c such that it prints out debug information (taken from
    x86) and invokes show_stack(NULL, NULL) and drops arch-specific
    dump_stack() implementations in all archs except blackfin. Blackfin's
    dump_stack() does something wonky that I don't understand.

    Debug information can be printed separately by calling
    dump_stack_print_info() so that arch-specific dump_stack()
    implementation can still emit the same debug information. This is used
    in blackfin.

    This patch brings the following behavior changes.

    * On some archs, an extra level in backtrace for show_stack() could be
    printed. This is because the top frame was determined in
    dump_stack() on those archs while generic dump_stack() can't do that
    reliably. It can be compensated by inlining dump_stack() but not
    sure whether that'd be necessary.

    * Most archs didn't use to print debug info on dump_stack(). They do
    now.

    An example WARN dump follows.

    WARNING: at kernel/workqueue.c:4841 init_workqueues+0x35/0x505()
    Hardware name: empty
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #9
    0000000000000009 ffff88007c861e08 ffffffff81c614dc ffff88007c861e48
    ffffffff8108f50f ffffffff82228240 0000000000000040 ffffffff8234a03c
    0000000000000000 0000000000000000 0000000000000000 ffff88007c861e58
    Call Trace:
    [] dump_stack+0x19/0x1b
    [] warn_slowpath_common+0x7f/0xc0
    [] warn_slowpath_null+0x1a/0x20
    [] init_workqueues+0x35/0x505
    ...

    v2: CPU number added to the generic debug info as requested by s390
    folks and dropped the s390 specific dump_stack(). This loses %ksp
    from the debug message which the maintainers think isn't important
    enough to keep the s390-specific dump_stack() implementation.

    dump_stack_print_info() is moved to kernel/printk.c from
    lib/dump_stack.c. Because linkage is per objecct file,
    dump_stack_print_info() living in the same lib file as generic
    dump_stack() means that archs which implement custom dump_stack()
    - at this point, only blackfin - can't use dump_stack_print_info()
    as that will bring in the generic version of dump_stack() too. v1
    The v1 patch broke build on blackfin due to this issue. The build
    breakage was reported by Fengguang Wu.

    Signed-off-by: Tejun Heo
    Acked-by: David S. Miller
    Acked-by: Vineet Gupta
    Acked-by: Jesper Nilsson
    Acked-by: Vineet Gupta
    Acked-by: Martin Schwidefsky [s390 bits]
    Cc: Heiko Carstens
    Cc: Mike Frysinger
    Cc: Fengguang Wu
    Cc: Bjorn Helgaas
    Cc: Sam Ravnborg
    Acked-by: Richard Kuo [hexagon bits]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

08 Mar, 2012

1 commit


17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds