Skip to content

Commit cb0b50b

Browse files
Sebastian Andrzej Siewiormcgrof
authored andcommitted
module: Remove preempt_disable() from module reference counting.
The preempt_disable() section in module_put() was added in commit e1783a2 ("module: Use this_cpu_xx to dynamically allocate counters") while the per-CPU counter were switched to another API. The API requires that during the RMW operation the CPU remained the same. This counting API was later replaced with atomic_t in commit 2f35c41 ("module: Replace module_ref with atomic_t refcnt") Since this atomic_t replacement there is no need to keep preemption disabled while the reference counter is modified. Remove preempt_disable() from module_put(), __module_get() and try_module_get(). Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent d36f6ef commit cb0b50b

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

kernel/module/main.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,8 @@ static struct module_attribute modinfo_refcnt =
820820
void __module_get(struct module *module)
821821
{
822822
if (module) {
823-
preempt_disable();
824823
atomic_inc(&module->refcnt);
825824
trace_module_get(module, _RET_IP_);
826-
preempt_enable();
827825
}
828826
}
829827
EXPORT_SYMBOL(__module_get);
@@ -833,15 +831,12 @@ bool try_module_get(struct module *module)
833831
bool ret = true;
834832

835833
if (module) {
836-
preempt_disable();
837834
/* Note: here, we can fail to get a reference */
838835
if (likely(module_is_live(module) &&
839836
atomic_inc_not_zero(&module->refcnt) != 0))
840837
trace_module_get(module, _RET_IP_);
841838
else
842839
ret = false;
843-
844-
preempt_enable();
845840
}
846841
return ret;
847842
}
@@ -852,11 +847,9 @@ void module_put(struct module *module)
852847
int ret;
853848

854849
if (module) {
855-
preempt_disable();
856850
ret = atomic_dec_if_positive(&module->refcnt);
857851
WARN_ON(ret < 0); /* Failed to put refcount */
858852
trace_module_put(module, _RET_IP_);
859-
preempt_enable();
860853
}
861854
}
862855
EXPORT_SYMBOL(module_put);

0 commit comments

Comments
 (0)