mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] locking/rtmutex: Avoid overwriting pi_blocked_on while invoking blk_flush_plug().
@ 2023-04-27 11:19 Sebastian Andrzej Siewior
  2023-04-27 11:19 ` [PATCH v2 1/4] sched/core: Provide sched_rtmutex() and expose sched work helpers Sebastian Andrzej Siewior
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2023-04-27 11:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ben Segall, Boqun Feng, Crystal Wood, Daniel Bristot de Oliveira,
	Dietmar Eggemann, Ingo Molnar, John Stultz, Juri Lelli,
	Mel Gorman, Peter Zijlstra, Steven Rostedt, Thomas Gleixner,
	Valentin Schneider, Vincent Guittot, Waiman Long, Will Deacon

Hi,

Crystal Wood reported that task_struct::pi_blocked_on can be overwritten
by mistake that is:
	rt_mutex_slowlock()
	  - task_blocks_on_rt_mutex()
	    - current->pi_blocked_on = waiter;
	  - rt_mutex_slowlock_block()
	    - schedule() 
	      - sched_submit_work()
	        - blk_flush_plug()
		  - *any* RT sleeping lock used by the plug
		     - rtlock_slowlock_locked()
	               - task_blocks_on_rt_mutex()
		         - current->pi_blocked_on = waiter; <-- XXX

The requirement is
- I/O queued
- lock contention on a sleeping lock (a mutex_t)
- lock contention while flushing queued I/O (in blk_flush_plug(), a
  spin_lock_t on PREEMPT_RT).

Later in review it was pointed out by tglx that any function within
sched_submit_work() is affected so it is not limited to
blk_flush_plug().

This series addresses the problem by
- export sched_submit_work()
- invoke sched_submit_work() if it is clear that the slow path is
  needed.
- invoke schedule_rtmutex() while blocking on lock which contains only
  the schedule loop (without sched_submit_work().

Original report by Crystal
	https://lore.kernel.org/all/4b4ab374d3e24e6ea8df5cadc4297619a6d945af.camel@redhat.com

v1: https://lore.kernel.org/all/20230322162719.wYG1N0hh@linutronix.de

v1…v2:
   - Avoid invoking blk_flush_plug() with DEBUG-enabled
   - Fix also the ww-mutex implementation based on RT-mutex.
   - Export sched_submit_work() and do the whole block before blocking
     not just blk_flush_plug().

Sebastian



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

end of thread, other threads:[~2023-06-16 12:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 11:19 [PATCH v2 0/4] locking/rtmutex: Avoid overwriting pi_blocked_on while invoking blk_flush_plug() Sebastian Andrzej Siewior
2023-04-27 11:19 ` [PATCH v2 1/4] sched/core: Provide sched_rtmutex() and expose sched work helpers Sebastian Andrzej Siewior
2023-05-03 13:20   ` Peter Zijlstra
2023-05-09 22:14     ` Crystal Wood
2023-05-11 13:53       ` Peter Zijlstra
2023-05-10 15:04     ` Sebastian Andrzej Siewior
2023-05-11 13:43       ` Peter Zijlstra
2023-05-25 15:25         ` Sebastian Andrzej Siewior
2023-06-16 12:37           ` Sebastian Andrzej Siewior
2023-04-27 11:19 ` [PATCH v2 2/4] locking/rtmutex: Submit/resume work explicitly before/after blocking Sebastian Andrzej Siewior
2023-04-27 11:19 ` [PATCH v2 3/4] locking/rtmutex: Avoid pointless blk_flush_plug() invocations Sebastian Andrzej Siewior
2023-04-27 11:19 ` [PATCH v2 4/4] locking/rtmutex: Add a lockdep assert to catch potential nested blocking 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

all inboxes | Powered by JetHome®