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>,
Oleksii Kurochko <oleksii.kurochko@gmail.com>
Subject: Re: [PATCH for-4.21 03/10] x86/HPET: use single, global, low-priority vector for broadcast IRQ
Date: Tue, 21 Oct 2025 09:37:13 +0100 [thread overview]
Message-ID: <aPdGOSXPvrRH3SOM@Mac.lan> (raw)
In-Reply-To: <c27a671f-0001-4c32-9fb5-41b19a3f0a49@suse.com>
On Mon, Oct 20, 2025 at 06:05:04PM +0200, Jan Beulich wrote:
> On 20.10.2025 17:49, Roger Pau Monné wrote:
> > On Mon, Oct 20, 2025 at 07:53:51AM +0200, Jan Beulich wrote:
> >> On 17.10.2025 10:20, Roger Pau Monné wrote:
> >>> On Fri, Oct 17, 2025 at 09:15:08AM +0200, Jan Beulich wrote:
> >>>> On 16.10.2025 18:27, Roger Pau Monné wrote:
> >>>>> On Thu, Oct 16, 2025 at 09:32:04AM +0200, Jan Beulich wrote:
> >>>>>> @@ -497,6 +503,7 @@ static void set_channel_irq_affinity(str
> >>>>>> spin_lock(&desc->lock);
> >>>>>> hpet_msi_mask(desc);
> >>>>>> hpet_msi_set_affinity(desc, cpumask_of(ch->cpu));
> >>>>>> + per_cpu(vector_irq, ch->cpu)[HPET_BROADCAST_VECTOR] = ch->msi.irq;
> >>>>>
> >>>>> I would set the vector table ahead of setting the affinity, in case we
> >>>>> can drop the mask calls around this block of code.
> >>>>
> >>>> Isn't there a problematic window either way round? I can make the change,
> >>>> but I don't see that addressing anything. The new comparator value will
> >>>> be written later anyway, and interrupts up to that point aren't of any
> >>>> interest anyway. I.e. it doesn't matter which of the CPUs gets to handle
> >>>> them.
> >>>
> >>> It's preferable to get a silent stray interrupt (if the per-cpu vector
> >>> table is correctly setup), rather than to get a message from Xen that
> >>> an unknown vector has been received?
> >>>
> >>> If a vector is injected ahead of vector_irq being set Xen would
> >>> complain in do_IRQ() that that's no handler for such vector.
> >>
> >> As of now, setup_vector_irq() makes sure the field isn't uninitialized
> >> (i.e. left at INT_MIN). With that change dropped (see below), there
> >> would indeed be such a risk (on the first instance on each CPU).
> >>
> >>>>>> --- a/xen/arch/x86/irq.c
> >>>>>> +++ b/xen/arch/x86/irq.c
> >>>>>> @@ -755,8 +755,9 @@ void setup_vector_irq(unsigned int cpu)
> >>>>>> if ( !irq_desc_initialized(desc) )
> >>>>>> continue;
> >>>>>> vector = irq_to_vector(irq);
> >>>>>> - if ( vector >= FIRST_HIPRIORITY_VECTOR &&
> >>>>>> - vector <= LAST_HIPRIORITY_VECTOR )
> >>>>>> + if ( vector <= (vector >= FIRST_HIPRIORITY_VECTOR
> >>>>>> + ? LAST_HIPRIORITY_VECTOR
> >>>>>> + : LAST_LOPRIORITY_VECTOR) )
> >>>>>> cpumask_set_cpu(cpu, desc->arch.cpu_mask);
> >>>>>
> >>>>> I think this is wrong. The low priority vector used by the HPET will
> >>>>> only target a single CPU at a time, and hence adding extra CPUs to
> >>>>> that mask as part of AP bringup is not correct.
> >>>>
> >>>> I'm not sure about "wrong". It's not strictly necessary for the HPET one,
> >>>> I expect, but it's generally what would be necessary. For the HPET one,
> >>>> hpet_msi_set_affinity() replaces the value anyway. (I can add a sentence
> >>>> to this effect to the description, if that helps.)
> >>>
> >>> I do think it's wrong, it's just not harmful per-se apart from showing
> >>> up in the output of dump_irqs(). The value in desc->arch.cpu_mask
> >>> should be the CPU that's the destination of the interrupt. In this
> >>> case, the HPET interrupt does have a single destination at a give
> >>> time, and adding another one will make the output of dump_irqs() show
> >>> two destinations, when the interrupt will target a single interrupt.
> >>
> >> Just that as soon as the interrupt is actually in use, what is done
> >> here doesn't matter anymore.
> >>
> >> I continue to think the change is correct for the general case: I'd
> >> expect these special vectors to normally (just not here) be used as
> >> "direct APIC vectors", in which case the IRQ does have multiple
> >> destinations.
> >
> > I think it depends on the usage of the vector. There are indeed
> > vectors that are active on all CPUs at the same time (like the current
> > hi priority ones). However in the case of the HPET vector that's not
> > the case, it targets a single CPU specifically.
> >
> > I think it would be best if vectors that are used on all CPUs at the
> > same time are initialized using cpumask_all or cpumask_setall(), and
> > avoid having to add a new bit every time a CPU is started. It's fine
> > for cpu_mask to contain offline CPUs.
>
> I don't think so. There may be less dependencies now, but look at e.g.
> the check in _bind_irq_vector(). Or this loop
>
> for_each_cpu(cpu, desc->arch.cpu_mask)
> per_cpu(vector_irq, cpu)[desc->arch.vector] = irq;
>
> in _assign_irq_vector() (that may be fine because of how the mask is
> set just before the loop, but the loop itself very much assumes no
> offline CPUs in there). The most problematic example may be in
> fixup_irqs(), where cpumask_any(desc->arch.cpu_mask) is used.
Then it looks like the comment ahead of the field declaration in irq.h
is wrong:
/*
* Except for high priority interrupts @cpu_mask may have bits set for
* offline CPUs. Consumers need to be careful to mask this down to
* online ones as necessary. There is supposed to always be a non-
* empty intersection with cpu_online_map.
*/
I realize now the comment says "Except for high priority", but we
don't seem to make a such differentiation in most of the code (like
fixup_irqs()).
Hopefully this will be way more simple if I can get rid of the
cpumasks in arch_irq_desc.
Thanks, Roger.
next prev parent reply other threads:[~2025-10-21 8:37 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 7:30 [PATCH for-4.21 00/10] x86/HPET: broadcast IRQ and other improvements Jan Beulich
2025-10-16 7:31 ` [PATCH for-4.21 01/10] x86/HPET: limit channel changes Jan Beulich
2025-10-16 10:24 ` Roger Pau Monné
2025-10-16 11:47 ` Jan Beulich
2025-10-16 15:07 ` Roger Pau Monné
2025-10-16 15:16 ` Jan Beulich
2025-10-16 15:25 ` Roger Pau Monné
2025-10-17 9:23 ` Roger Pau Monné
2025-10-17 9:55 ` Jan Beulich
2025-10-16 7:31 ` [PATCH for-4.21 02/10] x86/HPET: disable unused channels Jan Beulich
2025-10-16 11:42 ` Roger Pau Monné
2025-10-16 11:57 ` Jan Beulich
2025-10-16 15:34 ` Roger Pau Monné
2025-10-16 15:55 ` Jan Beulich
2025-10-16 16:28 ` Roger Pau Monné
2025-10-16 16:31 ` Roger Pau Monné
2025-10-17 6:08 ` Jan Beulich
2025-10-17 6:10 ` Jan Beulich
2025-10-16 7:32 ` [PATCH for-4.21 03/10] x86/HPET: use single, global, low-priority vector for broadcast IRQ Jan Beulich
2025-10-16 16:27 ` Roger Pau Monné
2025-10-17 7:15 ` Jan Beulich
2025-10-17 8:20 ` Roger Pau Monné
2025-10-20 5:53 ` Jan Beulich
2025-10-20 15:49 ` Roger Pau Monné
2025-10-20 16:05 ` Jan Beulich
2025-10-21 8:37 ` Roger Pau Monné [this message]
2025-10-16 17:01 ` Andrew Cooper
2025-10-17 6:23 ` Jan Beulich
2025-10-16 7:32 ` [PATCH for-4.21 04/10] x86/HPET: ignore "stale" IRQs Jan Beulich
2025-10-17 9:19 ` Roger Pau Monné
2025-10-17 9:57 ` Jan Beulich
2025-10-17 12:13 ` Roger Pau Monné
2025-10-16 7:32 ` [PATCH 05/10] x86/HPET: avoid indirect call to event handler Jan Beulich
2025-10-16 7:33 ` [PATCH 06/10] x86/HPET: make another channel flags update atomic Jan Beulich
2025-10-16 7:33 ` [PATCH 07/10] x86/HPET: move legacy tick IRQ count adjustment Jan Beulich
2025-10-16 7:34 ` [PATCH 08/10] x86/HPET: shrink IRQ-descriptor locked region in set_channel_irq_affinity() Jan Beulich
2025-10-16 7:34 ` [PATCH 09/10] x86/HPET: reduce hpet_next_event() call sites Jan Beulich
2025-10-16 7:35 ` [PATCH 10/10] x86/HPET: don't use hardcoded 0 for "long timeout" Jan Beulich
2025-10-16 10:05 ` [PATCH for-4.21 00/10] x86/HPET: broadcast IRQ and other improvements Roger Pau Monné
2025-10-16 10:41 ` Jan Beulich
2025-10-17 16:03 ` Oleksii Kurochko
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=aPdGOSXPvrRH3SOM@Mac.lan \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=oleksii.kurochko@gmail.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.