From: Thomas Gleixner <tglx@linutronix.de>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Tianyang Zhang <zhangtianyang@loongson.cn>,
corbet@lwn.net, alexs@kernel.org, kernel@xen0n.name,
jiaxun.yang@flygoat.com, gaoliang@loongson.cn,
wangliupu@loongson.cn, lvjianmin@loongson.cn, yijun@loongson.cn,
mhocko@suse.com, akpm@linux-foundation.org,
dianders@chromium.org, maobibo@loongson.cn, xry111@xry111.site,
zhaotianrui@loongson.cn, nathan@kernel.org,
yangtiezhu@loongson.cn, zhoubinbin@loongson.cn,
loongarch@lists.linux.dev, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Huacai Chen <chenhuacai@loongson.cn>
Subject: Re: [PATCH v10 2/2] irqchip/loongarch-avec: Add AVEC irqchip support
Date: Wed, 21 Aug 2024 16:31:32 +0200 [thread overview]
Message-ID: <87cym2hrqz.ffs@tglx> (raw)
In-Reply-To: <CAAhV-H424SB_Ff6y4m4Cb7Cx9eWTLbK08Wycwa803y08qWVoOA@mail.gmail.com>
On Wed, Aug 21 2024 at 21:14, Huacai Chen wrote:
> On Wed, Aug 21, 2024 at 12:29 AM Thomas Gleixner <tglx@linutronix.de> wrote:
>> This patch is doing too many things at once and is absolutely not
>> reviewable.
>>
>> Please split it up into the obvious bits and pieces:
> Splitting may cause another problem: some patches will get upstream
> via the arch tree and others via the irq tree. These dependencies may
> cause build errors in a certain tree. But anyway, we will try our best
> to do this.
That's not a problem at all. The trivial way to solve this is to apply
the architecture changes to the loongarch tree in a separate branch
which is based of some -rcX tag and only contains those dependencies.
That branch is then merged into the main loongarch branch and I can pull
it in to my tree for adding the irqchip changes. No conflicts, no merge
dependencies, nothing.
>> #ifdef CONFIG_IRQ_LOONGARCH_AVEC
>> # define SMP_CLEAR_VECTOR BIT(ACTION_CLEAR_VECTOR)
>> #else
>> # define SMP_CLEAR_VECTOR (0)
>> #endif
>>
>> That way the compiler will optimize out stuff like the
>> SMP_CLEAR_VECTOR handling and you only need the prototype of
>> complete_irq_moving(), but no implementation.
> These macros are not in hot-path, and we have already tried our best
> to avoid using #ifdefs for cpu_has_xxx, so I suggest not introduce a
> new Kconfig option. Moreover, the new option should always be selected
> due to the deep coupling among loongson's irqchips, which makes the
> #ifdefs useless.
They are removed in step 8 again. It's for having a sanely split up and
structured patch series instead of one big lump.
>> > +static void clear_free_vector(struct irq_data *irqd)
>> > +{
>> > + struct avecintc_data *adata = irq_data_get_irq_chip_data(irqd);
>> > + bool managed = irqd_affinity_is_managed(irqd);
>>
>> Don't even try. Your managed support is broken at the allocation side
>> and at several other places.
> I'm a bit confused here, irq_create_affinity_masks() marks some
> interrupts "managed". So if we completely ignore "managed" here, then
> can irq_create_affinity_masks() still work? Or the two has nothing to
> do with each other?
Managed interrupts have the property that the core and irqchip code
guarantees the interrupts to be affinable to the CPU masks which are
handed in to the allocator for them.
So the requirement for architectures which have a limited number of
vectors per CPU (x86, loongarch) is that you have to reserve the managed
vectors right at allocation time.
x86_vector_alloc_irqs()
assign_irq_vector_policy()
if (managed)
reserve_managed_vector()
irq_matrix_reserve_managed(mask)
irq_matrix_reserve_managed() then reserves a vector on all CPUs which
are in the affinity mask.
On activation:
x86_vector_activate()
if (managed)
activate_managed()
assign_managed_vector(mask)
irq_matrix_alloc_managed(mask)
irq_matrix_alloc_managed() then picks an unassigned vector out of the
managed vector space. Similar mechanism when the affinity is set.
Why is this important for x86 (and loongarch)?
Because both have a limited vector space of 256 vectors per CPU, where
some of the vectors might be reserved for exceptions and OS purposes or
the legacy space.
The managed mechanism guarantees at allocation time that the interrupt
will have a reserved vector on all CPUs in the mask. That ensures that
on CPU hotplug the interrupt can be migrated over to a still online CPU
in the mask. If the last CPU goes offline the interrupt is shut down.
You might not yet have run into the situation of vector exhaustion, but
once your number of CPUs gets big enough that is guaranteed to happen.
That's why x86 also uses the concept of reserved (not guaranteed)
regular vectors for non-managed interrupts. x86 uses the spurious vector
for that. That's important because there are enough device drivers out
there which allocate a gazillion of interrupts at probe time, but only
request a few of them.
If you allocate all vectors for them right upfront, then you exhaust
your vector space quickly for no reason. Only when the interrupt is
requested then a usable vector is allocated - or the allocation fails
and request_irq() fails. That's better than exhausting the vector space
for nothing.
The complexity of the x86 allocation/activate/set_affinity mechanisms
is there for a reason and not just because we did not have anything
better to do. :)
Thanks,
tglx
next prev parent reply other threads:[~2024-08-21 14:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 11:26 [PATCH v10 0/2] Loongarch-avec support Tianyang Zhang
2024-08-15 11:26 ` [PATCH v10 1/2] irqchip/loongson-pch-msi: Switch to MSI parent domains Tianyang Zhang
2024-08-15 11:26 ` [PATCH v10 2/2] irqchip/loongarch-avec: Add AVEC irqchip support Tianyang Zhang
2024-08-20 16:29 ` Thomas Gleixner
2024-08-21 1:47 ` Tianyang Zhang
2024-08-21 13:14 ` Huacai Chen
2024-08-21 14:31 ` Thomas Gleixner [this message]
2024-08-22 11:53 ` Huacai Chen
2024-08-22 20:52 ` Thomas Gleixner
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=87cym2hrqz.ffs@tglx \
--to=tglx@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=alexs@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=corbet@lwn.net \
--cc=dianders@chromium.org \
--cc=gaoliang@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=lvjianmin@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=mhocko@suse.com \
--cc=nathan@kernel.org \
--cc=wangliupu@loongson.cn \
--cc=xry111@xry111.site \
--cc=yangtiezhu@loongson.cn \
--cc=yijun@loongson.cn \
--cc=zhangtianyang@loongson.cn \
--cc=zhaotianrui@loongson.cn \
--cc=zhoubinbin@loongson.cn \
/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 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).