[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [RFC PATCH] interrupt coalescing
This patch introduces interrupt coalescing. This is done by through introducing two guest configurable parameters: - max_coalesced_buffers: maximum number of pending buffers to be processed before sending a virtqueue interrupt. - coalesced_usecs: maximum number of micro seconds to delay a virtqueue interrupt after a buffer is processed. Only pci part is implemented currently. Signed-off-by: Jason Wang <jasowang@redhat.com> --- content.tex | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- virtio-ring.h | 4 ++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/content.tex b/content.tex index 1efdcc8..9831e73 100644 --- a/content.tex +++ b/content.tex @@ -551,7 +551,8 @@ Otherwise, if the VIRTIO_F_EVENT_IDX feature bit is negotiated: \begin{itemize} \item If the \field{idx} field in the used ring (which determined where that descriptor index was placed) was equal to - \field{used_event}, the device MUST send an interrupt. + \field{used_event} and the interrupt was not coalesced (see \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Coalescing}), + the device MUST send an interrupt. \item Otherwise the device SHOULD NOT send an interrupt. \end{itemize} \end{itemize} @@ -562,6 +563,50 @@ For example, if \field{used_event} is 0, then a device using used (and again after the 65536th buffer, etc). \end{note} +\subsection{Virtqueue Interrupt Coalescing}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Coalescing} + +If the VIRTIO_F_INTR_COALESCING feature bit is negotiated, driver +could use \field{max_coalseced_buffers} and \field{coalseced_usecs} as +hints to device for coalescing several interrupts into a single one. + +The interrupt coalescing method is unreliable, as it was not +synchronized with the device, but it serves as a useful optimization. + +\drivernormative{\subsubsection}{Virtqueue Interrupt Coalescing}{Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Coalescing} + +If the VIRTIO_F_INTR_COALESCING feature bit is negotiated: +\begin{itemize} +\item The driver MAY use \field{max_coalseced_buffers} as a hint to + device for the maximum number of pending buffers to be processed + before sending a virtqueue interrupt. Set value zero to + \field{max_coalesced_buffers} will disable interrupt coalescing in + device. +\item The driver MAY use \field{coalesced_usecs} as a hint to device + for the maxinum number of micro seconds to delay a virtqueue + interrupt after a buffer is processed. Set value zero to + \field{coalesced_usecs} will disable interrupt coalescing in device. +\item The driver MUST set non zero values for both + \field{max_coalesced_buffers} and \field{coalesced_usecs} to enable + interrupt coalescing in device. +\end{itemize} +The driver MUST handle spurious interrupts from the device. + +\devicenormative{\subsubsection}{Virtqueue Interrupt Coalescing}{Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Coalescing} +If the VIRTIO_F_INTR_COALESCING feature bit is negotiated: +\begin{itemize} +\item The device MUST NOT coalesce interrupts when either + \field{max_coalseced_buffers} or \field{coalesced_usecs} is zero. +\item The device SHOULD send a virtqueue interrupt when virtqueue + interrupt is not suppressed (see \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Suppression}) + and one of the following conditions is met since last virtqueue interrupt: + \begin{itemize} + \item The number of processed buffers interrupt exceeds + \field{max_coalesced_buffers}. + \item The number of micro seconds since a buffer has been + processed exceeds \field{coalesced_usecs}. + \end{itemize} +\end{itemize} + \subsection{The Virtqueue Used Ring}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} \begin{lstlisting} @@ -1225,6 +1270,8 @@ struct virtio_pci_common_cfg { le64 queue_desc; /* read-write */ le64 queue_avail; /* read-write */ le64 queue_used; /* read-write */ + le32 max_coalseced_buffers; /* read-write, only if VIRTIO_F_INTR_COALESCING */ + le32 coalesce_usecs; /* read-write, only if VIRTIO_F_INTR_COALESCING */ }; \end{lstlisting} @@ -1291,6 +1338,12 @@ struct virtio_pci_common_cfg { \item[\field{queue_used}] The driver writes the physical address of Used Ring here. See section \ref{sec:Basic Facilities of a Virtio Device / Virtqueues}. + +\item[\field{max_coalesced_buffers}] + The driver writes the maximum coalesced buffers here. See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Coalescing}. + +\item[\field{coalesced_usecs}] + The driver writes the coalesced micro seconds here. See \ref{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Interrupt Coalescing}. \end{description} \devicenormative{\paragraph}{Common configuration structure layout}{Virtio Transport Options / Virtio Over PCI Bus / PCI Device Layout / Common configuration structure layout} diff --git a/virtio-ring.h b/virtio-ring.h index aa01d92..3377a7d 100644 --- a/virtio-ring.h +++ b/virtio-ring.h @@ -59,6 +59,10 @@ /* Arbitrary descriptor layouts. */ #define VIRTIO_F_ANY_LAYOUT 27 +/* Support for interrupt coalescing */ +#define VIRTIO_F_INTR_COALESCING 30 + + /* Virtqueue descriptors: 16 bytes. * These can chain together via "next". */ struct virtq_desc { -- 2.1.4
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]