linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event()
@ 2021-04-13 16:55 Maciej Żenczykowski
  2021-04-13 17:14 ` Greg KH
  0 siblings, 1 reply; 23+ messages in thread
From: Maciej Żenczykowski @ 2021-04-13 16:55 UTC (permalink / raw)
  To: Ingo Molnar, Greg KH, Anna-Maria Behnsen
  Cc: linux-kernel, mikael.beckius, tglx, Lorenzo Colitti,
	Maciej Żenczykowski

This patch (or at least the version of it that showed up in 5.10.24
LTS when combined with Android Common Kernel and some arm phone
platform drivers) causes a roughly 60% regression (from ~5.3-6 gbps
down to ~2.2gbps) on running pktgen when egressing via ncm gadget on a
SuperSpeed+ 10gbps USB3 connection.

The regression is not there in 5.10.23, and is present in 5.10.24 and
5.10.26.  Reverting just this one patch is confirmed to restore
performance (both on 5.10.24 and 5.10.26).

We don't know the cause, as we know nothing about hrtimers... but we
lightly suspect that the ncm->task_timer in f_ncm.c is perhaps not
firing as often as it should...

Unfortunately I have no idea how to replicate this on commonly
available hardware (or with a pure stable or 5.11/5.12 Linus tree)
since it requires a gadget capable usb3.1 10gbps controller (which I
only have access to in combination with a 5.10-based arm+dwc3 soc).

(the regression is visible with just usb3.0, but it's smaller due to
usb3.0 topping out at just under 4gbps, though it still drops to
2.2gbps -- and this still doesn't help since usb3 gadget capable
controllers are nearly as rare)

- Maciej & Lorenzo

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Sv: [PATCH] hrtimer: Interrupt storm on clock_settime
@ 2021-02-12 13:38 Beckius, Mikael
  2021-02-23 16:02 ` [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event() Anna-Maria Behnsen
  0 siblings, 1 reply; 23+ messages in thread
From: Beckius, Mikael @ 2021-02-12 13:38 UTC (permalink / raw)
  To: Thomas Gleixner, linux-kernel; +Cc: Anna-Maria Behnsen

Thanks for the update and sorry for the late reply. After long-term testing of the patch, storm detection improved, it turns out that a similar problem can occur if hrtimer_interrupt runs during clock_settime. In this case it seems the offset can get updated and later read using hrtimer_update_base in hrtimer_interrupt before softirq_expires_next gets updated. As soon as softirq_expires_next gets updated by hrtimer_force_reprogram the storm ends. To fix this I made the below changes.

--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -529,8 +529,10 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
 			if (exclude)
 				continue;
 
-			if (timer->is_soft)
+			if (timer->is_soft) {
 				cpu_base->softirq_next_timer = timer;
+				cpu_base->softirq_expires_next = expires;
+			}
 			else
 				cpu_base->next_timer = timer;
 		}
@@ -633,19 +635,6 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
 	 */
 	expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL);
 
-	if (cpu_base->next_timer && cpu_base->next_timer->is_soft) {
-		/*
-		 * When the softirq is activated, hrtimer has to be
-		 * programmed with the first hard hrtimer because soft
-		 * timer interrupt could occur too late.
-		 */
-		if (cpu_base->softirq_activated)
-			expires_next = __hrtimer_get_next_event(cpu_base,
-								HRTIMER_ACTIVE_HARD);
-		else
-			cpu_base->softirq_expires_next = expires_next;
-	}
-
 	if (skip_equal && expires_next == cpu_base->expires_next)
 		return;
 
--

This is similar to hrtimer_reprogram. I also removed the cpu_base->softirq_activated case since as far as I can tell expires_next must be hard if cpu_base->softirq_activated is true. I might be missing something as I don't have whole picture of the hrtimer subsystem but at least no interrupt storms are detected during clock_settime with latest changes.

Micke

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

end of thread, other threads:[~2021-05-14 19:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 16:55 [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event() Maciej Żenczykowski
2021-04-13 17:14 ` Greg KH
2021-04-14  2:49   ` Lorenzo Colitti
2021-04-15 16:47     ` Thomas Gleixner
2021-04-20  3:12       ` Maciej Żenczykowski
2021-04-20  6:44         ` Thomas Gleixner
2021-04-20  8:15       ` Lorenzo Colitti
2021-04-20 14:19         ` Thomas Gleixner
2021-04-21 14:08           ` Lorenzo Colitti
2021-04-21 14:40             ` Lorenzo Colitti
2021-04-21 15:22               ` Greg KH
2021-04-22  0:08             ` Thomas Gleixner
2021-04-22 10:07               ` Thomas Gleixner
2021-04-22 14:20               ` Lorenzo Colitti
2021-04-22 15:35                 ` Thomas Gleixner
2021-04-26  8:49           ` [PATCH] hrtimer: Avoid double reprogramming in __hrtimer_start_range_ns() Thomas Gleixner
2021-04-26  9:40             ` Peter Zijlstra
2021-04-26 12:25               ` Peter Zijlstra
2021-05-14 19:29                 ` Thomas Gleixner
2021-04-26 12:33               ` Thomas Gleixner
2021-04-26 12:40                 ` Peter Zijlstra
2021-04-26 14:27                   ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2021-02-12 13:38 Sv: [PATCH] hrtimer: Interrupt storm on clock_settime Beckius, Mikael
2021-02-23 16:02 ` [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event() Anna-Maria Behnsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).