Skip to contentSkip to conversation

+ printk-hand-over-printing-to-console-if-printing-too-long.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Mar 13, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Subject: + printk-hand-over-printing-to-console-if-printing-too-long.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Thu, 13 Mar 2014 16:14:45 -0700

The patch titled
Subject: printk: hand over printing to console if printing too long
has been added to the -mm tree. Its filename is
printk-hand-over-printing-to-console-if-printing-too-long.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/printk-hand-over-printing-to-console-if-printing-too-long.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/printk-hand-over-printing-to-console-if-printing-too-long.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Jan Kara <[email protected]>
Subject: printk: hand over printing to console if printing too long

Currently, console_unlock() prints messages from kernel printk buffer to console while the buffer is non-empty. When serial console is attached, printing is slow and thus other CPUs in the system have plenty of time to append new messages to the buffer while one CPU is printing. Thus the CPU can spend unbounded amount of time doing printing in console_unlock(). This is especially serious problem if the printk() calling console_unlock() was called with interrupts disabled.

In practice users have observed a CPU can spend tens of seconds printing in console_unlock() (usually during boot when hundreds of SCSI devices are discovered) resulting in RCU stalls (CPU doing printing doesn't reach quiescent state for a long time), softlockup reports (IPIs for the printing CPU don't get served and thus other CPUs are spinning waiting for the printing CPU to process IPIs), and eventually a machine death (as messages from stalls and lockups append to printk buffer faster than we are able to print). So these machines are unable to boot with serial console attached. Also during artificial stress testing SATA disk disappears from the system because its interrupts aren't served for too long.

This patch implements a mechanism where after printing specified number of characters (tunable as a kernel parameter printk.offload_chars), CPU doing printing asks for help by setting PRINTK_HANDOVER_B bit in printk_handover_state variable and wakes up one of dedicated kthreads. As soon as the printing CPU notices kthread got scheduled and is spinning on console_sem, it drops console_sem and exits console_unlock(). kthread then takes over printing instead. This way no CPU should spend printing too long even if there is heavy printk traffic.

Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

---

 Documentation/kernel-parameters.txt |   16 ++
 kernel/printk/printk.c              |  196 +++++++++++++++++++++++---
 2 files changed, 195 insertions(+), 17 deletions(-)
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~printk-hand-over-printing-to-console-if-printing-too-long +16 -0
diff -puN Documentation/kernel-parameters.txt~printk-hand-over-printing-to-console-if-printing-too-long Documentation/kernel-parameters.txt
@@ -2626,6 +2626,22 @@ bytes respectively. Such letter suffixes
 			Format: <bool>  (1/Y/y=enable, 0/N/n=disable)
 			default: disabled
 
+	printk.offload_chars=
+			Printing to console can be relatively slow especially
+			in case of serial console. When there is intensive
+			printing happening from several cpus (as is the case
+			during boot), a cpu can be spending significant time
+			(seconds or more) doing printing. To avoid softlockups,
+			lost interrupts, and similar problems other cpus
+			will take over printing after the currently printing
+			cpu has printed 'printk.offload_chars' characters.
+			Higher value means possibly longer interrupt and other
+			latencies but lower latency of printing and lower
+			chance something goes wrong during system crash and
+			important message is not printed.
+			Format: <number>
+			default: 0 (disabled)
+
 	printk.time=	Show timing data prefixed to each printk message line
 			Format: <bool>  (1/Y/y=enable, 0/N/n=disable)
 
kernel/printk/printk.c renamed from kernel/printk/printk.c~printk-hand-over-printing-to-console-if-printing-too-long +179 -17

302 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

backing_dev-fix-hung-task-on-sync.patch backing_dev-fix-hung-task-on-sync-fix.patch bdi-avoid-oops-on-device-removal.patch kthread-ensure-locality-of-task_struct-allocations.patch fanotify-remove-useless-bypass_perm-check.patch fanotify-use-fanotify-event-structure-for-permission-response-processing.patch fanotify-convert-access_mutex-to-spinlock.patch fanotify-reorganize-loop-in-fanotify_read.patch fanotify-move-unrelated-handling-from-copy_event_to_user.patch ocfs2-remove-ocfs2_inode_skip_delete-flag.patch ocfs2-move-dquot_initialize-in-ocfs2_delete_inode-somewhat-later.patch quota-provide-function-to-grab-quota-structure-reference.patch ocfs2-implement-delayed-dropping-of-last-dquot-reference.patch ocfs2-avoid-blocking-in-ocfs2_mark_lockres_freeing-in-downconvert-thread.patch ocfs2-revert-iput-deferring-code-in-ocfs2_drop_dentry_lock.patch mm-vmstat-fix-up-zone-state-accounting.patch fs-cachefiles-use-add_to_page_cache_lru.patch lib-radix-tree-radix_tree_delete_item.patch mm-shmem-save-one-radix-tree-lookup-when-truncating-swapped-pages.patch mm-filemap-move-radix-tree-hole-searching-here.patch mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch mm-fs-store-shadow-entries-in-page-cache.patch mm-thrash-detection-based-file-cache-sizing.patch lib-radix_tree-tree-node-interface.patch mm-keep-page-cache-radix-tree-nodes-in-check.patch mm-readaheadc-fix-readahead-failure-for-memoryless-numa-nodes-and-limit-readahead-pages.patch fs-mpagec-forgotten-write_sync-in-case-of-data-integrity-write.patch printk-remove-duplicated-check-for-log-level.patch printk-remove-obsolete-check-for-log-level-c.patch printk-add-comment-about-tricky-check-for-text-buffer-size.patch printk-use-also-the-last-bytes-in-the-ring-buffer.patch printk-do-not-compute-the-size-of-the-message-twice.patch printk-remove-outdated-comment.patch printk-release-lockbuf_lock-before-calling-console_trylock_for_printk.patch printk-enable-interrupts-before-calling-console_trylock_for_printk.patch printk-remove-separate-printk_sched-buffers-and-use-printk-buf-instead.patch printk-hand-over-printing-to-console-if-printing-too-long.patch kernel-avoid-softlockups-in-stop_machine-during-heavy-printing.patch linux-next.patch
mm-add-strictlimit-knob-v2.patch