Re: [PATCH] Revert "module, async: async_synchronize_full() on module init iff async is used"

From: Greg Kroah-Hartman
Date: Tue Feb 01 2022 - 13:20:25 EST


On Tue, Feb 01, 2022 at 08:13:14AM -1000, Tejun Heo wrote:
> Hello,
>
> On Fri, Jan 28, 2022 at 09:39:12AM +0200, Linus Torvalds wrote:
> > However, we've done this for *so* long that I wonder if there might be
> > situations that have ended up depending on the lack of synchronization
> > for pure performance reasons.
> >
> > If *this* module loading process started the async work, then we'd
> > wait for it, but what if there's other async work that was started by
> > others? This revert would now make us wait for that async work too,
> > and that might be a big deal slowing things down at boot time.
> >
> > Looking at it, this is all under the 'module_mutex', so I guess we are
> > already single-threaded at least wrt loading other modules, so the
> > amount of unrelated async work going on is presumably fairly low and
> > that isn't an issue.
>
> Looks like we're multi-threaded while running the mod inits which launch the
> async jobs and single-threaded while waiting for them to finish. Greg should
> know a lot better than me but according to my hazy memory and cursory code
> reading udev is multi-processed when loading modules, which makes it a lot
> less likely that this will impact boot time in most cases.

I think userspace is multi-processed here, which should help with the
reading of the modules from disk at boot while others are actually being
loaded due to the kernel lock.

> > Anyway, I think this patch is the right thing to do, but just the fact
> > that we've avoided that async wait for so long makes me a bit nervous
> > about fallout from the revert.
> >
> > Comments? Maybe this is a "just apply it, see if somebody screams" situation?
>
> So, yeah, I think the risk is pretty low and even in the unlikely case that
> someone is affected, the workaround is pretty straight-forward - not waiting
> for the module loading to finish if appropriate.

I agree with Linus, let's see if anyone notices :)

thanks,

greg k-h