Re: [PATCH v5 1/6] kprobes: Remove dependency to the module_mutex

From: Jarkko Sakkinen
Date: Fri Jul 24 2020 - 22:43:00 EST


On Fri, Jul 24, 2020 at 01:22:58PM +0300, Mike Rapoport wrote:
> On Fri, Jul 24, 2020 at 08:05:48AM +0300, Jarkko Sakkinen wrote:
> > Add lock_modules() and unlock_modules() wrappers for acquiring module_mutex
> > in order to remove the compile time dependency to it.
> >
> > Cc: linux-mm@xxxxxxxxx
> > Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Suggested-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx>
> > ---
> > include/linux/module.h | 18 ++++++++++++++++++
> > kernel/kprobes.c | 4 ++--
> > kernel/trace/trace_kprobe.c | 4 ++--
> > 3 files changed, 22 insertions(+), 4 deletions(-)
>
> Any reason to convert only kprobes to the new API and leave others with
> opencoded implementation?

Not anything particular.

Lets see:

$ git --no-pager grep "mutex_lock(&module_mutex)"
arch/powerpc/platforms/powernv/pci-cxl.c: mutex_lock(&module_mutex);
drivers/gpu/drm/drm_fb_helper.c: mutex_lock(&module_mutex);
include/linux/module.h: mutex_lock(&module_mutex);
kernel/livepatch/core.c: mutex_lock(&module_mutex);
kernel/livepatch/core.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);
kernel/module.c: mutex_lock(&module_mutex);

I could refine this commit to patch these sites. Or should I split it
into multiple?

/Jarkko