\input{configpres}
\date{2018-10-25}

\section{printk}

\title{Cleaning Up printk()}
\author{John Ogness}

\maketitle

\newcommand\verbbf[1]{\textcolor[rgb]{0,0,0}{\textbf{#1}}}

\subsection{printk: Issues}

\begin{frame}[containsverbatim]
\begin{itemize}
\item global log buffer protected by \verb|raw_spinlock|
\begin{itemize}
\item disables interrupts
\item not NMI safe
\item not recursive safe
\end{itemize}
\item \verb|printk_safe|
\begin{itemize}
\item relies on \verb|irq_work|
\item bogus timestamps
\end{itemize}
\item console drivers
\begin{itemize}
\item slow (serial, video, netconsole)
\item executed by \verb|printk()| caller (possibly atomic)
\end{itemize}
\item INFO handled the same as EMERG
\begin{itemize}
\item \verb|BUG()| is worth the pain, but ''\verb|USB Video Class driver (1.1.1)|''?
\end{itemize}
\item last \verb|printk()| stuck with the bill
\begin{itemize}
\item it is not unbounded but it is a big wildcard
\end{itemize}
\item \verb|oops_in_progress| and \verb|bust_spinlocks()|
\begin{itemize}
\item um, yeah
\end{itemize}
\end{itemize}
\end{frame}

\subsection{printk: Proposal}

\begin{frame}[containsverbatim]
\begin{itemize}
\item new static global lockless multi-reader multi-writer ring buffer
\begin{itemize}
\item interrupts never disabled
\item NMI safe
\item recursive safe
\item available immediately
\item obsoletes \verb|printk_safe| (log directly from \textbf{any} context)
\end{itemize}
\item grab timestamp as first line of \verb|printk()|
\begin{itemize}
\item accurate timestamps
\end{itemize}
\item create a single \verb|printk| kthread to handle printing to all consoles
\begin{itemize}
\item fully preemptible
\item console driver pain goes away
\end{itemize}
\item introduce a \verb|write_atomic()| operation for consoles
\begin{itemize}
\item optional, NMI safe write implementation
\end{itemize}
\item introduce the concept of ''emergency messages''
\begin{itemize}
\item If a message is flagged for emergency and a console implements \verb|write_atomic()|, print the message for that console \textbf{directly}
\item We are already sitting on the CPU! Use it!
\item \verb|write_atomic()| for UART 8250 implemented as an example
\end{itemize}
\item add CPU ID to output to flag and sort messages
\begin{itemize}
\item simultaneous emergency/non-emergency messages
\item simultaneous emergency messages
\end{itemize}
\end{itemize}
\end{frame}

\subsection{printk: Proposal: Issues}

\begin{frame}[containsverbatim]
\begin{itemize}
\item messages printed out of order
\begin{itemize}
\item but timestamps have meaning
\end{itemize}
\item \verb|LOG_CONT| not yet implemented
\begin{itemize}
\item need to decide how best to implement it
\end{itemize}
\item the new ring buffer does not support dynamic resizing
\begin{itemize}
\item not looked into yet
\end{itemize}
\item vmcore data changes
\begin{itemize}
\item userspace ABI changes
\end{itemize}
\end{itemize}
\end{frame}

\subsection{}

\begin{frame}[containsverbatim]
\frametitle{Questions / Comments}
Thank you for your attention!
\vskip30pt
\begin{Verbatim}[commandchars=\\\{\}]


RCPT TO:<john.ogness@linutronix.de>
\end{Verbatim}
\end{frame}

\end{document}
