From 8da2d4ec14288f4a518244a7a74a43bf5f66a8dd Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 22 Jan 2026 14:11:43 +0100 Subject: [PATCH] x86/HPET: reduce hpet_next_event() call sites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'm surprised gcc doesn't manage to do that: At least in debug builds two call sites exist, just like source code has it. That's not necessary though - by using do/while we can reduce this to a single call site. Then the function will be inlined. While improving code gen, also switch the function's 2nd parameter to unsigned. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- xen/arch/x86/hpet.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c index a096547fe8..44915d9ecb 100644 --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -124,7 +124,7 @@ static inline unsigned long ns2ticks(unsigned long nsec, int shift, return (unsigned long) tmp; } -static int hpet_next_event(unsigned long delta, int timer) +static int hpet_next_event(unsigned long delta, unsigned int timer) { uint32_t cnt, cmp; unsigned long flags; @@ -173,12 +173,10 @@ static int reprogram_hpet_evt_channel( delta = max_t(int64_t, delta, MIN_DELTA_NS); delta = ns2ticks(delta, ch->shift, ch->mult); - ret = hpet_next_event(delta, ch->idx); - while ( ret && force ) - { - delta += delta; + do { ret = hpet_next_event(delta, ch->idx); - } + delta += delta; + } while ( ret && force ); return ret; }