lkml.org 
[lkml]   [2020]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 1/7] module: Add lock_modules() and unlock_modules()
    Date
    Add wrapper functions for acquiring module_mutex so that the locking can
    be implicitly compiled out when CONFIG_MODULES is not enabled.

    Cc: Andi Kleen <ak@linux.intel.com>
    Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    ---
    include/linux/module.h | 18 ++++++++++++++++++
    1 file changed, 18 insertions(+)

    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)
    +{
    +}
    +
    #endif /* CONFIG_MODULES */

    #ifdef CONFIG_SYSFS
    --
    2.25.1
    \
     
     \ /
      Last update: 2020-07-17 05:06    [W:4.260 / U:0.304 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site