On Tue, Jan 13, 2026 at 10:32:48AM +0100, Paolo Bonzini wrote: > 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.
I'd be concerned that we would not be able to rationalize what thread is starting the RCU thread. It will probably be the main thread, but proving that will be difficult. A thread which is not the main thread may have undesirable CPU affinity set which we don't have the RCU thread to inherit. IMHO if we remove the constructor, then we need to have a strong guarantee that it is spawned from the main() method and not from any other background thread. I wouldn't rule our doing it manually from every main() method. We could probably come up with something to make it less of a burden for test programs. eg replace g_test_init() with q_test_init() which combines g_test_init with RCU thread creation. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
