All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: "Denis V. Lunev" <den@openvz.org>, qemu-devel@nongnu.org
Cc: den@openvz.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Zhao Liu" <zhao1.liu@intel.com>
Subject: Re: [PATCH 09/10] system/cpus: add bql-watchdog-abort
Date: Wed, 14 Oct 2026 20:30:02 -0300	[thread overview]
Message-ID: <875wz3n9mt.fsf@suse.de> (raw)
In-Reply-To: <20260915203455.580999-10-den@openvz.org>

"Denis V. Lunev" <den@openvz.org> writes:

> From: Denis V. Lunev <den@openvz.org>
>
> The report says where each thread was when the watchdog looked, not
> how it got there. A core carries every thread's whole stack, at the
> price of the guest. A qemu whose BQL has been held this long is not
> running its vCPUs anyway, so on a host where the answer is worth more
> than the guest, abort after the report.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> Cc: Zhao Liu <zhao1.liu@intel.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> ---
>  hw/core/machine.c     | 17 +++++++++++++++++
>  include/system/cpus.h |  4 ++++
>  qemu-options.hx       |  5 +++++
>  system/cpus.c         | 19 +++++++++++++++++++
>  4 files changed, 45 insertions(+)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index b55af89516..2abb9e6295 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -403,6 +403,17 @@ static void machine_set_bql_watchdog_ms(Object *obj, Visitor *v,
>      bql_watchdog_set_timeout_ms(value, errp);
>  }
>  
> +static bool machine_get_bql_watchdog_abort(Object *obj, Error **errp)
> +{
> +    return bql_watchdog_get_abort();
> +}
> +
> +static void machine_set_bql_watchdog_abort(Object *obj, bool value,
> +                                           Error **errp)
> +{
> +    bql_watchdog_set_abort(value);
> +}
> +
>  static bool machine_get_new_accel_vmfd_on_reset(Object *obj, Error **errp)
>  {
>      MachineState *ms = MACHINE(obj);
> @@ -1174,6 +1185,12 @@ static void machine_class_init(ObjectClass *oc, const void *data)
>          "Watchdog deadline for a Big QEMU Lock hold, in ms. "
>          "Default: 0 (disabled)");
>  
> +    object_class_property_add_bool(oc, "bql-watchdog-abort",
> +        machine_get_bql_watchdog_abort, machine_set_bql_watchdog_abort);
> +    object_class_property_set_description(oc, "bql-watchdog-abort",
> +        "Abort after the bql-watchdog-ms report, to leave a core dump. "
> +        "Default: off");
> +
>      object_class_property_add_bool(oc, "x-change-vmfd-on-reset",
>          machine_get_new_accel_vmfd_on_reset,
>          machine_set_new_accel_vmfd_on_reset);
> diff --git a/include/system/cpus.h b/include/system/cpus.h
> index 0e1e63bd85..14dbc8ff0d 100644
> --- a/include/system/cpus.h
> +++ b/include/system/cpus.h
> @@ -44,4 +44,8 @@ void cpu_synchronize_all_pre_loadvm(void);
>  bool bql_watchdog_set_timeout_ms(uint64_t ms, Error **errp);
>  uint64_t bql_watchdog_get_timeout_ms(void);
>  
> +/* Abort after reporting, to leave a core behind. */
> +void bql_watchdog_set_abort(bool enable);
> +bool bql_watchdog_get_abort(void);
> +
>  #endif
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 9600620d34..f43d8ca480 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -33,6 +33,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
>      "                dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
>      "                mem-merge=on|off controls memory merge support (default: on)\n"
>      "                bql-watchdog-ms=ms report a Big QEMU Lock held longer than ms (default: 0, off)\n"
> +    "                bql-watchdog-abort=on|off abort after the bql-watchdog-ms report (default: off)\n"
>      "                aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n"
>      "                dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
>      "                suppress-vmdesc=on|off disables self-describing migration (default=off)\n"
> @@ -94,6 +95,10 @@ SRST
>          milliseconds, up to a minute. The default is 0, which disables the
>          watchdog.
>  
> +    ``bql-watchdog-abort=on|off``
> +        Abort after the ``bql-watchdog-ms`` report, to leave a core dump.
> +        The default is off.
> +
>      ``aes-key-wrap=on|off``
>          Enables or disables AES key wrapping support on s390-ccw hosts.
>          This feature controls whether AES wrapping keys will be created
> diff --git a/system/cpus.c b/system/cpus.c
> index 03a07e4824..a200a07707 100644
> --- a/system/cpus.c
> +++ b/system/cpus.c
> @@ -398,6 +398,7 @@ static int bql_this_tid(void)
>  static QemuThread bql_watchdog_thread;
>  static QemuSemaphore bql_watchdog_sem;
>  static uint64_t bql_watchdog_timeout_ms;
> +static bool bql_watchdog_abort;
>  
>  static void bql_report_thread_states(void)
>  {
> @@ -411,6 +412,16 @@ static void bql_report_thread_states(void)
>      qemu_funlockfile(stderr);
>  }
>  
> +bool bql_watchdog_get_abort(void)
> +{
> +    return qatomic_read(&bql_watchdog_abort);
> +}
> +
> +void bql_watchdog_set_abort(bool enable)
> +{
> +    qatomic_set(&bql_watchdog_abort, enable);
> +}
> +
>  static void *bql_watchdog_fn(void *opaque)
>  {
>      unsigned int last = qatomic_read(&bql_seq);
> @@ -456,6 +467,14 @@ static void *bql_watchdog_fn(void *opaque)
>                       when ?: "", when ? " " : "", timeout_ms,
>                       qatomic_read(&bql_owner_tid));
>          bql_report_thread_states();
> +        if (!qatomic_read(&bql_watchdog_abort)) {
> +            continue;
> +        }
> +        /*
> +         * A core carries the whole of every stack, and a qemu whose BQL has
> +         * been held this long has stopped running its vCPUs anyway.
> +         */
> +        abort();
>      }
>  }

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2026-10-14 23:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 20:34 [PATCH 0/10] system: add a watchdog for the Big QEMU Lock Denis V. Lunev
2026-09-15 20:34 ` [PATCH 01/10] util/qemu-thread: track bql_locked across the timed condvar wait Denis V. Lunev
2026-10-14 22:36   ` Fabiano Rosas
2026-09-15 20:34 ` [PATCH 02/10] oslib: add qemu_debugger_attached() Denis V. Lunev
2026-09-15 20:34 ` [PATCH 03/10] oslib: add qemu_thread_states() Denis V. Lunev
2026-09-15 20:34 ` [PATCH 04/10] oslib: report kernel stacks in qemu_thread_states() Denis V. Lunev
2026-09-15 20:34 ` [PATCH 05/10] util/qemu-thread: reserve a signal for thread introspection Denis V. Lunev
2026-09-15 20:34 ` [PATCH 06/10] oslib: report each thread's program counter Denis V. Lunev
2026-09-15 20:34 ` [PATCH 07/10] system/cpus: report a BQL held past a deadline Denis V. Lunev
2026-09-15 20:34 ` [PATCH 08/10] system/cpus: hold off the BQL watchdog under a debugger Denis V. Lunev
2026-09-15 20:34 ` [PATCH 09/10] system/cpus: add bql-watchdog-abort Denis V. Lunev
2026-10-14 23:30   ` Fabiano Rosas [this message]
2026-09-15 20:34 ` [PATCH 10/10] tests/functional: cover the BQL watchdog Denis V. Lunev
2026-09-16  4:57   ` Thomas Huth
2026-09-16  6:44     ` Marc-André Lureau
2026-09-16  7:56       ` Denis V. Lunev
2026-09-18 21:56 ` [PATCH 0/10] system: add a watchdog for the Big QEMU Lock Fabiano Rosas

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=875wz3n9mt.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=den@openvz.org \
    --cc=pbonzini@redhat.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhao1.liu@intel.com \
    /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.