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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 24, 2020 at 11:13:19AM +0200, Ingo Molnar wrote:
> 
> * Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> 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(-)
> > 
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 2e6670860d27..8850b9692b8f 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -705,6 +705,16 @@ static inline bool is_livepatch_module(struct module *mod)
> >  bool is_module_sig_enforced(void);
> >  void set_module_sig_enforced(void);
> >  
> > +static inline void lock_modules(void)
> > +{
> > +	mutex_lock(&module_mutex);
> > +}
> > +
> > +static inline void unlock_modules(void)
> > +{
> > +	mutex_unlock(&module_mutex);
> > +}
> > +
> >  #else /* !CONFIG_MODULES... */
> >  
> >  static inline struct module *__module_address(unsigned long addr)
> > @@ -852,6 +862,14 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr)
> >  	return ptr;
> >  }
> >  
> > +static inline void lock_modules(void)
> > +{
> > +}
> > +
> > +static inline void unlock_modules(void)
> > +{
> > +}
> 
> Minor namespace nit: when introducing new locking wrappers please 
> standardize on the XYZ_lock()/XYZ_unlock() nomenclature, i.e.:
> 
> 	modules_lock()
> 	...
> 	modules_unlock()
> 
> Similarly to the mutex_lock/unlock(&module_mutex) API that it is 
> wrapping.
> 
> Also, JFYI, the overwhelming majority of the modules related APIs use 
> module_*(), i.e. singular - not plural, so 
> module_lock()/module_unlock() would be the more canonical choice. 
> (But both sound fine to me)

Thanks, I renamed them as module_lock() and module_unlock().

> Thanks,
> 
> 	Ingo

/Jarkko




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux