[Pdbg] [PATCH v2 37/39] gdbserver: use thread_stop_all() / thread_start_all()

Joel Stanley joel at jms.id.au
Tue May 3 17:43:15 AEST 2022


On Wed, 20 Apr 2022 at 06:52, Nicholas Piggin <npiggin at gmail.com> wrote:
>
> This could (marginally) improve stop/start latency when targeting
> all threads.
>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>

Reviewed-by: Joel Stanley <joel at jms.id.au>

> ---
>  src/pdbgproxy.c | 44 +++++++++++++++++++++++++-------------------
>  1 file changed, 25 insertions(+), 19 deletions(-)
>
> diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
> index d50121c0..e81dba40 100644
> --- a/src/pdbgproxy.c
> +++ b/src/pdbgproxy.c
> @@ -686,13 +686,19 @@ static void __start_all(void)
>         if (!all_stopped)
>                 PR_ERROR("starting while not all stopped\n");
>
> -       for_each_path_target_class("thread", target) {
> -               if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
> -                       continue;
> +       if (path_target_all_selected("thread", NULL)) {
> +               if (thread_start_all()) {
> +                       PR_ERROR("Could not start threads\n");
> +               }
> +       } else {
> +               for_each_path_target_class("thread", target) {
> +                       if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
> +                               continue;
>
> -               if (thread_start(target)) {
> -                       PR_ERROR("Could not start thread %s\n",
> -                                pdbg_target_path(target));
> +                       if (thread_start(target)) {
> +                               PR_ERROR("Could not start thread %s\n",
> +                                        pdbg_target_path(target));
> +                       }
>                 }
>         }
>
> @@ -706,16 +712,10 @@ static void start_all(void)
>         for_each_path_target_class("thread", target) {
>                 struct thread *thread = target_to_thread(target);
>                 struct gdb_thread *gdb_thread;
> -               struct thread_state status;
>
>                 if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
>                         continue;
>
> -               target->probe(target);
> -               status = thread_status(target);
> -               if (!status.quiesced)
> -                       PR_ERROR("starting thread not quiesced\n");
> -
>                 gdb_thread = thread->gdbserver_priv;
>
>                 gdb_thread->stop_attn = false;
> @@ -794,14 +794,20 @@ static void __stop_all(void)
>         if (all_stopped)
>                 PR_ERROR("stopping while all stopped\n");
>
> -       for_each_path_target_class("thread", target) {
> -               if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
> -                       continue;
> +       if (path_target_all_selected("thread", NULL)) {
> +               if (thread_stop_all()) {
> +                       PR_ERROR("Could not stop threads\n");
> +               }
> +       } else {
> +               for_each_path_target_class("thread", target) {
> +                       if (pdbg_target_status(target) != PDBG_TARGET_ENABLED)
> +                               continue;
>
> -               if (thread_stop(target)) {
> -                       PR_ERROR("Could not stop thread %s\n",
> -                                pdbg_target_path(target));
> -                       /* How to fix? */
> +                       if (thread_stop(target)) {
> +                               PR_ERROR("Could not stop thread %s\n",
> +                                        pdbg_target_path(target));
> +                               /* How to fix? */
> +                       }
>                 }
>         }
>
> --
> 2.35.1
>
> --
> Pdbg mailing list
> Pdbg at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg


More information about the Pdbg mailing list