mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Bristot de Oliveira <bristot@kernel.org>
To: Nico Pache <npache@redhat.com>, linux-kernel@vger.kernel.org
Cc: rostedt@goodmis.org, mingo@redhat.com
Subject: Re: [PATCH] trace/osnoise: Fix possible recursive locking in stop_per_cpu_kthreads
Date: Tue, 20 Sep 2022 09:42:44 +0200	[thread overview]
Message-ID: <53ba30f1-c867-f34e-b262-08df67ef26fb@kernel.org> (raw)
In-Reply-To: <20220919144932.3064014-1-npache@redhat.com>

Hi Nico!

On 9/19/22 16:49, Nico Pache wrote:
> There is a recursive lock on the cpu_hotplug_lock.
> 
> In kernel/trace/trace_osnoise.c:<start/stop>_per_cpu_kthreads:
>     - start_per_cpu_kthreads calls cpus_read_lock() and if
> 	start_kthreads returns a error it will call stop_per_cpu_kthreads.
>     - stop_per_cpu_kthreads then calls cpus_read_lock() again causing
>       deadlock.

Yep, I see the problem.

> Fix this by calling cpus_read_unlock() before calling
> stop_per_cpu_kthreads. This behavior can also be seen in commit
> f46b16520a08 ("trace/hwlat: Implement the per-cpu mode").

Correct, we have a similar function that *without* this problem.

> This error was noticed during the LTP ftrace-stress-test:
> 
> WARNING: possible recursive locking detected
> --------------------------------------------
> sh/275006 is trying to acquire lock:
> ffffffffb02f5400 (cpu_hotplug_lock){++++}-{0:0}, at: stop_per_cpu_kthreads
> 
> but task is already holding lock:
> ffffffffb02f5400 (cpu_hotplug_lock){++++}-{0:0}, at: start_per_cpu_kthreads
> 
> other info that might help us debug this:
>  Possible unsafe locking scenario:
> 
>       CPU0
>       ----
>  lock(cpu_hotplug_lock);
>  lock(cpu_hotplug_lock);
> 
>  *** DEADLOCK ***
> 
> May be due to missing lock nesting notation
> 
> 3 locks held by sh/275006:
>  #0: ffff8881023f0470 (sb_writers#24){.+.+}-{0:0}, at: ksys_write
>  #1: ffffffffb084f430 (trace_types_lock){+.+.}-{3:3}, at: rb_simple_write
>  #2: ffffffffb02f5400 (cpu_hotplug_lock){++++}-{0:0}, at: start_per_cpu_kthreads
> 
> Fixes: c8895e271f79 ("trace/osnoise: Support hotplug operations")
> Signed-off-by: Nico Pache <npache@redhat.com>

Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>

Thanks!
-- Daniel

      reply	other threads:[~2022-09-20  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 14:49 Nico Pache
2022-09-20  7:42 ` Daniel Bristot de Oliveira [this message]

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=53ba30f1-c867-f34e-b262-08df67ef26fb@kernel.org \
    --to=bristot@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=npache@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®