[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251021083721.703242-1-jackzxcui1989@163.com>
Date: Tue, 21 Oct 2025 16:37:21 +0800
From: Xin Zhao <jackzxcui1989@....com>
To: gregkh@...uxfoundation.org,
jirislaby@...nel.org
Cc: linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org,
tj@...nel.org,
hch@...radead.org,
Xin Zhao <jackzxcui1989@....com>
Subject: [PATCH v1 0/2] serial: 8250_dma: dma rx work optimize
On the embedded platform, certain critical data, such as IMU data, is
transmitted through UART. The tty_flip_buffer_push interface in the TTY
layer uses system_unbound_wq to handle the flipping of the TTY buffer.
Although the unbound workqueue can create new threads on demand and wake
up the kworker thread on an idle CPU, the priority of the kworker thread
itself is not high. Even if the CPU running this work was idle just a
moment ago, it may be preempted by real-time tasks or other high-priority
tasks.
In our system, the processing interval for each frame of IMU data
transmitted via UART can experience significant jitter due to this issue.
Instead of the expected 10 to 15 ms frame processing interval, we see
spikes up to 30 to 35 ms. Moreover, in just one or two hours, there can
be 2 to 3 occurrences of such high jitter, which is quite frequent. This
jitter exceeds the software's tolerable limit of 20 ms.
Add tty_flip_buffer_push_wq interface to queue work on specific workqueue
and specific cpu. Add module param tty_flip_cpu to queue rx complete work
on the specific cpu by tty_flip_buffer_push_wq. The default value of
tty_flip_cpu is WORK_CPU_UNBOUND which means using the default
system_unbound_wq called by tty_flip_buffer_push, otherwise we use the
newly added workqueue wq_tty_flip which is set to WQ_HIGHPRI to promote
performance.
We set tty_flip_cpu to a specific CPU core that has relatively few
real-time tasks running continuously for long periods. Additionally,
tasks on this core have some correlation with the UART data related to
the 8250 DMA operation. After queuing work to this designated CPU and
set workqueue to WQ_HIGHPRI, we can stably eliminate the jitter and
ensure that the frame processing interval remains between 10 and 15 ms.
Xin Zhao (2):
tty: tty_buffer: add interface to queue work on specific wq and cpu
serial: 8250_dma: add parameter to queue work on specific cpu
drivers/tty/serial/8250/8250.h | 2 ++
drivers/tty/serial/8250/8250_dma.c | 46 ++++++++++++++++++++++++++++--
drivers/tty/tty_buffer.c | 23 +++++++++++++++
include/linux/tty_flip.h | 3 ++
4 files changed, 72 insertions(+), 2 deletions(-)
--
2.34.1
Powered by blists - more mailing lists