public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] Allow to preempt a timer softirq on PREEMPT_RT.
@ 2023-08-04 11:30 Sebastian Andrzej Siewior
  2023-08-04 11:30 ` [RFC PATCH 1/3] sched/core: Provide a method to check if a task is PI-boosted Sebastian Andrzej Siewior
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2023-08-04 11:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ben Segall, Daniel Bristot de Oliveira, Dietmar Eggemann,
	Frederic Weisbecker, Ingo Molnar, John Stultz, Juri Lelli,
	Mel Gorman, Peter Zijlstra, Stephen Boyd, Steven Rostedt,
	Thomas Gleixner, Valentin Schneider, Vincent Guittot

Hi,

while the softirqs are served, bottom halves are disabled. By disabling
bottom halves (as per local_bh_disable()) PREEMPT_RT acquires a
local_lock_t. This lock ensures that the softirq is synchronized against
other softirq user on that CPU while keeping the context preemptible.

This leads to a scenario where context itself is preemptible but needs
to "complete" before the system can make progress. For instance, the
timer callback (in TIMER_SOFTIRQ) gets preempted because a
force-threaded interrupt thread, with higher priority, gets woken up.
Before the handler of the forced-threaded interrupt can be invoked,
bottom halves get disabled and this blocks on the same per-CPU lock.
This in turn leads to a PI-boost and the preempted timer softirq is back
on the CPU with higher priority completing its job (not just the timer,
all pending softirqs).

In the end the force threaded interrupt is blocked until all pending
softirqs have been served.

The PI-boost is usually intended to allow the thread with lower priority
to "quickly" finish what it was doing and leave the critical section
ASAP. This is not the case with softirqs and how this is handled by the
individual callbacks. Additionally the need_resched() check in
__do_softirq() is never true due to the boost. This means in worst case
this can run for MAX_SOFTIRQ_TIME or MAX_SOFTIRQ_RESTART.

One way of out would be to add preemption within the softirq handling at
which point the softirq-BKL can be dropped. This can be after all
softirqs have been served (__do_softirq() where the need_resched() check
is located), after each softirq handler or within the softirq handler
where it is considered safe to do so.

This series adds as an example such a preemption point to the timer
softirq handler. Should this fly then it would be needed the remaining
handlers as well.

Sebastian



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-03  7:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 11:30 [RFC PATCH 0/3] Allow to preempt a timer softirq on PREEMPT_RT Sebastian Andrzej Siewior
2023-08-04 11:30 ` [RFC PATCH 1/3] sched/core: Provide a method to check if a task is PI-boosted Sebastian Andrzej Siewior
2023-11-02  9:30   ` Juri Lelli
2023-11-02 16:03     ` Sebastian Andrzej Siewior
2023-11-03  7:11       ` Juri Lelli
2023-08-04 11:30 ` [RFC PATCH 2/3] softirq: Add function to preempt serving softirqs Sebastian Andrzej Siewior
2023-08-04 11:30 ` [RFC PATCH 3/3] time: Allow to preempt after a callback Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox