Re: [PATCH v2 3/6] module/dups: Avoid unnecessary kmod_dup_req allocations
Aaron Tomlin <[email protected]> Thu, 23 Jul 2026 22:53:13 -0400
| Newsgroups | org.kernel.vger.linux-modules,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <wci5eeu4cchnpf37ohadhcemwmvoeyvaux35kzb2ucp2hz25hp@svqybphsnxoi> |
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 <[email protected]> > --- > kernel/module/dups.c | 38 ++++++++++++++++++++++---------------- > 1 file changed, 22 insertions(+), 16 deletions(-) Reviewed-by: Aaron Tomlin <[email protected]> -- Aaron Tomlin