Re: [PATCH v5 02/24] include: define constant for early constructor priority

Paolo Bonzini <[email protected]> Tue, 13 Jan 2026 10:32:48 +0100
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-devel
Message-ID <CABgObfZn753g5Ve4AHi4gX0DtKdDBWV8aCuRSha5ySv9Y_4OGg@mail.gmail.com>
Il mar 13 gen 2026, 10:04 Markus Armbruster <[email protected]> ha scritto:

> Paolo Bonzini <[email protected]> writes:
>
> > On 1/9/26 12:46, Daniel P. Berrangé wrote:
> >> IMHO the root problem is that it is pretty dubious for us to be
> >> spawning the RCU thread from a constructor. Constructors should
> >> be limited to minimal initialization of state.
>
> Yes!  Discussed in review of v3:
>
>     https://lore.kernel.org/qemu-devel/[email protected]/
>     Message-ID: <[email protected]>
>
> >>                                                Spawning threads
> >> is outside the boundary of what I'd consider reasonable for
> >> a constructor todo. I didn't want try to tackle refactoring the
> >> RCU thread creation though, hence this gross workaround.
> >
> > I see.  Maybe we could (just as gross but smaller) do the RCU
> constructor late.  Not something that you need to do now, of course.
>
> Could we use an old-fashioned initialization function instead of a
> constructor for RCU?
>

You have to do it in all main()s, which make it unwieldy for tests etc.

Another possibility is to do it lazily on first call_rcu, and just clear
the flag in the atfork callbacks.

Paolo


>