summaryrefslogtreecommitdiff
path: root/include/linux/console.h
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2023-09-16 22:20:05 +0300
committerPetr Mladek <pmladek@suse.com>2023-09-18 18:03:45 +0300
commitad56ebd1d79b216dc147474fac89a11daf6b10df (patch)
tree17c20b002afe4dbdd8b6a1c284ce6a7acc729da9 /include/linux/console.h
parent4b08d9e24f50163a8bda0a702b45b06bf841d792 (diff)
downloadlinux-ad56ebd1d79b216dc147474fac89a11daf6b10df.tar.xz
printk: nbcon: Add sequence handling
Add an atomic_long_t field @nbcon_seq to the console struct to store the sequence number for nbcon consoles. For nbcon consoles this will be used instead of the non-atomic @seq field. The new field allows for safe atomic sequence number updates without requiring any locking. On 64bit systems the new field stores the full sequence number. On 32bit systems the new field stores the lower 32 bits of the sequence number, which are expanded to 64bit as needed by folding the values based on the sequence numbers available in the ringbuffer. For 32bit systems, having a 32bit representation in the console is sufficient. If a console ever gets more than 2^31 records behind the ringbuffer then this is the least of the problems. Co-developed-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Thomas Gleixner (Intel) <tglx@linutronix.de> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20230916192007.608398-7-john.ogness@linutronix.de
Diffstat (limited to 'include/linux/console.h')
-rw-r--r--include/linux/console.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/console.h b/include/linux/console.h
index ca1ef8700e55..20cd486b76ad 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -243,6 +243,7 @@ struct printk_buffers;
* might cause a system freeze when the console
* is used later.
* @pbufs: Pointer to the text buffer for this context
+ * @seq: The sequence number to print for this context
*/
struct nbcon_context {
/* members set by caller */
@@ -253,6 +254,7 @@ struct nbcon_context {
/* members set by acquire */
struct printk_buffers *pbufs;
+ u64 seq;
};
/**
@@ -276,6 +278,7 @@ struct nbcon_context {
* @node: hlist node for the console list
*
* @nbcon_state: State for nbcon consoles
+ * @nbcon_seq: Sequence number of the next record for nbcon to print
* @pbufs: Pointer to nbcon private buffer
*/
struct console {
@@ -299,6 +302,7 @@ struct console {
/* nbcon console specific members */
atomic_t __private nbcon_state;
+ atomic_long_t __private nbcon_seq;
struct printk_buffers *pbufs;
};