<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/printk/printk_safe.c, branch linux-5.17.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.17.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.17.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-07-26T13:09:44Z</updated>
<entry>
<title>printk: remove NMI tracking</title>
<updated>2021-07-26T13:09:44Z</updated>
<author>
<name>John Ogness</name>
</author>
<published>2021-07-15T19:33:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=85e3e7fbbb720b9897fba9a99659e31cbd1c082e'/>
<id>urn:sha1:85e3e7fbbb720b9897fba9a99659e31cbd1c082e</id>
<content type='text'>
All NMI contexts are handled the same as the safe context: store the
message and defer printing. There is no need to have special NMI
context tracking for this. Using in_nmi() is enough.

There are several parts of the kernel that are manually calling into
the printk NMI context tracking in order to cause general printk
deferred printing:

    arch/arm/kernel/smp.c
    arch/powerpc/kexec/crash.c
    kernel/trace/trace.c

For arm/kernel/smp.c and powerpc/kexec/crash.c, provide a new
function pair printk_deferred_enter/exit that explicitly achieves the
same objective.

For ftrace, remove the printk context manipulation completely. It was
added in commit 03fc7f9c99c1 ("printk/nmi: Prevent deadlock when
accessing the main log buffer in NMI"). The purpose was to enforce
storing messages directly into the ring buffer even in NMI context.
It really should have only modified the behavior in NMI context.
There is no need for a special behavior any longer. All messages are
always stored directly now. The console deferring is handled
transparently in vprintk().

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
[pmladek@suse.com: Remove special handling in ftrace.c completely.
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20210715193359.25946-5-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>printk: remove safe buffers</title>
<updated>2021-07-26T13:09:34Z</updated>
<author>
<name>John Ogness</name>
</author>
<published>2021-07-15T19:33:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=93d102f094be9beab28e5afb656c188b16a3793b'/>
<id>urn:sha1:93d102f094be9beab28e5afb656c188b16a3793b</id>
<content type='text'>
With @logbuf_lock removed, the high level printk functions for
storing messages are lockless. Messages can be stored from any
context, so there is no need for the NMI and safe buffers anymore.
Remove the NMI and safe buffers.

Although the safe buffers are removed, the NMI and safe context
tracking is still in place. In these contexts, store the message
immediately but still use irq_work to defer the console printing.

Since printk recursion tracking is in place, safe context tracking
for most of printk is not needed. Remove it. Only safe context
tracking relating to the console and console_owner locks is left
in place. This is because the console and console_owner locks are
needed for the actual printing.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20210715193359.25946-4-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>printk: Move EXPORT_SYMBOL() closer to vprintk definition</title>
<updated>2021-06-16T08:42:19Z</updated>
<author>
<name>Punit Agrawal</name>
</author>
<published>2021-06-14T23:56:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6262e1b906a1ba12688ea6039453b4a088dbaf44'/>
<id>urn:sha1:6262e1b906a1ba12688ea6039453b4a088dbaf44</id>
<content type='text'>
Commit 28e1745b9fa2 ("printk: rename vprintk_func to vprintk") while
improving readability by removing vprintk indirection, inadvertently
placed the EXPORT_SYMBOL() for the newly renamed function at the end
of the file.

For reader sanity, and as is convention move the EXPORT_SYMBOL()
declaration just after the end of the function.

Fixes: 28e1745b9fa2 ("printk: rename vprintk_func to vprintk")
Signed-off-by: Punit Agrawal &lt;punitagrawal@gmail.com&gt;
Acked-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Acked-by: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20210614235635.887365-1-punitagrawal@gmail.com
</content>
</entry>
<entry>
<title>printk: rename vprintk_func to vprintk</title>
<updated>2021-03-30T13:21:18Z</updated>
<author>
<name>Rasmus Villemoes</name>
</author>
<published>2021-03-23T14:42:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=28e1745b9fa23f71f465f6b65f966a1ef65af517'/>
<id>urn:sha1:28e1745b9fa23f71f465f6b65f966a1ef65af517</id>
<content type='text'>
The printk code is already hard enough to understand. Remove an
unnecessary indirection by renaming vprintk_func to vprintk (adding
the asmlinkage annotation), and removing the vprintk definition from
printk.c. That way, printk is implemented in terms of vprintk as one
would expect, and there's no "vprintk_func, what's that? Some function
pointer that gets set where?"

The declaration of vprintk in linux/printk.h already has the
__printf(1,0) attribute, there's no point repeating that with the
definition - it's for diagnostics in callers.

linux/printk.h already contains a static inline {return 0;} definition
of vprintk when !CONFIG_PRINTK.

Since the corresponding stub definition of vprintk_func was not marked
"static inline", any translation unit including internal.h would get a
definition of vprintk_func - it just so happens that for
!CONFIG_PRINTK, there is precisely one such TU, namely printk.c. Had
there been more, it would be a link error; now it's just a silly waste
of a few bytes of .text, which one must assume are rather precious to
anyone disabling PRINTK.

$ objdump -dr kernel/printk/printk.o
00000330 &lt;vprintk_func&gt;:
 330:   31 c0                   xor    %eax,%eax
 332:   c3                      ret
 333:   8d b4 26 00 00 00 00    lea    0x0(%esi,%eiz,1),%esi
 33a:   8d b6 00 00 00 00       lea    0x0(%esi),%esi

Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Reviewed-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20210323144201.486050-1-linux@rasmusvillemoes.dk
</content>
</entry>
<entry>
<title>printk: remove logbuf_lock</title>
<updated>2021-03-08T10:43:32Z</updated>
<author>
<name>John Ogness</name>
</author>
<published>2021-03-03T10:15:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=996e966640ddea7b535cbe7b749e87a3b24f37e8'/>
<id>urn:sha1:996e966640ddea7b535cbe7b749e87a3b24f37e8</id>
<content type='text'>
Since the ringbuffer is lockless, there is no need for it to be
protected by @logbuf_lock. Remove @logbuf_lock.

@console_seq, @exclusive_console_stop_seq, @console_dropped are
protected by @console_lock.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20210303101528.29901-14-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>printk: fix deadlock when kernel panic</title>
<updated>2021-02-10T12:57:06Z</updated>
<author>
<name>Muchun Song</name>
</author>
<published>2021-02-10T03:48:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8a8109f303e25a27f92c1d8edd67d7cbbc60a4eb'/>
<id>urn:sha1:8a8109f303e25a27f92c1d8edd67d7cbbc60a4eb</id>
<content type='text'>
printk_safe_flush_on_panic() caused the following deadlock on our
server:

CPU0:                                         CPU1:
panic                                         rcu_dump_cpu_stacks
  kdump_nmi_shootdown_cpus                      nmi_trigger_cpumask_backtrace
    register_nmi_handler(crash_nmi_callback)      printk_safe_flush
                                                    __printk_safe_flush
                                                      raw_spin_lock_irqsave(&amp;read_lock)
    // send NMI to other processors
    apic_send_IPI_allbutself(NMI_VECTOR)
                                                        // NMI interrupt, dead loop
                                                        crash_nmi_callback
  printk_safe_flush_on_panic
    printk_safe_flush
      __printk_safe_flush
        // deadlock
        raw_spin_lock_irqsave(&amp;read_lock)

DEADLOCK: read_lock is taken on CPU1 and will never get released.

It happens when panic() stops a CPU by NMI while it has been in
the middle of printk_safe_flush().

Handle the lock the same way as logbuf_lock. The printk_safe buffers
are flushed only when both locks can be safely taken. It can avoid
the deadlock _in this particular case_ at expense of losing contents
of printk_safe buffers.

Note: It would actually be safe to re-init the locks when all CPUs were
      stopped by NMI. But it would require passing this information
      from arch-specific code. It is not worth the complexity.
      Especially because logbuf_lock and printk_safe buffers have been
      obsoleted by the lockless ring buffer.

Fixes: cf9b1106c81c ("printk/nmi: flush NMI messages on the system panic")
Signed-off-by: Muchun Song &lt;songmuchun@bytedance.com&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Acked-by: Sergey Senozhatsky &lt;sergey.senozhatsky@gmail.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20210210034823.64867-1-songmuchun@bytedance.com
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial</title>
<updated>2020-10-15T22:11:56Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2020-10-15T22:11:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bbf625990371782370f6eacb3155dc1fe131ddfc'/>
<id>urn:sha1:bbf625990371782370f6eacb3155dc1fe131ddfc</id>
<content type='text'>
Pull trivial updates from Jiri Kosina:
 "The latest advances in computer science from the trivial queue"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial:
  xtensa: fix Kconfig typo
  spelling.txt: Remove some duplicate entries
  mtd: rawnand: oxnas: cleanup/simplify code
  selftests: vm: add fragment CONFIG_GUP_BENCHMARK
  perf: Fix opt help text for --no-bpf-event
  HID: logitech-dj: Fix spelling in comment
  bootconfig: Fix kernel message mentioning CONFIG_BOOT_CONFIG
  MAINTAINERS: rectify MMP SUPPORT after moving cputype.h
  scif: Fix spelling of EACCES
  printk: fix global comment
  lib/bitmap.c: fix spello
  fs: Fix missing 'bit' in comment
</content>
</entry>
<entry>
<title>printk: move dictionary keys to dev_printk_info</title>
<updated>2020-09-22T09:27:48Z</updated>
<author>
<name>John Ogness</name>
</author>
<published>2020-09-21T11:18:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=74caba7f2a0685575b3ee5330a118f5922485e02'/>
<id>urn:sha1:74caba7f2a0685575b3ee5330a118f5922485e02</id>
<content type='text'>
Dictionaries are only used for SUBSYSTEM and DEVICE properties. The
current implementation stores the property names each time they are
used. This requires more space than otherwise necessary. Also,
because the dictionary entries are currently considered optional,
it cannot be relied upon that they are always available, even if the
writer wanted to store them. These issues will increase should new
dictionary properties be introduced.

Rather than storing the subsystem and device properties in the
dict ring, introduce a struct dev_printk_info with separate fields
to store only the property values. Embed this struct within the
struct printk_info to provide guaranteed availability.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/87mu1jl6ne.fsf@jogness.linutronix.de
</content>
</entry>
<entry>
<title>Merge branch 'master' into for-next</title>
<updated>2020-09-01T12:19:48Z</updated>
<author>
<name>Jiri Kosina</name>
</author>
<published>2020-09-01T12:19:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ead5d1f4d877e92c051e1a1ade623d0d30e71619'/>
<id>urn:sha1:ead5d1f4d877e92c051e1a1ade623d0d30e71619</id>
<content type='text'>
Sync with Linus' branch in order to be able to apply fixups
of more recent patches.
</content>
</entry>
<entry>
<title>Merge tag 'printk-for-5.8-kdb-nmi' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux</title>
<updated>2020-06-12T19:13:36Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2020-06-12T19:13:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5c2fb57af0f42550eb718a3b0b445c81ec923895'/>
<id>urn:sha1:5c2fb57af0f42550eb718a3b0b445c81ec923895</id>
<content type='text'>
Pull printk fix from Petr Mladek:
 "One more printk change for 5.8: make sure that messages printed from
  KDB context are redirected to KDB console handlers. It did not work
  when KDB interrupted NMI or printk_safe contexts.

  Arm people started hitting this problem more often recently. I forgot
  to add the fix into the previous pull request by mistake"

* tag 'printk-for-5.8-kdb-nmi' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
  printk/kdb: Redirect printk messages into kdb in any context
</content>
</entry>
</feed>
