Re: [PATCH v3] modules: wait do_free_init correctly

From: Andrew Morton
Date: Sun Feb 18 2024 - 16:22:02 EST


On Sat, 17 Feb 2024 16:18:10 +0800 Changbin Du <changbin.du@xxxxxxxxxx> wrote:

> The synchronization here is just to ensure the module init's been freed
> before doing W+X checking. But the commit 1a7b7d922081 ("modules: Use
> vmalloc special flag") moves do_free_init() into a global workqueue
> instead of call_rcu(). So now rcu_barrier() can not ensure that do_free_init
> has completed. We should wait it via flush_work().
>
> Without this fix, we still could encounter false positive reports in
> W+X checking, and the rcu synchronization is unnecessary which can
> introduce significant delay.
>
> Eric Chanudet reports that the rcu_barrier introduces ~0.1s delay on a
> PREEMPT_RT kernel.
> [ 0.291444] Freeing unused kernel memory: 5568K
> [ 0.402442] Run /sbin/init as init process
>
> With this fix, the above delay can be eliminated.

Thanks, I'll queue this as a delta, to be folded into the base patch
prior to upstreaming.

I added a Tested-by: Eric, if that's OK by him?