* [PATCH v5 0/3] pps: improve PREEMPT_RT performance
@ 2026-04-25 17:18 Michael Byczkowski
2026-04-25 17:19 ` [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts Michael Byczkowski
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Michael Byczkowski @ 2026-04-25 17:18 UTC (permalink / raw)
To: Rodolfo Giometti, Andrew Morton; +Cc: linux-kernel
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
<giometti@enneenne.com>
Changes since v3: - Patch 2/3: fixed lost indentation on pps_kc_event()
call (reported by Rodolfo Giometti <giometti@enneenne.com>)
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 <nb@buchwitz.com>)
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 <by@by-online.de>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Tested-by: Michael Byczkowski <by@by-online.de>
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts
2026-04-25 17:18 [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
@ 2026-04-25 17:19 ` Michael Byczkowski
2026-05-22 14:25 ` Sebastian Andrzej Siewior
2026-04-25 17:20 ` [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT Michael Byczkowski
2026-05-16 11:32 ` [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2 siblings, 1 reply; 14+ messages in thread
From: Michael Byczkowski @ 2026-04-25 17:19 UTC (permalink / raw)
To: Rodolfo Giometti, Andrew Morton; +Cc: linux-kernel
On PREEMPT_RT, all IRQ handlers are force-threaded. The current
pps_gpio_irq_handler captures the PPS timestamp via pps_get_ts()
inside the handler, but on RT this runs in thread context — after
a scheduling delay that adds variable latency (jitter) to the
timestamp.
Split the handler into a hardirq primary (pps_gpio_irq_hardirq)
that only captures the timestamp, and a threaded handler
(pps_gpio_irq_thread) that processes the event. With
request_threaded_irq(), the primary handler runs in hardirq context
even on PREEMPT_RT, preserving nanosecond timestamp precision.
On non-RT kernels, request_threaded_irq with an explicit primary
handler behaves identically to the previous request_irq call.
Signed-off-by: Michael Byczkowski <by@by-online.de>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Tested-by: Michael Byczkowski <by@by-online.de>
Tested-by: Calvin Owens <calvin@wbinvd.org>
---
drivers/pps/clients/pps-gpio.c | 37 +++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 935da68610c7..f37398fd6b10 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -35,33 +35,44 @@ struct pps_gpio_device_data {
bool capture_clear;
unsigned int echo_active_ms; /* PPS echo active duration */
unsigned long echo_timeout; /* timer timeout value in jiffies */
+ struct pps_event_time ts; /* timestamp captured in hardirq */
};
/*
* Report the PPS event
*/
-static irqreturn_t pps_gpio_irq_handler(int irq, void *data)
+/*
+ * Primary hardirq handler — runs in hardirq context even on PREEMPT_RT.
+ * Only captures the timestamp; all other work is deferred to the thread.
+ */
+static irqreturn_t pps_gpio_irq_hardirq(int irq, void *data)
{
- const struct pps_gpio_device_data *info;
- struct pps_event_time ts;
- int rising_edge;
+ struct pps_gpio_device_data *info = data;
+
+ pps_get_ts(&info->ts);
- /* Get the time stamp first */
- pps_get_ts(&ts);
+ return IRQ_WAKE_THREAD;
+}
- info = data;
+/*
+ * Threaded handler — processes the PPS event using the timestamp
+ * captured in hardirq context above.
+ */
+static irqreturn_t pps_gpio_irq_thread(int irq, void *data)
+{
+ struct pps_gpio_device_data *info = data;
+ int rising_edge;
- /* Small trick to bypass the check on edge's direction when capture_clear is unset */
rising_edge = info->capture_clear ?
gpiod_get_value(info->gpio_pin) : !info->assert_falling_edge;
if ((rising_edge && !info->assert_falling_edge) ||
(!rising_edge && info->assert_falling_edge))
- pps_event(info->pps, &ts, PPS_CAPTUREASSERT, data);
+ pps_event(info->pps, &info->ts, PPS_CAPTUREASSERT, data);
else if (info->capture_clear &&
((rising_edge && info->assert_falling_edge) ||
(!rising_edge && !info->assert_falling_edge)))
- pps_event(info->pps, &ts, PPS_CAPTURECLEAR, data);
+ pps_event(info->pps, &info->ts, PPS_CAPTURECLEAR, data);
else
dev_warn_ratelimited(&info->pps->dev, "IRQ did not trigger any PPS event\n");
@@ -210,8 +221,10 @@ static int pps_gpio_probe(struct platform_device *pdev)
}
/* register IRQ interrupt handler */
- ret = request_irq(data->irq, pps_gpio_irq_handler,
- get_irqf_trigger_flags(data), data->info.name, data);
+ ret = request_threaded_irq(data->irq,
+ pps_gpio_irq_hardirq, pps_gpio_irq_thread,
+ get_irqf_trigger_flags(data) | IRQF_ONESHOT,
+ data->info.name, data);
if (ret) {
pps_unregister_source(data->pps);
dev_err(dev, "failed to acquire IRQ %d\n", data->irq);
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT
2026-04-25 17:18 [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2026-04-25 17:19 ` [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts Michael Byczkowski
@ 2026-04-25 17:20 ` Michael Byczkowski
2026-04-25 17:21 ` [PATCH v5 3/3] pps: convert pps_kc_hardpps_lock " Michael Byczkowski
2026-05-22 14:33 ` [PATCH v5 2/3] pps: convert pps_device lock " Sebastian Andrzej Siewior
2026-05-16 11:32 ` [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2 siblings, 2 replies; 14+ messages in thread
From: Michael Byczkowski @ 2026-04-25 17:20 UTC (permalink / raw)
To: Rodolfo Giometti, Andrew Morton; +Cc: linux-kernel
On PREEMPT_RT, spinlock_t becomes a sleeping mutex, which allows
pps_event() to be preempted mid-update by other RT threads. This
introduces jitter in the PPS event recording path.
Convert pps_device.lock to raw_spinlock_t so the timestamp and
sequence number updates remain non-preemptible on RT.
Move wake_up_interruptible_all() and kill_fasync() outside the
raw_spinlock critical section, as these acquire sleeping locks
on PREEMPT_RT. The lock now protects only the timestamp, sequence
number, and last_ev updates. This is safe because PPS_FETCH waiters
use wait_event_interruptible_timeout() and will re-check after
waking, and kill_fasync() does not require PPS data to be locked
(thanks to Nikolaus Buchwitz <nb@buchwitz.com> for reporting).
On non-RT kernels, raw_spinlock_t compiles to identical code as
spinlock_t — no behavioral change.
Signed-off-by: Michael Byczkowski <by@by-online.de>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Tested-by: Michael Byczkowski <by@by-online.de>
---
drivers/pps/kapi.c | 18 +++++++++++-------
drivers/pps/pps.c | 16 ++++++++--------
include/linux/pps_kernel.h | 2 +-
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index 1bf0335a1b41..46d9fe8b8ce9 100644
--- a/drivers/pps/kapi.c
+++ b/drivers/pps/kapi.c
@@ -102,7 +102,7 @@ struct pps_device *pps_register_source(struct pps_source_info *info,
pps->info.echo = pps_echo_client_default;
init_waitqueue_head(&pps->queue);
- spin_lock_init(&pps->lock);
+ raw_spin_lock_init(&pps->lock);
/* Create the char device */
err = pps_register_cdev(pps);
@@ -167,7 +167,7 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event,
timespec_to_pps_ktime(&ts_real, ts->ts_real);
- spin_lock_irqsave(&pps->lock, flags);
+ raw_spin_lock_irqsave(&pps->lock, flags);
/* Must call the echo function? */
if ((pps->params.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)))
@@ -206,14 +206,18 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event,
pps_kc_event(pps, ts, event);
- /* Wake up if captured something */
- if (captured) {
+ if (captured)
pps->last_ev++;
- wake_up_interruptible_all(&pps->queue);
+ raw_spin_unlock_irqrestore(&pps->lock, flags);
+
+ /*
+ * Wake up after releasing the lock: wake_up_interruptible_all()
+ * and kill_fasync() acquire sleeping locks on PREEMPT_RT.
+ */
+ if (captured) {
+ wake_up_interruptible_all(&pps->queue);
kill_fasync(&pps->async_queue, SIGIO, POLL_IN);
}
-
- spin_unlock_irqrestore(&pps->lock, flags);
}
EXPORT_SYMBOL(pps_event);
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index c6b8b6478276..ad96425208a1 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -103,12 +103,12 @@ static long pps_cdev_ioctl(struct file *file,
case PPS_GETPARAMS:
dev_dbg(&pps->dev, "PPS_GETPARAMS\n");
- spin_lock_irq(&pps->lock);
+ raw_spin_lock_irq(&pps->lock);
/* Get the current parameters */
params = pps->params;
- spin_unlock_irq(&pps->lock);
+ raw_spin_unlock_irq(&pps->lock);
err = copy_to_user(uarg, ¶ms, sizeof(struct pps_kparams));
if (err)
@@ -139,7 +139,7 @@ static long pps_cdev_ioctl(struct file *file,
return -EINVAL;
}
- spin_lock_irq(&pps->lock);
+ raw_spin_lock_irq(&pps->lock);
/* Save the new parameters */
pps->params = params;
@@ -163,7 +163,7 @@ static long pps_cdev_ioctl(struct file *file,
pps->params.assert_off_tu.flags = 0;
pps->params.clear_off_tu.flags = 0;
- spin_unlock_irq(&pps->lock);
+ raw_spin_unlock_irq(&pps->lock);
break;
@@ -190,7 +190,7 @@ static long pps_cdev_ioctl(struct file *file,
return err;
/* Return the fetched timestamp and save last fetched event */
- spin_lock_irq(&pps->lock);
+ raw_spin_lock_irq(&pps->lock);
pps->last_fetched_ev = pps->last_ev;
@@ -200,7 +200,7 @@ static long pps_cdev_ioctl(struct file *file,
fdata.info.clear_tu = pps->clear_tu;
fdata.info.current_mode = pps->current_mode;
- spin_unlock_irq(&pps->lock);
+ raw_spin_unlock_irq(&pps->lock);
err = copy_to_user(uarg, &fdata, sizeof(struct pps_fdata));
if (err)
@@ -278,7 +278,7 @@ static long pps_cdev_compat_ioctl(struct file *file,
return err;
/* Return the fetched timestamp and save last fetched event */
- spin_lock_irq(&pps->lock);
+ raw_spin_lock_irq(&pps->lock);
pps->last_fetched_ev = pps->last_ev;
@@ -291,7 +291,7 @@ static long pps_cdev_compat_ioctl(struct file *file,
memcpy(&compat.info.clear_tu, &pps->clear_tu,
sizeof(struct pps_ktime_compat));
- spin_unlock_irq(&pps->lock);
+ raw_spin_unlock_irq(&pps->lock);
return copy_to_user(uarg, &compat,
sizeof(struct pps_fdata_compat)) ? -EFAULT : 0;
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
index aab0aebb529e..f2fe504071ed 100644
--- a/include/linux/pps_kernel.h
+++ b/include/linux/pps_kernel.h
@@ -59,7 +59,7 @@ struct pps_device {
void const *lookup_cookie; /* For pps_lookup_dev() only */
struct device dev;
struct fasync_struct *async_queue; /* fasync method */
- spinlock_t lock;
+ raw_spinlock_t lock;
};
/*
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 3/3] pps: convert pps_kc_hardpps_lock to raw_spinlock for PREEMPT_RT
2026-04-25 17:20 ` [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT Michael Byczkowski
@ 2026-04-25 17:21 ` Michael Byczkowski
2026-05-22 14:37 ` Sebastian Andrzej Siewior
2026-05-22 14:33 ` [PATCH v5 2/3] pps: convert pps_device lock " Sebastian Andrzej Siewior
1 sibling, 1 reply; 14+ messages in thread
From: Michael Byczkowski @ 2026-04-25 17:21 UTC (permalink / raw)
To: Rodolfo Giometti, Andrew Morton; +Cc: linux-kernel
Convert pps_kc_hardpps_lock from spinlock_t to raw_spinlock_t. This
lock is held in pps_kc_event() which calls hardpps(). hardpps() takes
tk_core.lock which is already a raw_spinlock — nesting a sleeping lock
(PREEMPT_RT spinlock_t) over a raw_spinlock is invalid.
The locked section only checks a pointer comparison and calls
hardpps(), both of which are non-sleeping.
On non-RT kernels, raw_spinlock_t compiles to identical code as
spinlock_t — no behavioral change.
Signed-off-by: Michael Byczkowski <by@by-online.de>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Tested-by: Michael Byczkowski <by@by-online.de>
Tested-by: Calvin Owens <calvin@wbinvd.org>
---
drivers/pps/kc.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/pps/kc.c b/drivers/pps/kc.c
index fbd23295afd7..9c6c024d5083 100644
--- a/drivers/pps/kc.c
+++ b/drivers/pps/kc.c
@@ -21,7 +21,7 @@
*/
/* state variables to bind kernel consumer */
-static DEFINE_SPINLOCK(pps_kc_hardpps_lock);
+static DEFINE_RAW_SPINLOCK(pps_kc_hardpps_lock);
/* PPS API (RFC 2783): current source and mode for kernel consumer */
static struct pps_device *pps_kc_hardpps_dev; /* unique pointer to device */
static int pps_kc_hardpps_mode; /* mode bits for kernel consumer */
@@ -36,17 +36,17 @@ static int pps_kc_hardpps_mode; /* mode bits for kernel consumer */
int pps_kc_bind(struct pps_device *pps, struct pps_bind_args *bind_args)
{
/* Check if another consumer is already bound */
- spin_lock_irq(&pps_kc_hardpps_lock);
+ raw_spin_lock_irq(&pps_kc_hardpps_lock);
if (bind_args->edge == 0)
if (pps_kc_hardpps_dev == pps) {
pps_kc_hardpps_mode = 0;
pps_kc_hardpps_dev = NULL;
- spin_unlock_irq(&pps_kc_hardpps_lock);
+ raw_spin_unlock_irq(&pps_kc_hardpps_lock);
dev_info(&pps->dev, "unbound kernel"
" consumer\n");
} else {
- spin_unlock_irq(&pps_kc_hardpps_lock);
+ raw_spin_unlock_irq(&pps_kc_hardpps_lock);
dev_err(&pps->dev, "selected kernel consumer"
" is not bound\n");
return -EINVAL;
@@ -56,11 +56,11 @@ int pps_kc_bind(struct pps_device *pps, struct pps_bind_args *bind_args)
pps_kc_hardpps_dev == pps) {
pps_kc_hardpps_mode = bind_args->edge;
pps_kc_hardpps_dev = pps;
- spin_unlock_irq(&pps_kc_hardpps_lock);
+ raw_spin_unlock_irq(&pps_kc_hardpps_lock);
dev_info(&pps->dev, "bound kernel consumer: "
"edge=0x%x\n", bind_args->edge);
} else {
- spin_unlock_irq(&pps_kc_hardpps_lock);
+ raw_spin_unlock_irq(&pps_kc_hardpps_lock);
dev_err(&pps->dev, "another kernel consumer"
" is already bound\n");
return -EINVAL;
@@ -78,15 +78,15 @@ int pps_kc_bind(struct pps_device *pps, struct pps_bind_args *bind_args)
*/
void pps_kc_remove(struct pps_device *pps)
{
- spin_lock_irq(&pps_kc_hardpps_lock);
+ raw_spin_lock_irq(&pps_kc_hardpps_lock);
if (pps == pps_kc_hardpps_dev) {
pps_kc_hardpps_mode = 0;
pps_kc_hardpps_dev = NULL;
- spin_unlock_irq(&pps_kc_hardpps_lock);
+ raw_spin_unlock_irq(&pps_kc_hardpps_lock);
dev_info(&pps->dev, "unbound kernel consumer"
" on device removal\n");
} else
- spin_unlock_irq(&pps_kc_hardpps_lock);
+ raw_spin_unlock_irq(&pps_kc_hardpps_lock);
}
/* pps_kc_event - call hardpps() on PPS event
@@ -102,8 +102,8 @@ void pps_kc_event(struct pps_device *pps, struct pps_event_time *ts,
unsigned long flags;
/* Pass some events to kernel consumer if activated */
- spin_lock_irqsave(&pps_kc_hardpps_lock, flags);
+ raw_spin_lock_irqsave(&pps_kc_hardpps_lock, flags);
if (pps == pps_kc_hardpps_dev && event & pps_kc_hardpps_mode)
hardpps(&ts->ts_real, &ts->ts_raw);
- spin_unlock_irqrestore(&pps_kc_hardpps_lock, flags);
+ raw_spin_unlock_irqrestore(&pps_kc_hardpps_lock, flags);
}
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-04-25 17:18 [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2026-04-25 17:19 ` [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts Michael Byczkowski
2026-04-25 17:20 ` [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT Michael Byczkowski
@ 2026-05-16 11:32 ` Michael Byczkowski
2026-05-19 16:19 ` Calvin Owens
2026-05-22 14:13 ` Sebastian Andrzej Siewior
2 siblings, 2 replies; 14+ messages in thread
From: Michael Byczkowski @ 2026-05-16 11:32 UTC (permalink / raw)
To: Rodolfo Giometti, Andrew Morton; +Cc: linux-kernel, linux-rt-users, bigeasy
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 <by@by-online.de> 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
> <giometti@enneenne.com>
>
> Changes since v3: - Patch 2/3: fixed lost indentation on pps_kc_event()
> call (reported by Rodolfo Giometti <giometti@enneenne.com>)
>
> 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 <nb@buchwitz.com>)
>
> 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 <by@by-online.de>
> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> Tested-by: Michael Byczkowski <by@by-online.de>
>
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-05-16 11:32 ` [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
@ 2026-05-19 16:19 ` Calvin Owens
2026-05-22 15:56 ` Michael Byczkowski
2026-05-22 14:13 ` Sebastian Andrzej Siewior
1 sibling, 1 reply; 14+ messages in thread
From: Calvin Owens @ 2026-05-19 16:19 UTC (permalink / raw)
To: Michael Byczkowski
Cc: Rodolfo Giometti, Andrew Morton, linux-kernel, linux-rt-users, bigeasy
On Saturday 05/16 at 13:32 +0200, Michael Byczkowski wrote:
> > On 25. Apr 2026, at 19:18, Michael Byczkowski <by@by-online.de> wrote:
> >
> > 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 <by@by-online.de>
> > Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> > Tested-by: Michael Byczkowski <by@by-online.de>
> >
> > 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
>
> 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.
Unfortunately apple mail is corrupting your patches :/
Greg KH usually applies patches for drivers/pps/, but I didn't add him
here yet because the patches don't apply.
If you can point me at a git branch for v5, I'd be happy to re-send the
patches myself with your authorship. This is all useful for me and I'd
like to help :)
If you do it yourself, just make sure to add Greg to the Cc: list.
Cheers,
Calvin
> Adding linux-rt-users@ and Sebastian on Cc in case there's interest from the
> PREEMPT_RT side.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-05-16 11:32 ` [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2026-05-19 16:19 ` Calvin Owens
@ 2026-05-22 14:13 ` Sebastian Andrzej Siewior
2026-05-23 17:58 ` Michael Byczkowski
1 sibling, 1 reply; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-05-22 14:13 UTC (permalink / raw)
To: Michael Byczkowski
Cc: Rodolfo Giometti, Andrew Morton, linux-kernel, linux-rt-users
On 2026-05-16 13:32:03 [+0200], Michael Byczkowski wrote:
> 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.
Was there a follow-up to the series?
Sebastian
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts
2026-04-25 17:19 ` [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts Michael Byczkowski
@ 2026-05-22 14:25 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-05-22 14:25 UTC (permalink / raw)
To: Michael Byczkowski; +Cc: Rodolfo Giometti, Andrew Morton, linux-kernel
On 2026-04-25 19:19:19 [+0200], Michael Byczkowski wrote:
> On PREEMPT_RT, all IRQ handlers are force-threaded. The current
> pps_gpio_irq_handler captures the PPS timestamp via pps_get_ts()
> inside the handler, but on RT this runs in thread context — after
> a scheduling delay that adds variable latency (jitter) to the
> timestamp.
>
> Split the handler into a hardirq primary (pps_gpio_irq_hardirq)
> that only captures the timestamp, and a threaded handler
> (pps_gpio_irq_thread) that processes the event. With
> request_threaded_irq(), the primary handler runs in hardirq context
> even on PREEMPT_RT, preserving nanosecond timestamp precision.
>
> On non-RT kernels, request_threaded_irq with an explicit primary
> handler behaves identically to the previous request_irq call.
No sure if this is wrong wording or so. You end up with a primary
handler in hardirq context and a threaded handler. So have both with and
without PREEMPT_RT.
But the change makes sense.
> Signed-off-by: Michael Byczkowski <by@by-online.de>
> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> Tested-by: Michael Byczkowski <by@by-online.de>
> Tested-by: Calvin Owens <calvin@wbinvd.org>
Sebastian
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT
2026-04-25 17:20 ` [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT Michael Byczkowski
2026-04-25 17:21 ` [PATCH v5 3/3] pps: convert pps_kc_hardpps_lock " Michael Byczkowski
@ 2026-05-22 14:33 ` Sebastian Andrzej Siewior
1 sibling, 0 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-05-22 14:33 UTC (permalink / raw)
To: Michael Byczkowski; +Cc: Rodolfo Giometti, Andrew Morton, linux-kernel
On 2026-04-25 19:20:08 [+0200], Michael Byczkowski wrote:
> --- a/drivers/pps/kapi.c
> +++ b/drivers/pps/kapi.c
> @@ -167,7 +167,7 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event,
>
> timespec_to_pps_ktime(&ts_real, ts->ts_real);
>
> - spin_lock_irqsave(&pps->lock, flags);
> + raw_spin_lock_irqsave(&pps->lock, flags);
>
> /* Must call the echo function? */
> if ((pps->params.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)))
> @@ -206,14 +206,18 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event,
>
> pps_kc_event(pps, ts, event);
This acquires a pps_kc_hardpps_lock which is spinlock_t in my tree.
There is also pps_gpio_echo() but this should be all non-blocking.
>
> - /* Wake up if captured something */
> - if (captured) {
> + if (captured)
> pps->last_ev++;
> - wake_up_interruptible_all(&pps->queue);
Sebastian
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 3/3] pps: convert pps_kc_hardpps_lock to raw_spinlock for PREEMPT_RT
2026-04-25 17:21 ` [PATCH v5 3/3] pps: convert pps_kc_hardpps_lock " Michael Byczkowski
@ 2026-05-22 14:37 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 14+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-05-22 14:37 UTC (permalink / raw)
To: Michael Byczkowski; +Cc: Rodolfo Giometti, Andrew Morton, linux-kernel
On 2026-04-25 19:21:14 [+0200], Michael Byczkowski wrote:
> Convert pps_kc_hardpps_lock from spinlock_t to raw_spinlock_t. This
> lock is held in pps_kc_event() which calls hardpps(). hardpps() takes
> tk_core.lock which is already a raw_spinlock — nesting a sleeping lock
> (PREEMPT_RT spinlock_t) over a raw_spinlock is invalid.
>
> The locked section only checks a pointer comparison and calls
> hardpps(), both of which are non-sleeping.
>
> On non-RT kernels, raw_spinlock_t compiles to identical code as
> spinlock_t — no behavioral change.
This looks okay. You need to swap patch #2 and #3 - this needs to come
first.
The bracket placement is terrible in pps_kc_bind(). Maybe if you swap to
guard() it becomes readable as a side effect.
> Signed-off-by: Michael Byczkowski <by@by-online.de>
> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> Tested-by: Michael Byczkowski <by@by-online.de>
> Tested-by: Calvin Owens <calvin@wbinvd.org>
Sebastian
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-05-19 16:19 ` Calvin Owens
@ 2026-05-22 15:56 ` Michael Byczkowski
2026-05-23 17:57 ` Michael Byczkowski
0 siblings, 1 reply; 14+ messages in thread
From: Michael Byczkowski @ 2026-05-22 15:56 UTC (permalink / raw)
To: Calvin Owens
Cc: Rodolfo Giometti, Andrew Morton, linux-kernel, linux-rt-users, bigeasy
Dear Calvin,
Thanks for picking this up, and yes, I’m actually a bit overwhelmed, so your help is much appreciated! And my apologies for the delay, I was traveling.
The clean v5 series is at:
https://github.com/by/linux-PPS/tree/pps-rt-v5-clean
Three commits on top of torvalds 0d9363a764d9 (around v7.0-rc6):
pps: pps-gpio: split IRQ handler into hardirq timestamper + threaded handler pps: convert pps_device.lock to raw_spinlock_t pps: kc: convert pps_kc_hardpps_lock to raw_spinlock_t
Your suspicion about Apple Mail was correct: I diffed the GitHub branch against the lore mbox and the sent version has quoted-printable damage which would explain why nobody could git am it cleanly. The GitHub branch is the ground truth.
Let me know how you'd like to proceed.
Lore thread for context: https://lore.kernel.org/lkml/719A31CE-CA58-45C3-A013-1BFE81F724C5@by-online.de/
Thanks and best regards,
Michael
> On 19. May 2026, at 18:19, Calvin Owens <calvin@wbinvd.org> wrote:
>
> On Saturday 05/16 at 13:32 +0200, Michael Byczkowski wrote:
>>> On 25. Apr 2026, at 19:18, Michael Byczkowski <by@by-online.de> wrote:
>>>
>>> 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 <by@by-online.de>
>>> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
>>> Tested-by: Michael Byczkowski <by@by-online.de>
>>>
>>> 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
>>
>> 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.
>
> Unfortunately apple mail is corrupting your patches :/
>
> Greg KH usually applies patches for drivers/pps/, but I didn't add him
> here yet because the patches don't apply.
>
> If you can point me at a git branch for v5, I'd be happy to re-send the
> patches myself with your authorship. This is all useful for me and I'd
> like to help :)
>
> If you do it yourself, just make sure to add Greg to the Cc: list.
>
> Cheers,
> Calvin
>
>> Adding linux-rt-users@ and Sebastian on Cc in case there's interest from the
>> PREEMPT_RT side.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-05-22 15:56 ` Michael Byczkowski
@ 2026-05-23 17:57 ` Michael Byczkowski
0 siblings, 0 replies; 14+ messages in thread
From: Michael Byczkowski @ 2026-05-23 17:57 UTC (permalink / raw)
To: Calvin Owens
Cc: Rodolfo Giometti, Andrew Morton, linux-kernel, linux-rt-users, bigeasy
Hi Calvin,
Thank you again for offering to relay the series. v6 is ready,
addressing all of Sebastian's review feedback on v5.
Branch: https://github.com/by/linux-PPS/tree/pps-rt-v6
Tip SHA: 013781f19756a4c6ac9c91e83b3a74a52882b707
Base: 0d9363a764d9d601a05591f9695cea8b429e9be3
("Input: xpad - add support for BETOP BTP-KP50B/C
controller's wireless mode")
To regenerate:
git fetch https://github.com/by/linux-PPS.git pps-rt-v6
git format-patch -3 \
--cover-letter \
--thread \
--subject-prefix="PATCH v6" \
--base=0d9363a764d9d601a05591f9695cea8b429e9be3 \
FETCH_HEAD
If easier, I have the four .patch files generated locally and can
attach them on request.
checkpatch.pl is clean on all three patches (0 errors, 0 warnings).
Suggested recipients (per scripts/get_maintainer.pl):
To: Rodolfo Giometti <giometti@enneenne.com>
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Clark Williams <clrkwllms@kernel.org>
Steven Rostedt <rostedt@goodmis.org>
Thomas Gleixner <tglx@linutronix.de>
linux-kernel@vger.kernel.org
linux-rt-devel@lists.linux.dev
Please add yourself with Signed-off-by as the relayer; the patches
preserve my authorship via the From: line inside each patch.
Cover letter content for the 0000 file:
----------------------------------------------------------------
Subject: [PATCH v6 0/3] pps: improve PREEMPT_RT performance
This is v6 of the PPS PREEMPT_RT patchset, addressing the review
feedback from Sebastian Andrzej Siewior on v5.
Changes since v5:
- Reordered: the pps_kc_hardpps_lock conversion now precedes the
pps_device.lock conversion. The previous order would have briefly
produced a raw_spinlock holding a sleeping spinlock on PREEMPT_RT
(Sebastian).
- Patch 1/3: commit message reworded to describe the handler split
structurally first, then its PREEMPT_RT benefit (Sebastian).
- Patch 2/3: refactored pps_kc_bind() and pps_kc_remove() to use
guard(raw_spinlock_irq) for scope-based lock release. Eliminates
four duplicated unlock call sites in pps_kc_bind() and the
ambiguous bracket structure that resulted from them (Sebastian).
- Rodolfo's Acked-by on patch 2/3 is preserved from v5; the guard()
refactor is purely stylistic and was suggested by Sebastian, but
please re-ack or NAK if disagreement.
Changes since v4:
- Patch 2/3: added Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Changes since v3:
- Patch 2/3: fixed lost indentation on pps_kc_event() call
(reported by Rodolfo Giometti <giometti@enneenne.com>)
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 <nb@xxxxxxxxxxxx>)
This patchset addresses three sources of PPS 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_kc_hardpps_lock: spinlock_t becomes a sleeping mutex on
PREEMPT_RT. Since pps_kc_event() calls hardpps() under this lock
and hardpps() takes the raw_spinlock_t tk_core.lock, the nesting
is invalid. Fix: convert to DEFINE_RAW_SPINLOCK.
3. pps_device.lock: same issue as (2), in the PPS event delivery
path. Fix: convert to raw_spinlock_t and move sleeping calls out
of the critical section.
All three patches are tested on a Raspberry Pi 5 running 7.0.1 and
7.1-rc PREEMPT_RT kernels. On non-RT kernels there is zero behavioral
change.
----------------------------------------------------------------
Thank you again. Let me know if you hit anything unexpected.
Best regards,
Michael
> On 22. May 2026, at 17:56, Michael Byczkowski <by@by-online.de> wrote:
>
> Dear Calvin,
>
> Thanks for picking this up, and yes, I’m actually a bit overwhelmed, so your help is much appreciated! And my apologies for the delay, I was traveling.
>
> The clean v5 series is at:
> https://github.com/by/linux-PPS/tree/pps-rt-v5-clean
>
> Three commits on top of torvalds 0d9363a764d9 (around v7.0-rc6):
> pps: pps-gpio: split IRQ handler into hardirq timestamper + threaded handler pps: convert pps_device.lock to raw_spinlock_t pps: kc: convert pps_kc_hardpps_lock to raw_spinlock_t
>
> Your suspicion about Apple Mail was correct: I diffed the GitHub branch against the lore mbox and the sent version has quoted-printable damage which would explain why nobody could git am it cleanly. The GitHub branch is the ground truth.
>
> Let me know how you'd like to proceed.
> Lore thread for context: https://lore.kernel.org/lkml/719A31CE-CA58-45C3-A013-1BFE81F724C5@by-online.de/
>
> Thanks and best regards,
> Michael
>
>
>> On 19. May 2026, at 18:19, Calvin Owens <calvin@wbinvd.org> wrote:
>>
>> On Saturday 05/16 at 13:32 +0200, Michael Byczkowski wrote:
>>>> On 25. Apr 2026, at 19:18, Michael Byczkowski <by@by-online.de> wrote:
>>>>
>>>> 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 <by@by-online.de>
>>>> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
>>>> Tested-by: Michael Byczkowski <by@by-online.de>
>>>>
>>>> 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
>>>
>>> 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.
>>
>> Unfortunately apple mail is corrupting your patches :/
>>
>> Greg KH usually applies patches for drivers/pps/, but I didn't add him
>> here yet because the patches don't apply.
>>
>> If you can point me at a git branch for v5, I'd be happy to re-send the
>> patches myself with your authorship. This is all useful for me and I'd
>> like to help :)
>>
>> If you do it yourself, just make sure to add Greg to the Cc: list.
>>
>> Cheers,
>> Calvin
>>
>>> Adding linux-rt-users@ and Sebastian on Cc in case there's interest from the
>>> PREEMPT_RT side.
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-05-22 14:13 ` Sebastian Andrzej Siewior
@ 2026-05-23 17:58 ` Michael Byczkowski
2026-05-26 18:34 ` Michael Byczkowski
0 siblings, 1 reply; 14+ messages in thread
From: Michael Byczkowski @ 2026-05-23 17:58 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Rodolfo Giometti, Andrew Morton, linux-kernel, linux-rt-users
Hi Sebastian,
Thanks very much for the review.
On 22 May 2026, at 16:13, Sebastian Andrzej Siewior wrote:
> Was there a follow-up to the series?
Yes: v6 is on the way. Calvin Owens kindly offered to relay it for
me (Apple Mail has been corrupting my patches in transit; I'm
addressing that separately), so the v6 series will arrive from him
shortly.
A summary of how I've addressed your v5 comments:
1/3 (pps-gpio handler split): commit message reworded. The new
message describes the split structurally first -- primary hardirq
handler that captures the timestamp, threaded handler that
processes the event -- and then describes the PREEMPT_RT benefit
second (no more scheduling delay between IRQ entry and timestamp
capture). The patch itself is unchanged.
2/3 (pps_kc_hardpps_lock -> raw_spinlock_t): I'd appreciate a quick
clarification here. You wrote that pps_kc_hardpps_lock "is
spinlock_t in my tree". My patch is against mainline at
0d9363a764d9 ("Input: xpad - add support for BETOP BTP-KP50B/C
controller's wireless mode"), where it is still DEFINE_SPINLOCK.
Could you point me at the branch you were looking at, so I can
check whether v6 needs to rebase on top of an existing conversion
in your tree?
Separately: I've also taken your suggestion and refactored
pps_kc_bind() (and pps_kc_remove() while I was in the file) to use
guard(raw_spinlock_irq). That eliminates the four duplicated unlock
call sites in pps_kc_bind() and removes the ambiguous bracket
nesting. Thank you for that pointer.
3/3 (pps_device.lock -> raw_spinlock_t): reordered so this comes
after the kc_hardpps conversion (which now becomes patch 2/3 in
v6), as you noted -- the previous ordering would briefly produce
a raw_spinlock holding a sleeping spinlock on PREEMPT_RT. Thank
you for catching that.
Also: thank you for auditing pps_gpio_echo() on my behalf, much
appreciated.
Best regards,
Michael
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/3] pps: improve PREEMPT_RT performance
2026-05-23 17:58 ` Michael Byczkowski
@ 2026-05-26 18:34 ` Michael Byczkowski
0 siblings, 0 replies; 14+ messages in thread
From: Michael Byczkowski @ 2026-05-26 18:34 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Rodolfo Giometti, Andrew Morton, linux-kernel, linux-rt-users
Hi Sebastian,
Quick update: v7 is on the way, addressing your v5 feedback plus
a separate bug Calvin Owens found in v6 during testing with
CONFIG_DEBUG_ATOMIC_SLEEP.
The new bug: pps_event() in kapi.c was holding pps->lock (now
raw_spinlock_t) across wake_up_interruptible_all() and
kill_fasync(), both of which internally take regular spinlock_t
locks that become rt_mutexes on PREEMPT_RT. This is the same
illegal-nesting pattern Nikolaus Buchwitz caught for the pps_kc
path between v2 and v3 -- I should have audited pps_event() for
the same issue back then and didn't. Patch 3/3 in v7 moves the
unlock above the wakeup calls.
Your v5 feedback is fully addressed:
1/3: commit message reworded to describe the split structurally
first, then the PREEMPT_RT benefit.
2/3: pps_kc_hardpps_lock conversion, now ordered before the
pps_device.lock conversion as you noted. While here, also
refactored pps_kc_bind() and pps_kc_remove() to use
guard(raw_spinlock_irq), eliminating the awkward bracket
placement you flagged.
3/3: pps_device.lock conversion, now with Calvin's wake-up
reordering. Rodolfo's Acked-by is dropped on this patch
since the change is substantive; hoping he'll re-ack.
Calvin is relaying v7 the same way he relayed v6.
Thanks again for the review,
Michael
> On 23. May 2026, at 19:58, Michael Byczkowski <by@by-online.de> wrote:
>
> Hi Sebastian,
>
> Thanks very much for the review.
>
> On 22 May 2026, at 16:13, Sebastian Andrzej Siewior wrote:
>> Was there a follow-up to the series?
>
> Yes: v6 is on the way. Calvin Owens kindly offered to relay it for
> me (Apple Mail has been corrupting my patches in transit; I'm
> addressing that separately), so the v6 series will arrive from him
> shortly.
>
> A summary of how I've addressed your v5 comments:
>
> 1/3 (pps-gpio handler split): commit message reworded. The new
> message describes the split structurally first -- primary hardirq
> handler that captures the timestamp, threaded handler that
> processes the event -- and then describes the PREEMPT_RT benefit
> second (no more scheduling delay between IRQ entry and timestamp
> capture). The patch itself is unchanged.
>
> 2/3 (pps_kc_hardpps_lock -> raw_spinlock_t): I'd appreciate a quick
> clarification here. You wrote that pps_kc_hardpps_lock "is
> spinlock_t in my tree". My patch is against mainline at
> 0d9363a764d9 ("Input: xpad - add support for BETOP BTP-KP50B/C
> controller's wireless mode"), where it is still DEFINE_SPINLOCK.
> Could you point me at the branch you were looking at, so I can
> check whether v6 needs to rebase on top of an existing conversion
> in your tree?
>
> Separately: I've also taken your suggestion and refactored
> pps_kc_bind() (and pps_kc_remove() while I was in the file) to use
> guard(raw_spinlock_irq). That eliminates the four duplicated unlock
> call sites in pps_kc_bind() and removes the ambiguous bracket
> nesting. Thank you for that pointer.
>
> 3/3 (pps_device.lock -> raw_spinlock_t): reordered so this comes
> after the kc_hardpps conversion (which now becomes patch 2/3 in
> v6), as you noted -- the previous ordering would briefly produce
> a raw_spinlock holding a sleeping spinlock on PREEMPT_RT. Thank
> you for catching that.
>
> Also: thank you for auditing pps_gpio_echo() on my behalf, much
> appreciated.
>
> Best regards,
> Michael
>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-05-26 18:35 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-25 17:18 [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2026-04-25 17:19 ` [PATCH v5 1/3] pps: pps-gpio: split IRQ handler into hardirq and threaded parts Michael Byczkowski
2026-05-22 14:25 ` Sebastian Andrzej Siewior
2026-04-25 17:20 ` [PATCH v5 2/3] pps: convert pps_device lock to raw_spinlock for PREEMPT_RT Michael Byczkowski
2026-04-25 17:21 ` [PATCH v5 3/3] pps: convert pps_kc_hardpps_lock " Michael Byczkowski
2026-05-22 14:37 ` Sebastian Andrzej Siewior
2026-05-22 14:33 ` [PATCH v5 2/3] pps: convert pps_device lock " Sebastian Andrzej Siewior
2026-05-16 11:32 ` [PATCH v5 0/3] pps: improve PREEMPT_RT performance Michael Byczkowski
2026-05-19 16:19 ` Calvin Owens
2026-05-22 15:56 ` Michael Byczkowski
2026-05-23 17:57 ` Michael Byczkowski
2026-05-22 14:13 ` Sebastian Andrzej Siewior
2026-05-23 17:58 ` Michael Byczkowski
2026-05-26 18:34 ` Michael Byczkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®