All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/3] plugins: Avoid deadlock in qemu_plugin_user_exit
Date: Fri, 20 Jan 2023 17:35:14 +0000	[thread overview]
Message-ID: <87pmb9w1h9.fsf@linaro.org> (raw)
In-Reply-To: <20230117035701.168514-3-richard.henderson@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> Use of start_exclusive on this exit path leads to deadlock,
> in particular when called from dump_core_and_abort.  There
> does not appear to be a need for it.

We don't want to be doing any translation while un-registering things
lest things get confused. You could split the patch in two though as the
early return seems reasonable.

>
> While we're at it, skip the entire function if no plugins.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  plugins/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/plugins/core.c b/plugins/core.c
> index ccb770a485..35aca0266d 100644
> --- a/plugins/core.c
> +++ b/plugins/core.c
> @@ -502,7 +502,9 @@ void qemu_plugin_user_exit(void)
>  
>      QEMU_LOCK_GUARD(&plugin.lock);
>  
> -    start_exclusive();
> +    if (QTAILQ_EMPTY(&plugin.ctxs)) {
> +        return;
> +    }
>  
>      /* un-register all callbacks except the final AT_EXIT one */
>      for (ev = 0; ev < QEMU_PLUGIN_EV_MAX; ev++) {
> @@ -520,8 +522,6 @@ void qemu_plugin_user_exit(void)
>          qemu_plugin_disable_mem_helpers(cpu);
>      }
>  
> -    end_exclusive();
> -
>      /* now it's safe to handle the exit case */
>      qemu_plugin_atexit_cb();
>  }


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2023-01-20 17:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17  3:56 [PATCH 0/3] tests: Fix some deadlocks Richard Henderson
2023-01-17  3:56 ` [PATCH 1/3] tests/tcg: Use SIGKILL for timeout Richard Henderson
2023-01-17  9:36   ` Alex Bennée
2023-01-17 15:28     ` Richard Henderson
2023-01-17  3:57 ` [PATCH 2/3] plugins: Avoid deadlock in qemu_plugin_user_exit Richard Henderson
2023-01-20 17:35   ` Alex Bennée [this message]
2023-01-17  3:57 ` [PATCH 3/3] plugins: Iterate on cb_lists " Richard Henderson
2023-01-20 17:39   ` Alex Bennée

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=87pmb9w1h9.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.