All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: Markus Armbruster <armbru@redhat.com>
Cc: Peter Xu <peterx@redhat.com>,
	qemu-devel@nongnu.org, Juraj Marcin <jmarcin@redhat.com>,
	Fabiano Rosas <farosas@suse.de>,
	Alexey Perevalov <a.perevalov@samsung.com>
Subject: Re: [PATCH 02/11] migration/hmp: Fix postcopy-blocktime per-vCPU results
Date: Wed, 28 May 2025 15:08:38 +0000	[thread overview]
Message-ID: <aDcm9turgPlQ75BO@gallifrey> (raw)
In-Reply-To: <878qmhjlma.fsf@pond.sub.org>

* Markus Armbruster (armbru@redhat.com) wrote:
> Peter Xu <peterx@redhat.com> writes:
> 
> > Unfortunately, it was never correctly shown..
> >
> > This is only found when I started to look into making the blocktime feature
> > more useful (so as to avoid using bpftrace, even though I'm not sure which
> > one will be harder to use..).
> >
> > So the old dump would look like this:
> >
> >   Postcopy vCPU Blocktime: 0-1,4,10,21,33,46,48,59
> >
> > Even though there're actually 40 vcpus, and the string will merge same
> > elements and also sort them.
> >
> > To fix it, simply loop over the uint32List manually.  Now it looks like:
> >
> >   Postcopy vCPU Blocktime (ms):
> >    [15, 0, 0, 43, 29, 34, 36, 29, 37, 41,
> >     33, 37, 45, 52, 50, 38, 40, 37, 40, 49,
> >     40, 35, 35, 35, 81, 19, 18, 19, 18, 30,
> >     22, 3, 0, 0, 0, 0, 0, 0, 0, 0]
> >
> > Cc: Dr. David Alan Gilbert <dave@treblig.org>
> > Cc: Alexey Perevalov <a.perevalov@samsung.com>
> > Cc: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  migration/migration-hmp-cmds.c | 23 ++++++++++++++---------
> >  1 file changed, 14 insertions(+), 9 deletions(-)
> >
> > diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> > index 367ff6037f..3cf890b887 100644
> > --- a/migration/migration-hmp-cmds.c
> > +++ b/migration/migration-hmp-cmds.c
> > @@ -208,15 +208,20 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
> >      }
> >  
> >      if (info->has_postcopy_vcpu_blocktime) {
> > -        Visitor *v;
> > -        char *str;
> > -        v = string_output_visitor_new(false, &str);
> > -        visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime,
> > -                              &error_abort);
> > -        visit_complete(v, &str);
> > -        monitor_printf(mon, "Postcopy vCPU Blocktime: %s\n", str);
> > -        g_free(str);
> > -        visit_free(v);
> > +        uint32List *item = info->postcopy_vcpu_blocktime;
> > +        int count = 0;
> > +
> > +        monitor_printf(mon, "Postcopy vCPU Blocktime (ms): \n [");
> > +
> > +        while (item) {
> > +            monitor_printf(mon, "%"PRIu32", ", item->value);
> > +            item = item->next;
> > +            /* Each line 10 vcpu results, newline if there's more */
> 
> The list can be arbitrarily long?

One per vCPU, so a small arbitrary.

> > +            if ((++count % 10 == 0) && item) {
> > +                monitor_printf(mon, "\n  ");
> > +            }
> > +        }
> > +        monitor_printf(mon, "\b\b]\n");
> 
> Uh, backspace?

Agreed!

Dave

> I usually do something like
> 
>     sep = "";
>     for (...) {
>         printf("%s...", sep, ...);
>         sep = ", "
>     }
> 
> To add line breaks, I'd use something like
> 
>         sep = ... ? ", " : ",\n";
> 
> >      }
> >  
> >  out:
> 
> The less the string visitors are used, the happier I am.
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/


  reply	other threads:[~2025-05-28 15:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27 21:58 [PATCH 00/11] migration: Some enhancements and cleanups for 10.1 Peter Xu
2025-05-27 21:58 ` [PATCH 01/11] migration/hmp: Reorg "info migrate" once more Peter Xu
2025-05-28  6:07   ` Zhijian Li (Fujitsu) via
2025-05-28 15:06   ` Dr. David Alan Gilbert
2025-05-29 16:44   ` Juraj Marcin
2025-05-27 21:58 ` [PATCH 02/11] migration/hmp: Fix postcopy-blocktime per-vCPU results Peter Xu
2025-05-28  6:27   ` Markus Armbruster
2025-05-28 15:08     ` Dr. David Alan Gilbert [this message]
2025-05-28 16:51       ` Peter Xu
2025-05-27 21:58 ` [PATCH 03/11] migration/docs: Move docs for postcopy blocktime feature Peter Xu
2025-05-29 16:45   ` Juraj Marcin
2025-05-27 21:58 ` [PATCH 04/11] migration/bg-snapshot: Do not check for SKIP in iterator Peter Xu
2025-05-29 16:45   ` Juraj Marcin
2025-05-27 21:58 ` [PATCH 05/11] migration: Drop save_live_complete_postcopy hook Peter Xu
2025-05-29 14:42   ` Juraj Marcin
2025-05-29 14:48     ` Juraj Marcin
2025-05-29 15:38       ` Peter Xu
2025-05-27 21:58 ` [PATCH 06/11] migration: Rename save_live_complete_precopy to save_complete Peter Xu
2025-05-27 21:58 ` [PATCH 07/11] migration: qemu_savevm_complete*() helpers Peter Xu
2025-05-27 21:58 ` [PATCH 08/11] migration/ram: One less indent for ram_find_and_save_block() Peter Xu
2025-05-29 16:47   ` Juraj Marcin
2025-05-27 21:58 ` [PATCH 09/11] migration/ram: Add tracepoints for ram_save_complete() Peter Xu
2025-05-29 16:48   ` Juraj Marcin
2025-05-27 21:58 ` [PATCH 10/11] migration: Rewrite the migration complete detect logic Peter Xu
2025-05-29 16:48   ` Juraj Marcin
2025-05-27 21:58 ` [PATCH 11/11] migration/postcopy: Avoid clearing dirty bitmap for postcopy too Peter Xu
2025-06-02 16:23   ` 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=aDcm9turgPlQ75BO@gallifrey \
    --to=dave@treblig.org \
    --cc=a.perevalov@samsung.com \
    --cc=armbru@redhat.com \
    --cc=farosas@suse.de \
    --cc=jmarcin@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.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.