From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Calvin Owens <calvin@wbinvd.org>
Cc: linux-kernel@vger.kernel.org,
Rodolfo Giometti <giometti@enneenne.com>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Byczkowski <by@by-online.de>,
Eliav Farber <farbere@amazon.com>,
linux-rt-devel@lists.linux.dev,
David Laight <david.laight.linux@gmail.com>
Subject: Re: [PATCH v6 3/3] pps: convert pps_device.lock to raw_spinlock_t
Date: Fri, 29 May 2026 14:57:24 +0200 [thread overview]
Message-ID: <20260529125724.ZaipPjjc@linutronix.de> (raw)
In-Reply-To: <ahmIp6lEjoiy-EDJ@mozart.vkv.me>
On 2026-05-29 05:37:59 [-0700], Calvin Owens wrote:
> > So lets look at the series:
> > - #1 splits the handler to take time stamp in hardirq and the remaining
> > work in the thread. It seems to be crucial to do so because doing so
> > in thread breaks something. Okay. Granted, makes a bit of sense.
> >
> > - #2 ignore for argument's sake
> >
> > - #3 says swap the lock so we can use pps_event() in hardirq context.
>
> I interpreted that as saying "swap the lock so the lock can be safely
> acquired from code running in both hardirq and threaded context".
That is correct. But wake_up_interruptible_all() and kill_fasync() must
not be used in hardirq context.
> But looking more closely, it doesn't seem that either lock is ever
> acquired in hardirq context before or after this series.
>
> So I think patches 2 and 3 are unnecessary.
Okay then.
> As a quick confirmation, I tested only patch 1 on a bona fide pps-gpio
> setup with lockdep and atomic_sleep and saw no splats.
>
> Patch 2 suggests tk_core.lock being a raw lock was somehow a problem,
> but it's never held across anything, it seems fine.
pps_event() does invoke pps_kc_event(). So you need to swap this lock
(pps_kc_hardpps_lock) before swapping pps->lock. And hardpps() itself
already has a raw_spinlock_t so it is fine.
That is my interpretation.
> > Now. Why or where do we need to use pps_event() in hardirq context?
> > If we use pps_event() is used in hardirq context, as claimed in the
> > commit message, then dropping the lock early here does not help and it
> > will lead to the same splat in wake_up_interruptible_all() because
> > interrupts are still disabled independent of the lock here. It is
> > hardirq-context after all.
> >
> > You don't see this warning in your testcase because it gets here from a
> > timer, yes. But. pps_event() can't be used as-is from hardirq context
> > either.
>
> In pps-gpio it's called from pps_gpio_irq_handler() which is threaded.
>
> In pps-ldisc it's called from pps_tty_dcd_change(). That is called from
> uart_handle_dcd_change(), the uart_port lock is a normal spin lock and
> is held over the call, and it calls wake_up_interruptible(), so I think
> that one must be fine (I only looked closely at 8250).
>
> PTP calls it from ptp_clock_event() which itself takes a normal spin
> lock, so if that one wasn't safe people would get a splat already.
>
> In pps-parport it's called from parport_irq(). That is called from
> parport_irq_handler() and mfc3_interrupt() which both look threaded to
> me.
>
> In the testcase the earlier trace was from it's called from
> pps_ktimer_event() which is threaded.
>
> I don't see anywhere pps_event() is called in hardirq context.
Okay. In that case #1 should be sufficient to not delay the taking the
timestamp if the context switch to the threaded interrupt is indeed such
a problem.
Sebastian
next prev parent reply other threads:[~2026-05-29 12:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 19:49 [PATCH v6 0/3] pps: improve PREEMPT_RT performance Calvin Owens
2026-05-25 19:49 ` [PATCH v6 1/3] pps: pps-gpio: split IRQ handler into hardirq timestamper + threaded handler Calvin Owens
2026-05-25 19:49 ` [PATCH v6 2/3] pps: kc: convert pps_kc_hardpps_lock to raw_spinlock_t Calvin Owens
2026-05-25 19:49 ` [PATCH v6 3/3] pps: convert pps_device.lock " Calvin Owens
2026-05-26 17:50 ` Calvin Owens
2026-05-26 18:31 ` Michael Byczkowski
2026-05-30 11:14 ` Michael Byczkowski
2026-05-28 7:49 ` Sebastian Andrzej Siewior
2026-05-28 15:57 ` Calvin Owens
2026-05-29 7:19 ` Sebastian Andrzej Siewior
2026-05-29 12:37 ` Calvin Owens
2026-05-29 12:57 ` Sebastian Andrzej Siewior [this message]
2026-05-30 11:03 ` Michael Byczkowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260529125724.ZaipPjjc@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=by@by-online.de \
--cc=calvin@wbinvd.org \
--cc=clrkwllms@kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=farbere@amazon.com \
--cc=giometti@enneenne.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome