mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-28 00:19:36 +00:00
rv: Remove rv_reactor's reference counter
rv_reactor has a reference counter to ensure it is not removed while monitors are still using it. However, this is futile, as __exit functions are not expected to fail and will proceed normally despite rv_unregister_reactor() returning an error. At the moment, reactors do not support being built as modules, therefore they are never removed and the reference counters are not necessary. If we support building RV reactors as modules in the future, kernel module's centralized facilities such as try_module_get(), module_put() or MODULE_SOFTDEP should be used instead of this custom implementation. Remove this reference counter. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/bb946398436a5e17fb0f5b842ef3313c02291852.1753378331.git.namcao@linutronix.de Reviewed-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Nam Cao <namcao@linutronix.de> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
parent
3d3c376118
commit
3d3800b4f7
@ -91,8 +91,6 @@ struct rv_reactor {
|
||||
const char *description;
|
||||
__printf(1, 2) void (*react)(const char *msg, ...);
|
||||
struct list_head list;
|
||||
/* protected by the monitor interface lock */
|
||||
int counter;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -769,7 +769,6 @@ static const struct file_operations monitoring_on_fops = {
|
||||
|
||||
static void destroy_monitor_dir(struct rv_monitor *mon)
|
||||
{
|
||||
reactor_cleanup_monitor(mon);
|
||||
rv_remove(mon->root_d);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ bool rv_is_nested_monitor(struct rv_monitor *mon);
|
||||
|
||||
#ifdef CONFIG_RV_REACTORS
|
||||
int reactor_populate_monitor(struct rv_monitor *mon);
|
||||
void reactor_cleanup_monitor(struct rv_monitor *mon);
|
||||
int init_rv_reactors(struct dentry *root_dir);
|
||||
#else
|
||||
static inline int reactor_populate_monitor(struct rv_monitor *mon)
|
||||
@ -39,11 +38,6 @@ static inline int reactor_populate_monitor(struct rv_monitor *mon)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void reactor_cleanup_monitor(struct rv_monitor *mon)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline int init_rv_reactors(struct dentry *root_dir)
|
||||
{
|
||||
return 0;
|
||||
|
@ -172,10 +172,6 @@ static void monitor_swap_reactors_single(struct rv_monitor *mon,
|
||||
if (monitor_enabled)
|
||||
rv_disable_monitor(mon);
|
||||
|
||||
/* swap reactor's usage */
|
||||
mon->reactor->counter--;
|
||||
reactor->counter++;
|
||||
|
||||
mon->reactor = reactor;
|
||||
mon->reacting = reacting;
|
||||
mon->react = reactor->react;
|
||||
@ -343,23 +339,10 @@ int rv_register_reactor(struct rv_reactor *reactor)
|
||||
*/
|
||||
int rv_unregister_reactor(struct rv_reactor *reactor)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&rv_interface_lock);
|
||||
|
||||
if (!reactor->counter) {
|
||||
list_del(&reactor->list);
|
||||
} else {
|
||||
printk(KERN_WARNING
|
||||
"rv: the rv_reactor %s is in use by %d monitor(s)\n",
|
||||
reactor->name, reactor->counter);
|
||||
printk(KERN_WARNING "rv: the rv_reactor %s cannot be removed\n",
|
||||
reactor->name);
|
||||
ret = -EBUSY;
|
||||
}
|
||||
|
||||
list_del(&reactor->list);
|
||||
mutex_unlock(&rv_interface_lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -456,23 +439,11 @@ int reactor_populate_monitor(struct rv_monitor *mon)
|
||||
* Configure as the rv_nop reactor.
|
||||
*/
|
||||
mon->reactor = get_reactor_rdef_by_name("nop");
|
||||
mon->reactor->counter++;
|
||||
mon->reacting = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* reactor_cleanup_monitor - cleanup a monitor reference
|
||||
* @mon: the monitor.
|
||||
*/
|
||||
void reactor_cleanup_monitor(struct rv_monitor *mon)
|
||||
{
|
||||
lockdep_assert_held(&rv_interface_lock);
|
||||
mon->reactor->counter--;
|
||||
WARN_ON_ONCE(mon->reactor->counter < 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Nop reactor register
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user