Re: [PATCH v2 3/6] module/dups: Avoid unnecessary kmod_dup_req allocations
From: Aaron Tomlin
Date: Thu Jul 23 2026 - 22:55:06 EST
On Thu, Jul 23, 2026 at 10:25:53AM +0200, Petr Pavlu wrote:
> The kmod dups code preallocates kmod_dup_req before taking kmod_dup_mutex
> to avoid allocating memory while holding the lock. This provides little
> benefit, since the allocation is fast and can safely be done under the
> lock. On the other hand, it leads to unnecessary allocations when the
> request turns out to be a duplicate and slightly complicates the code.
>
> Allocate kmod_dup_req only when needed and introduce a helper function
> alloc_kmod_req() to initialize the structure.
>
> Signed-off-by: Petr Pavlu <petr.pavlu@xxxxxxxx>
> ---
> kernel/module/dups.c | 38 ++++++++++++++++++++++----------------
> 1 file changed, 22 insertions(+), 16 deletions(-)
Reviewed-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
--
Aaron Tomlin