Patch "wait: Fix __wait_event_hrtimeout for RT/DL tasks" has been added to the 5.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    wait: Fix __wait_event_hrtimeout for RT/DL tasks

to the 5.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     wait-fix-__wait_event_hrtimeout-for-rt-dl-tasks.patch
and it can be found in the queue-5.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 33d8be9cf2281311b5fa89968c3535501ed804ef
Author: Juri Lelli <juri.lelli@xxxxxxxxxx>
Date:   Mon Jun 27 11:50:51 2022 +0200

    wait: Fix __wait_event_hrtimeout for RT/DL tasks
    
    [ Upstream commit cceeeb6a6d02e7b9a74ddd27a3225013b34174aa ]
    
    Changes to hrtimer mode (potentially made by __hrtimer_init_sleeper on
    PREEMPT_RT) are not visible to hrtimer_start_range_ns, thus not
    accounted for by hrtimer_start_expires call paths. In particular,
    __wait_event_hrtimeout suffers from this problem as we have, for
    example:
    
    fs/aio.c::read_events
      wait_event_interruptible_hrtimeout
        __wait_event_hrtimeout
          hrtimer_init_sleeper_on_stack <- this might "mode |= HRTIMER_MODE_HARD"
                                           on RT if task runs at RT/DL priority
            hrtimer_start_range_ns
              WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard)
              fires since the latter doesn't see the change of mode done by
              init_sleeper
    
    Fix it by making __wait_event_hrtimeout call hrtimer_sleeper_start_expires,
    which is aware of the special RT/DL case, instead of hrtimer_start_range_ns.
    
    Reported-by: Bruno Goncalves <bgoncalv@xxxxxxxxxx>
    Signed-off-by: Juri Lelli <juri.lelli@xxxxxxxxxx>
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Reviewed-by: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
    Reviewed-by: Valentin Schneider <vschneid@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220627095051.42470-1-juri.lelli@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 851e07da2583..58cfbf81447c 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -544,10 +544,11 @@ do {										\
 										\
 	hrtimer_init_sleeper_on_stack(&__t, CLOCK_MONOTONIC,			\
 				      HRTIMER_MODE_REL);			\
-	if ((timeout) != KTIME_MAX)						\
-		hrtimer_start_range_ns(&__t.timer, timeout,			\
-				       current->timer_slack_ns,			\
-				       HRTIMER_MODE_REL);			\
+	if ((timeout) != KTIME_MAX) {						\
+		hrtimer_set_expires_range_ns(&__t.timer, timeout,		\
+					current->timer_slack_ns);		\
+		hrtimer_sleeper_start_expires(&__t, HRTIMER_MODE_REL);		\
+	}									\
 										\
 	__ret = ___wait_event(wq_head, condition, state, 0, 0,			\
 		if (!__t.task) {						\



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux