linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Beau Belgrave <beaub@linux.microsoft.com>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, ast@kernel.org,
	dcook@linux.microsoft.com
Subject: Re: [PATCH v2 3/5] tracing/user_events: Add auto cleanup and a flag to persist events
Date: Tue, 13 Jun 2023 15:26:06 -0400	[thread overview]
Message-ID: <20230613152606.3ace5547@gandalf.local.home> (raw)
In-Reply-To: <20230605233900.2838-4-beaub@linux.microsoft.com>

On Mon,  5 Jun 2023 16:38:58 -0700
Beau Belgrave <beaub@linux.microsoft.com> wrote:

Continuing on what Alexei was saying ...

> +	/*
> +	 * Unfortunately we have to attempt the actual destroy in a work
> +	 * queue. This is because not all cases handle a trace_event_call
> +	 * being removed within the class->reg() operation for unregister.
> +	 */
> +	INIT_WORK(&user->put_work, delayed_destroy_user_event);

We initialize the work here.

> +
> +	/*
> +	 * Since the event is still in the hashtable, we have to re-inc
> +	 * the ref count to 1. This count will be decremented and checked
> +	 * in the work queue to ensure it's still the last ref. This is
> +	 * needed because a user-process could register the same event in
> +	 * between the time of event_mutex release and the work queue
> +	 * running the delayed destroy. If we removed the item now from
> +	 * the hashtable, this would result in a timing window where a
> +	 * user process would fail a register because the trace_event_call
> +	 * register would fail in the tracing layers.
> +	 */
> +	refcount_set(&user->refcnt, 1);
> +
> +	if (!schedule_work(&user->put_work)) {

From what I understand, schedule_work() can only fail if the work is
already queued. That should never happen if we just initialized it.

That means we need a WARN_ON_ONCE() here. Because it's a major bug if that
does return false.

-- Steve


> +		/*
> +		 * If we fail we must wait for an admin to attempt delete or
> +		 * another register/close of the event, whichever is first.
> +		 */
> +		pr_warn("user_events: Unable to queue delayed destroy\n");
> +	}

  parent reply	other threads:[~2023-06-13 19:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 23:38 [PATCH v2 0/5] tracing/user_events: Add auto cleanup and a flag to persist events Beau Belgrave
2023-06-05 23:38 ` [PATCH v2 1/5] tracing/user_events: Store register flags on events Beau Belgrave
2023-06-05 23:38 ` [PATCH v2 2/5] tracing/user_events: Track refcount consistently via put/get Beau Belgrave
2023-06-05 23:38 ` [PATCH v2 3/5] tracing/user_events: Add auto cleanup and a flag to persist events Beau Belgrave
2023-06-07  1:26   ` Alexei Starovoitov
2023-06-07 19:16     ` Beau Belgrave
2023-06-08 20:25   ` Steven Rostedt
2023-06-08 21:22     ` Beau Belgrave
2023-06-13 19:26   ` Steven Rostedt [this message]
2023-06-05 23:38 ` [PATCH v2 4/5] tracing/user_events: Add self-test for persist flag Beau Belgrave
2023-06-05 23:39 ` [PATCH v2 5/5] tracing/user_events: Add persist flag documentation 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=20230613152606.3ace5547@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=ast@kernel.org \
    --cc=beaub@linux.microsoft.com \
    --cc=dcook@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).