Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance

Michael Byczkowski <[email protected]> Sat, 16 May 2026 13:32:03 +0200
Newsgroups org.kernel.vger.linux-rt-users,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Gentle ping on this series. v4 patches 1/3 and 3/3 carried Rodolfo's Acked-by; v5 addressed the remaining feedback on 2/3. Happy to rework anything or split the series if that helps it move forward.

Adding linux-rt-users@ and Sebastian on Cc in case there's interest from the PREEMPT_RT side.


> On 25. Apr 2026, at 19:18, Michael Byczkowski <[email protected]> wrote:
> 
> Dear Rodolfo, Dear Andrew,
> 
> This is v5 of the PPS PREEMPT_RT patchset, including your
> Acked-by for the  the fixe of the sleeping-in-atomic issue in
> patch 2/3 as well as the lost indentation
> now squashed in.
> 
> Changes since v4b: - corrected typo, corrected email structure
> 
> Changes since v4: - Patch 2/3: added Acked-by: Rodolfo Giometti
> <[email protected]>
> 
> Changes since v3: - Patch 2/3: fixed lost indentation on pps_kc_event()
> call (reported by Rodolfo Giometti <[email protected]>)
> 
> Changes since v2: - Patch 2/3: moved wake_up_interruptible_all() and 
> kill_fasync() out of raw_spinlock section to avoid sleeping-in-atomic on
> PREEMPT_RT (reported by Nikolaus Buchwitz)
> 
> Changes since v2:
> - Patch 2/3: moved wake_up_interruptible_all() and kill_fasync() out
> of raw_spinlock section to avoid sleeping-in-atomic on PREEMPT_RT
> (reported by Nikolaus Buchwitz <[email protected]>)
> 
> Andrew Morton pointed me your way as PPS maintainer. I'm running a
> precision NTP time server on a Raspberry Pi 5 with a PREEMPT_RT kernel
> and a u-blox ZED-F9P GPS receiver providing PPS via GPIO.
> 
> I found three issues in the PPS subsystem that cause unnecessary jitter
> under PREEMPT_RT, while being fully backward-compatible with non-RT
> kernels:
> 
> 1. pps-gpio: The IRQ handler is force-threaded on PREEMPT_RT, so the
> PPS timestamp is captured after scheduling delay rather than at
> interrupt entry. Fix: split into a hardirq primary handler (captures
> timestamp only) and a threaded handler (processes the event).
> 
> 2. pps_device.lock: spinlock_t becomes a sleeping mutex on PREEMPT_RT,
> allowing pps_event() to be preempted mid-update. Fix: convert to
> raw_spinlock_t and move sleeping calls out of the critical section.
> 
> 3. pps_kc_hardpps_lock: Same issue as (2), in the kernel consumer path
> that calls hardpps(). Fix: convert to DEFINE_RAW_SPINLOCK.
> 
> All three patches are tested on a Raspberry Pi 5 running a 7.0.0-rc6
> PREEMPT_RT kernel. On non-RT kernels there is zero behavioral change.
> 
> Signed-off-by: Michael Byczkowski <[email protected]>
> Acked-by: Rodolfo Giometti <[email protected]>
> Tested-by: Michael Byczkowski <[email protected]>
> 
> by (3):
> pps: pps-gpio: split IRQ handler into hardirq and threaded parts
> pps: convert pps_device lock to raw_spinlock for PREEMPT_RT
> pps: convert pps_kc_hardpps_lock to raw_spinlock for PREEMPT_RT
> 
> drivers/pps/clients/pps-gpio.c | 37 +++++++++++++++++++++++-----------
> drivers/pps/kapi.c             | 18 ++++++++++-------
> drivers/pps/kc.c               | 22 ++++++++++----------
> drivers/pps/pps.c              | 16 +++++++--------
> include/linux/pps_kernel.h     |  2 +-
> 5 files changed, 56 insertions(+), 39 deletions(-)
> 
> -- 
> 2.47.3