Commit b7c424c4 authored by Philippe Gerum's avatar Philippe Gerum

module: ipipe: enable try_module_get() from hard atomic context

We might have out-of-band code calling try_module_get() from the head
domain, or from a section covered by a hard spinlock where the root
domain must not reschedule. This requires the preemption management
calls in try_module_get() (and the converse module_put()) to be
converted to their hard variant.

REVISIT: using try_module_get() from such contexts is questionable,
client domains should be fixed.
parent 5f37bade
......@@ -1115,7 +1115,7 @@ bool try_module_get(struct module *module)
bool ret = true;
if (module) {
preempt_disable();
unsigned long flags = hard_preempt_disable();
/* Note: here, we can fail to get a reference */
if (likely(module_is_live(module) &&
atomic_inc_not_zero(&module->refcnt) != 0))
......@@ -1123,7 +1123,7 @@ bool try_module_get(struct module *module)
else
ret = false;
preempt_enable();
hard_preempt_enable(flags);
}
return ret;
}
......@@ -1134,11 +1134,11 @@ void module_put(struct module *module)
int ret;
if (module) {
preempt_disable();
unsigned long flags = hard_preempt_disable();
ret = atomic_dec_if_positive(&module->refcnt);
WARN_ON(ret < 0); /* Failed to put refcount */
trace_module_put(module, _RET_IP_);
preempt_enable();
hard_preempt_enable(flags);
}
}
EXPORT_SYMBOL(module_put);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment