All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH v4 3/8] x86/HPET: move legacy tick IRQ count adjustment
Date: Thu, 22 Jan 2026 12:21:42 +0100	[thread overview]
Message-ID: <aXIIRtrYegADdz2o@Mac.lan> (raw)
In-Reply-To: <cafc144d-5c75-49c1-9231-a854389382dc@suse.com>

On Thu, Jan 22, 2026 at 11:31:52AM +0100, Jan Beulich wrote:
> On 22.01.2026 09:50, Roger Pau Monné wrote:
> > On Mon, Nov 17, 2025 at 03:37:45PM +0100, Jan Beulich wrote:
> >> If already we play with the IRQ count, we should do so only if we actually
> >> "consume" the interrupt; normal timer IRQs should not have any adjustment
> >> done.
> >>
> >> Fixes: 353533232730 ("cpuidle: fix the menu governor to enhance IO performance")
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >> ---
> >> _Why_ we do these adjustments (also elsewhere) I don't really know.
> > 
> > I think I have an idea of what's going on here.  This accounting is
> > used by the idle governor to decide when to go idle.  On Linux (where
> > the code is imported from) the governor took into account the inflight
> > IO request state.  However that's not available to Xen and instead
> > they decided to mimic the tracking of the IO activity by counting
> > interrupts.  I bet then realized the timer interrupt would "skew"
> > those results and make it look like there's IO activity when the
> > system is otherwise mostly idle.
> 
> Hmm, yes, that sounds pretty plausible. Except for one aspect: Why would
> it be I/O that the governor would care about?

This is all hypothetical, I don't know the real reasons.  I think they
aimed to avoid putting the system in deep idle states if there's IO
gong on, regardless of whether the CPU is otherwise idle.  Putting the
system in those deeper idle states would also increase interrupt
latency.

I'm not arguing the initial purpose was correct, just attempting to
make sense of all of this.

> It wants to judge by the
> system being busy, and timer interrupts generally are an indication of
> busyness. Just not broadcast ones. Hence ...
> 
> >> --- a/xen/arch/x86/hpet.c
> >> +++ b/xen/arch/x86/hpet.c
> >> @@ -808,13 +808,13 @@ int hpet_broadcast_is_available(void)
> >>  
> >>  int hpet_legacy_irq_tick(void)
> >>  {
> >> -    this_cpu(irq_count)--;
> > 
> > I think you want to pull this decrease into timer_interrupt() itself,
> > so it does the decrease unconditionally of whether the interrupt is a
> > legacy HPET one or from the PIT?
> 
> ... I think moving to timer_interrupt() would actually be wrong.

Hm, I see.  It's only HPET broadcast we want to avoid accounting for.

> > By gating the decrease on the interrupt having been originated from
> > the HPET you completely avoid the decrease in the PIT case AFAICT.
> > 
> >> -
> >>      if ( !hpet_events ||
> >>           (hpet_events->flags & (HPET_EVT_DISABLE|HPET_EVT_LEGACY)) !=
> >>           HPET_EVT_LEGACY )
> >>          return 0;
> >>  
> >> +    this_cpu(irq_count)--;
> > 
> > Also in hpet_interrupt_handler() we might consider only doing the
> > decrease after we ensure it's not a spurious interrupt?  We don't seem
> > to decrease irq_count for spurious interrupts elsewhere.
> 
> Even a spurious interrupt is only an idle management auxiliary one (i.e.
> really an artifact thereof). It doesn't hint at the system being busy.

Right, I was mislead and somehow assumed the intent was to avoid this
counting for all timer interrupts.  Instead is just the HPET broadcast
that not accounted for.

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.


  reply	other threads:[~2026-01-22 11:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 14:35 [PATCH v4 0/8] x86/HPET: tidying / improvements Jan Beulich
2025-11-17 14:37 ` [PATCH v4 1/8] x86/HPET: avoid indirect call to event handler Jan Beulich
2026-01-21 16:19   ` Roger Pau Monné
2025-11-17 14:37 ` [PATCH v4 2/8] x86/HPET: make another channel flags update atomic Jan Beulich
2026-01-21 17:55   ` Roger Pau Monné
2025-11-17 14:37 ` [PATCH v4 3/8] x86/HPET: move legacy tick IRQ count adjustment Jan Beulich
2026-01-22  8:50   ` Roger Pau Monné
2026-01-22 10:31     ` Jan Beulich
2026-01-22 11:21       ` Roger Pau Monné [this message]
2025-11-17 14:38 ` [PATCH v4 4/8] x86/HPET: reduce hpet_next_event() call sites Jan Beulich
2026-01-22  9:00   ` Roger Pau Monné
2025-11-17 14:39 ` [PATCH v4 5/8] x86/HPET: drop "long timeout" handling from reprogram_hpet_evt_channel() Jan Beulich
2026-01-22  9:03   ` Roger Pau Monné
2026-01-22  9:23     ` Jan Beulich
2025-11-17 14:39 ` [PATCH v4 6/8] x86/HPET: simplify "expire" check a little in reprogram_hpet_evt_channel() Jan Beulich
2026-01-22  9:18   ` Roger Pau Monné
2026-01-22  9:28     ` Jan Beulich
2026-01-22 10:10       ` Roger Pau Monné
2026-01-22 10:15         ` Jan Beulich
2026-01-22 11:30           ` Roger Pau Monné
2026-01-22 12:50             ` Jan Beulich
2025-11-17 14:39 ` [PATCH v4 7/8] x86/HPET: drop .set_affinity hook Jan Beulich
2026-01-22 10:05   ` Roger Pau Monné
2025-11-17 14:40 ` [PATCH v4 8/8] x86/HPET: don't arbitrarily cap delta in reprogram_hpet_evt_channel() Jan Beulich
2026-01-22 10:23   ` Roger Pau Monné
2026-01-22 10:35     ` Jan Beulich
2026-01-22 11:29       ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aXIIRtrYegADdz2o@Mac.lan \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.