public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	joel@joelfernandes.org, linke li <lilinke99@qq.com>,
	Rabin Vincent <rabin@rab.in>,
	stable@vger.kernel.org
Subject: Re: [PATCH 4/6] tracing: Fix waking up tracing readers
Date: Fri, 8 Mar 2024 14:13:11 -0500	[thread overview]
Message-ID: <20240308141311.03eefef1@gandalf.local.home> (raw)
In-Reply-To: <20240308184007.805898590@goodmis.org>

On Fri, 08 Mar 2024 13:38:20 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> +static DEFINE_MUTEX(wait_mutex);
> +
> +static bool wait_woken_prepare(struct trace_iterator *iter, int *wait_index)
> +{
> +	bool woken = false;
> +
> +	mutex_lock(&wait_mutex);
> +	if (iter->waking)
> +		woken = true;
> +	*wait_index = iter->wait_index;
> +	mutex_unlock(&wait_mutex);
> +
> +	return woken;
> +}

The last patch adds this code after a prepare_to_wait(), which triggered
the warning:

  do not call blocking ops when !TASK_RUNNING; state=1 set at [<00000000797e3e20>] prepare_to_wait+0x48/0xf0

Which is correct. The prepare_to_wait() set task state to
TASK_INTERRUPTIBLE, so I can not call a mutex after that.

I'll send a v2 where I switch this over to spin locks.

-- Steve


> +
> +static bool wait_woken_check(struct trace_iterator *iter, int *wait_index)
> +{
> +	bool woken = false;
> +
> +	mutex_lock(&wait_mutex);
> +	if (iter->waking || *wait_index != iter->wait_index)
> +		woken = true;
> +	mutex_unlock(&wait_mutex);
> +
> +	return woken;
> +}
> +
> +static void wait_woken_set(struct trace_iterator *iter)
> +{
> +	mutex_lock(&wait_mutex);
> +	iter->waking++;
> +	iter->wait_index++;
> +	mutex_unlock(&wait_mutex);
> +}
> +
> +static void wait_woken_clear(struct trace_iterator *iter)
> +{
> +	mutex_lock(&wait_mutex);
> +	iter->waking--;
> +	mutex_unlock(&wait_mutex);
> +}
> +

  reply	other threads:[~2024-03-08 19:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240308183816.676883229@goodmis.org>
2024-03-08 18:38 ` [PATCH 1/6] ring-buffer: Fix waking up ring buffer readers Steven Rostedt
2024-03-08 18:38 ` [PATCH 3/6] tracing: Use .flush() call to wake up readers Steven Rostedt
2024-03-08 18:38 ` [PATCH 4/6] tracing: Fix waking up tracing readers Steven Rostedt
2024-03-08 19:13   ` Steven Rostedt [this message]
2024-03-08 18:38 ` [PATCH 5/6] ring-buffer: Restructure ring_buffer_wait() to prepare for updates Steven Rostedt
2024-03-08 18:38 ` [PATCH 6/6] tracing/ring-buffer: Fix wait_on_pipe() race Steven Rostedt

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=20240308141311.03eefef1@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=joel@joelfernandes.org \
    --cc=lilinke99@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rabin@rab.in \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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