All of lore.kernel.org
 help / color / mirror / Atom feed
From: Beau Belgrave <beaub@linux.microsoft.com>
To: rostedt@goodmis.org, mhiramat@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	ast@kernel.org, dcook@linux.microsoft.com
Subject: [PATCH v3 0/6] tracing/user_events: Add auto cleanup and a flag to persist events
Date: Wed, 14 Jun 2023 09:33:30 -0700	[thread overview]
Message-ID: <20230614163336.5797-1-beaub@linux.microsoft.com> (raw)

As part of the discussions for user_events aligning to be used with eBPF
it became clear [1] we needed a way to delete events without having to rely
upon the delete IOCTL. Steven suggested that we simply have an owner
for the event, however, the event can be held by more than just the
first register FD, such as perf/ftrace or additional registers. In order
to handle all those cases, we must only delete after all references are
gone from both user and kernel space.

This series adds a internal register flag, USER_EVENT_REG_PERSIST, which
causes the event to not delete itself upon the last put reference. We
cannot fully drop the delete IOCTL, since we still want to enable events to
be registered early via dynamic_events and persist. Events that do not use
this new flag are auto-cleaned up upon no longer being used. This new flag
is not exposed to user processes yet while we work out the details, however,
the code is updated to accomodate it once it is ready.

1: https://lore.kernel.org/linux-trace-kernel/20230518093600.3f119d68@rorschach.local.home/

Change history

v3:
  Rebased to trace/urgent as requested by Steven

  Removed user-facing references to USER_EVENT_REG_PERSIST while we work out
  the details

  Added check for any flags, even from dynamic_events, will return -EINVAL

  Added clarifying comment about event_mutex protection of refcounts

  Updated selftests to work given the absence of persist events

  Updated documentation to not include /sys/kernel/tracing/dynamic_events since
  they cannot be used until persist flags exist and a note about auto-deletions

v2:
  Renamed series to "Add auto cleanup and a flag to persist events"

  Changed auto-delete to be default behavior, with new flag to persist events

Beau Belgrave (6):
  tracing/user_events: Store register flags on events
  tracing/user_events: Track refcount consistently via put/get
  tracing/user_events: Add auto cleanup and future persist flag
  selftests/user_events: Ensure auto cleanup works as expected
  selftests/user_events: Adapt dyn_test to non-persist events
  tracing/user_events: Document auto-cleanup and remove dyn_event refs

 Documentation/trace/user_events.rst           |   7 +-
 kernel/trace/trace_events_user.c              | 208 ++++++++++++++----
 .../testing/selftests/user_events/dyn_test.c  | 177 +++++++++++----
 .../selftests/user_events/ftrace_test.c       |  49 ++++-
 4 files changed, 346 insertions(+), 95 deletions(-)


base-commit: a8c5c6a5c87ea10189ec43483f44800a4ec97785
-- 
2.25.1


             reply	other threads:[~2023-06-14 16:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 16:33 Beau Belgrave [this message]
2023-06-14 16:33 ` [PATCH v3 1/6] tracing/user_events: Store register flags on events Beau Belgrave
2023-06-14 16:33 ` [PATCH v3 2/6] tracing/user_events: Track refcount consistently via put/get Beau Belgrave
2023-06-14 16:33 ` [PATCH v3 3/6] tracing/user_events: Add auto cleanup and future persist flag Beau Belgrave
2023-06-14 16:33 ` [PATCH v3 4/6] selftests/user_events: Ensure auto cleanup works as expected Beau Belgrave
2023-06-14 16:33 ` [PATCH v3 5/6] selftests/user_events: Adapt dyn_test to non-persist events Beau Belgrave
2023-06-14 16:33 ` [PATCH v3 6/6] tracing/user_events: Document auto-cleanup and remove dyn_event refs Beau Belgrave

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230614163336.5797-1-beaub@linux.microsoft.com \
    --to=beaub@linux.microsoft.com \
    --cc=ast@kernel.org \
    --cc=dcook@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.