tracing/user_events: Track refcount consistently via put/get
authorBeau Belgrave <beaub@linux.microsoft.com>
Wed, 14 Jun 2023 16:33:32 +0000 (09:33 -0700)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 14 Jun 2023 17:43:26 +0000 (13:43 -0400)
commitf0dbf6fd0bddb9290c89fdd7afc53dad5051030e
treed689d0ff6ade593f0ff0bc583f8d9d274aa14c3f
parentb08d72580584ab89c41d6fc0f15cd1cf4ce2ed93
tracing/user_events: Track refcount consistently via put/get

Various parts of the code today track user_event's refcnt field directly
via a refcount_add/dec. This makes it hard to modify the behavior of the
last reference decrement in all code paths consistently. For example, in
the future we will auto-delete events upon the last reference going
away. This last reference could happen in many places, but we want it to
be consistently handled.

Add user_event_get() and user_event_put() for the add/dec. Update all
places where direct refcounts are being used to utilize these new
functions. In each location pass if event_mutex is locked or not. This
allows us to drop events automatically in future patches clearly. Ensure
when caller states the lock is held, it really is (or is not) held.

Link: https://lkml.kernel.org/r/20230614163336.5797-3-beaub@linux.microsoft.com
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_user.c