Skip to content

Commit 3d3800b

Browse files
covanamrostedt
authored andcommitted
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 <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Link: https://lore.kernel.org/bb946398436a5e17fb0f5b842ef3313c02291852.1753378331.git.namcao@linutronix.de Reviewed-by: Gabriele Monaco <[email protected]> Signed-off-by: Nam Cao <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 3d3c376 commit 3d3800b

File tree

4 files changed

+2
-40
lines changed

4 files changed

+2
-40
lines changed

include/linux/rv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ struct rv_reactor {
9191
const char *description;
9292
__printf(1, 2) void (*react)(const char *msg, ...);
9393
struct list_head list;
94-
/* protected by the monitor interface lock */
95-
int counter;
9694
};
9795
#endif
9896

kernel/trace/rv/rv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,6 @@ static const struct file_operations monitoring_on_fops = {
769769

770770
static void destroy_monitor_dir(struct rv_monitor *mon)
771771
{
772-
reactor_cleanup_monitor(mon);
773772
rv_remove(mon->root_d);
774773
}
775774

kernel/trace/rv/rv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ bool rv_is_nested_monitor(struct rv_monitor *mon);
3131

3232
#ifdef CONFIG_RV_REACTORS
3333
int reactor_populate_monitor(struct rv_monitor *mon);
34-
void reactor_cleanup_monitor(struct rv_monitor *mon);
3534
int init_rv_reactors(struct dentry *root_dir);
3635
#else
3736
static inline int reactor_populate_monitor(struct rv_monitor *mon)
3837
{
3938
return 0;
4039
}
4140

42-
static inline void reactor_cleanup_monitor(struct rv_monitor *mon)
43-
{
44-
return;
45-
}
46-
4741
static inline int init_rv_reactors(struct dentry *root_dir)
4842
{
4943
return 0;

kernel/trace/rv/rv_reactors.c

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ static void monitor_swap_reactors_single(struct rv_monitor *mon,
172172
if (monitor_enabled)
173173
rv_disable_monitor(mon);
174174

175-
/* swap reactor's usage */
176-
mon->reactor->counter--;
177-
reactor->counter++;
178-
179175
mon->reactor = reactor;
180176
mon->reacting = reacting;
181177
mon->react = reactor->react;
@@ -343,23 +339,10 @@ int rv_register_reactor(struct rv_reactor *reactor)
343339
*/
344340
int rv_unregister_reactor(struct rv_reactor *reactor)
345341
{
346-
int ret = 0;
347-
348342
mutex_lock(&rv_interface_lock);
349-
350-
if (!reactor->counter) {
351-
list_del(&reactor->list);
352-
} else {
353-
printk(KERN_WARNING
354-
"rv: the rv_reactor %s is in use by %d monitor(s)\n",
355-
reactor->name, reactor->counter);
356-
printk(KERN_WARNING "rv: the rv_reactor %s cannot be removed\n",
357-
reactor->name);
358-
ret = -EBUSY;
359-
}
360-
343+
list_del(&reactor->list);
361344
mutex_unlock(&rv_interface_lock);
362-
return ret;
345+
return 0;
363346
}
364347

365348
/*
@@ -456,23 +439,11 @@ int reactor_populate_monitor(struct rv_monitor *mon)
456439
* Configure as the rv_nop reactor.
457440
*/
458441
mon->reactor = get_reactor_rdef_by_name("nop");
459-
mon->reactor->counter++;
460442
mon->reacting = false;
461443

462444
return 0;
463445
}
464446

465-
/**
466-
* reactor_cleanup_monitor - cleanup a monitor reference
467-
* @mon: the monitor.
468-
*/
469-
void reactor_cleanup_monitor(struct rv_monitor *mon)
470-
{
471-
lockdep_assert_held(&rv_interface_lock);
472-
mon->reactor->counter--;
473-
WARN_ON_ONCE(mon->reactor->counter < 0);
474-
}
475-
476447
/*
477448
* Nop reactor register
478449
*/

0 commit comments

Comments
 (0)