From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Romain Caritey" <Romain.Caritey@microchip.com>,
"Baptiste Le Duc" <baptiste.le-duc@vates.tech>,
"Zheng Zhang" <zhangzheng@iscas.ac.cn>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Connor Davis" <connojdavis@gmail.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger@xenproject.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Daniel P. Smith" <dpsmith@apertussolutions.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v8 16/20] xen/riscv: implement IRQ routing for device passthrough
Date: Fri, 4 Sep 2026 12:58:31 +0200 [thread overview]
Message-ID: <6e807532-4cd5-410f-b073-99b58a40733e@gmail.com> (raw)
In-Reply-To: <ffa2c0cb-52ed-421b-8c4e-9b61edd43f6f@gmail.com>
On 9/3/26 4:39 PM, Oleksii Kurochko wrote:
>>> + do { smp_rmb(); } while ( test_bit(_IRQ_INPROGRESS, &desc-
>>> >status) );
>
> I am thinking if a barrier is in correct place or needed at all.
>
> Considering that desc->status is updated under spinlock() which uses
> full barrier the result here should be already observable without
> smp_rmb() inside do {} while ().
>
> Probably we want to have load->load between test_bit() and a read of
> action->free_on_release in if () below but I don't see what could go
> wrong if this read will happen before do {} while ().
>
> xvfree() (stores inside it) can't be executed ealier because of control
> dependency [Rule 11: b (xfree) is a (action->free_on_release) store, and
> b has a syntactic control dependency on a] so again it looks like a
> barrier isn't needed here.
>
> So considering what kind of barrier is used inside spinlock + Rule 11 we
> can just move smp_rmb() after the cycle (just in case) and it looks like
> smp_rmb() is only here just to force compiler not to order the things
> considering how action->free_on_release is used:
>
> static void irq_release_action(const struct irq_desc *desc,
> struct irqaction *action)
> {
> /*
> * Wait to make sure it's not being used on another CPU.
> *
> * desc->status is cleared in do_IRQ() under desc->lock, whose
> * acquire/release barriers are a full smp_mb() on this arch, so the
> * handler's writes are already ordered before the clear is visible.
> * On this side, xvfree() is control-dependent on the final test_bit()
> * load, so Rule 11 (RVWMO) already orders it after the wait with no
> * barrier. smp_rmb() below adds real read->read ordering, but nothing
> * after the loop depends on it (action->free_on_release isn't racy);
> * it's kept as a guard against the compiler breaking the control
> * dependency the ordering actually relies on.
> */
> while ( test_bit(_IRQ_INPROGRESS, &desc->status) )
> cpu_relax();
> smp_rmb();
>
> if ( action->free_on_release )
> xvfree(action);
>
> Am I missing something?
It could be option just to skip smp_rmb() here at all:
/*
* Wait for a handler still running on another CPU to complete:
do_IRQ()
* clears IRQ_INPROGRESS only after the handler has returned.
*
* No barrier is needed here: nothing below reads data written by the
* handler (action->free_on_release is set up once, before the
action is
* ever registered), and the stores done by xvfree() are ordered after
* the loop's load of desc->status by the control dependency alone
* (RVWMO ppo rule 11).
*/
while ( test_bit(_IRQ_INPROGRESS, &desc->status) )
cpu_relax();
if ( action->free_on_release )
xvfree(action);
But probably just to be sure that if ->free_on_release will one day
somewhere else set except the mentioned case it makes sense to have
smp_rmb() or even smp_mb() (depsite of the fact smp_rmb() looks more
then enough).
Does it make sense?
>
>>
>> Please split this across three lines, to conform to style. (Also same nit
>> as above.)
>>
>>> + if ( action->free_on_release )
>>> + xvfree(action);
next prev parent reply other threads:[~2026-09-04 10:58 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 15:18 [PATCH v8 00/20] Introduce enablemenant of dom0less Oleksii Kurochko
2026-08-27 15:18 ` [PATCH v8 01/20] xen: introduce CONFIG_HAS_SHARED_INFO for archs without a shared page Oleksii Kurochko
2026-08-27 15:18 ` [PATCH v8 02/20] xen/dom0less: turn max_init_domid into a common variable Oleksii Kurochko
2026-08-31 15:48 ` Orzel, Michal
2026-09-01 6:54 ` Jan Beulich
2026-09-01 7:14 ` Orzel, Michal
2026-09-01 7:26 ` Jan Beulich
2026-09-02 9:59 ` Oleksii Kurochko
2026-08-27 15:18 ` [PATCH v8 03/20] xen/riscv: Implement construct_domain() Oleksii Kurochko
2026-08-27 15:18 ` [PATCH v8 04/20] xen/riscv: introduce guest riscv,isa string Oleksii Kurochko
2026-09-02 14:58 ` Jan Beulich
2026-09-03 7:27 ` Oleksii Kurochko
2026-09-03 7:33 ` Jan Beulich
2026-08-27 15:18 ` [PATCH v8 05/20] xen/riscv: implement make_cpus_node() Oleksii Kurochko
2026-08-27 15:18 ` [PATCH v8 06/20] xen/riscv: implement make_timer_node() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 07/20] xen/riscv: implement make_arch_nodes() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 08/20] xen/riscv: introduce init interrupt controller operations Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 09/20] xen/riscv: implement make_intc_domU_node() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 10/20] xen/riscv: introduce aia_init() and aia_usable() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 11/20] xen/riscv: introduce per-vCPU IMSIC state Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 12/20] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 13/20] xen/riscv: introduce (de)initialization helpers for vINTC Oleksii Kurochko
2026-09-03 9:20 ` Jan Beulich
2026-09-03 10:49 ` Oleksii Kurochko
2026-09-03 11:16 ` Jan Beulich
2026-08-27 15:19 ` [PATCH v8 14/20] xen/riscv: generate IMSIC DT node for guest domains Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 15/20] xen/riscv: create APLIC " Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 16/20] xen/riscv: implement IRQ routing for device passthrough Oleksii Kurochko
2026-09-03 10:00 ` Jan Beulich
2026-09-03 14:39 ` Oleksii Kurochko
2026-09-04 10:58 ` Oleksii Kurochko [this message]
2026-08-27 15:19 ` [PATCH v8 17/20] xen/riscv: implement init_intc_phandle() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 18/20] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 19/20] xen/riscv: provide init_vuart() Oleksii Kurochko
2026-08-27 15:19 ` [PATCH v8 20/20] xen/riscv: add initial dom0less infrastructure support 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=6e807532-4cd5-410f-b073-99b58a40733e@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=Romain.Caritey@microchip.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=baptiste.le-duc@vates.tech \
--cc=connojdavis@gmail.com \
--cc=dpsmith@apertussolutions.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=zhangzheng@iscas.ac.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 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.