Skip to content

Commit 6fb0538

Browse files
Aaron Tomlinmcgrof
authored andcommitted
module: Move module_assert_mutex_or_preempt() to internal.h
No functional change. This patch migrates module_assert_mutex_or_preempt() to internal.h. So, the aforementiond function can be used outside of main/or core module code yet will remain restricted for internal use only. Signed-off-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent c14e522 commit 6fb0538

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

kernel/module/internal.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/module.h>
1111
#include <linux/mutex.h>
1212
#include <linux/rculist.h>
13+
#include <linux/rcupdate.h>
1314

1415
#ifndef ARCH_SHF_SMALL
1516
#define ARCH_SHF_SMALL 0
@@ -102,6 +103,17 @@ long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr,
102103
char *module_flags(struct module *mod, char *buf);
103104
size_t module_flags_taint(unsigned long taints, char *buf);
104105

106+
static inline void module_assert_mutex_or_preempt(void)
107+
{
108+
#ifdef CONFIG_LOCKDEP
109+
if (unlikely(!debug_locks))
110+
return;
111+
112+
WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
113+
!lockdep_is_held(&module_mutex));
114+
#endif
115+
}
116+
105117
static inline unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
106118
{
107119
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS

kernel/module/main.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,6 @@ static void mod_update_bounds(struct module *mod)
118118
#endif
119119
}
120120

121-
static void module_assert_mutex_or_preempt(void)
122-
{
123-
#ifdef CONFIG_LOCKDEP
124-
if (unlikely(!debug_locks))
125-
return;
126-
127-
WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
128-
!lockdep_is_held(&module_mutex));
129-
#endif
130-
}
131-
132121
/* Block module loading/unloading? */
133122
int modules_disabled = 0;
134123
core_param(nomodule, modules_disabled, bint, 0);

0 commit comments

Comments
 (0)