lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220422141446.915024-1-npiggin@gmail.com>
Date:   Sat, 23 Apr 2022 00:14:46 +1000
From:   Nicholas Piggin <npiggin@...il.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     Nicholas Piggin <npiggin@...il.com>,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
        Zhouyi Zhou <zhouzhouyi@...il.com>,
        Frederic Weisbecker <fweisbec@...il.com>,
        Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org,
        Viresh Kumar <viresh.kumar@...aro.org>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Michal Suchánek <msuchanek@...e.de>
Subject: [PATCH] timers/nohz: Low-res tick handler switch to ONESHOT_STOPPED if tick stops

When tick_nohz_stop_tick() stops the tick, the the clock event device
is not put into ONESHOT_STOPPED mode. This can lead to spurious timer
interrupts with some clock event device drivers that don't shut down
entirely after firing.

Eliminate these by putting the device into ONESHOT_STOPPED mode at
points where it is not being reprogrammed. When there are no timers
active, then tick_program_event() with KTIME_MAX can be used to stop the
device. When there is a timer active, the device can be stopped at the
next tick (any new timer added by timers will reprogram the tick).

Signed-off-by: Nicholas Piggin <npiggin@...il.com>
---
 kernel/time/tick-sched.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index d257721c68b8..da1a7efa45a4 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -928,6 +928,8 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
 	if (unlikely(expires == KTIME_MAX)) {
 		if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
 			hrtimer_cancel(&ts->sched_timer);
+		else
+			tick_program_event(KTIME_MAX, 1);
 		return;
 	}
 
@@ -1364,9 +1366,14 @@ static void tick_nohz_handler(struct clock_event_device *dev)
 	tick_sched_do_timer(ts, now);
 	tick_sched_handle(ts, regs);
 
-	/* No need to reprogram if we are running tickless  */
-	if (unlikely(ts->tick_stopped))
+	if (unlikely(ts->tick_stopped)) {
+		/*
+		 * If we are tickless, no need to reprogram, so change the
+		 * clock event device to ONESHOT_STOPPED.
+		 */
+		tick_program_event(KTIME_MAX, 1);
 		return;
+	}
 
 	hrtimer_forward(&ts->sched_timer, now, TICK_NSEC);
 	tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1);
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ