From: Paolo Bonzini <pbonzini@redhat.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
Junjie Mao <junjie.mao@hotmail.com>,
qemu-rust@nongnu.org
Subject: Re: [PATCH 1/2] rust: add BQL-enforcing Cell variant
Date: Wed, 27 Nov 2024 09:31:28 +0100 [thread overview]
Message-ID: <CABgObfZXWKZ8hhH4FmZjZg+9VkSh1+DXPzDs0sMzFyd+yaTuTA@mail.gmail.com> (raw)
In-Reply-To: <Z0a9uPLxrGyVJJwB@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2589 bytes --]
Il mer 27 nov 2024, 07:17 Zhao Liu <zhao1.liu@intel.com> ha scritto:
> > and a single "regs: BqlRefCell<PL011Registers>" in PL011State.
>
> Here I have a possibly common question about the choice of BqlCell and
> future BqlRefCell. Pls refer my comment below...
>
> I understand we need BqlRefCell instead of BqlCell for registers since
> there may be more than one reference, e.g., callbacks from CharBackend
> and MemoryRegion may hold multiple references at the same time, right?
>
> If right, like HPET, with only MemoryRegion callbacks, reads and writes
> I guess which should not be able to happen at the same time, so BqlCell
> is also feasible, as is Irq?
>
Choose between BqlCell/BqlRefCell like you would choose between
Cell/RefCell. They result in different code so pick what looks better.
That said for HPET you have the array of timers structs, and these structs
are not Copy, and therefore BqlRefCell is almost the only choice for that
array. With BqlRefCell used for the timers you might as well put the other
registers in the same BqlRefCell.
(This piece of the thread model is a bit more complex, and I'm fully
> aware that the right TYPE relies a lot on understanding the underlying
> mechanism, which I'm not yet familiar enough with :-) ).
>
It's not too complex—the point is to make it as similar as possible to
normal single threaded Rust.
However, all in all, using BqlRefCell for register fields looks to be
> always better than BqlCell.
>
Yep :)
Thank you! I'll change the current code to support this. Instead of
> implementing a register space like PL011, I continue to handle registers
> with u64 variables and bit macro definitions like the C version
That's fine. Experimenting in different directions makes it easier for
future developers to evaluate the tradeoffs.
Also related to the above question, I'm a bit hesitant to use BqlCell
> directly
> or RefCell for such u64 fields...
>
Do whatever looks best to you!
> Plus, speaking in general, "it does something in a different way than the
> > pl011 device model" is a good reason to merge the HPET model earlier
> too. :)
>
> There must be a lot more opens :-(, such as the memattrs/timer binding,
> which I hope to discuss with you at the later RFC!
>
Yes, but stuff like "correctly uses interior mutability" is a very good
reason to include the HPET early.
I will send the next version and include BqlRefCell once I incorporate
Junjie's feedback, in the meanwhile I will send you the BqlRefCell patch
off list.
Paolo
[-- Attachment #2: Type: text/html, Size: 4422 bytes --]
next prev parent reply other threads:[~2024-11-27 8:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 7:47 [PATCH 0/2] rust: safe wrappers for interrupt sources Paolo Bonzini
2024-11-22 7:47 ` [PATCH 1/2] rust: add BQL-enforcing Cell variant Paolo Bonzini
2024-11-26 14:56 ` Zhao Liu
2024-11-26 16:11 ` Paolo Bonzini
2024-11-27 6:35 ` Zhao Liu
2024-11-27 8:31 ` Paolo Bonzini [this message]
2024-11-27 6:54 ` Junjie Mao
2024-11-22 7:47 ` [PATCH 2/2] rust: add bindings for interrupt sources Paolo Bonzini
2024-11-22 8:28 ` Philippe Mathieu-Daudé
2024-11-22 8:32 ` Paolo Bonzini
2024-11-22 10:30 ` Philippe Mathieu-Daudé
2024-11-22 10:53 ` Paolo Bonzini
2024-11-22 11:07 ` Philippe Mathieu-Daudé
2024-11-26 13:45 ` Zhao Liu
2024-11-26 13:35 ` Paolo Bonzini
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=CABgObfZXWKZ8hhH4FmZjZg+9VkSh1+DXPzDs0sMzFyd+yaTuTA@mail.gmail.com \
--to=pbonzini@redhat.com \
--cc=junjie.mao@hotmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
--cc=zhao1.liu@intel.com \
/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).