qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: peter.maydell@linaro.org,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	dgilbert@redhat.com, qemu-devel@nongnu.org, imammedo@redhat.com,
	Dave.Martin@arm.com
Subject: Re: [Qemu-devel] How do we do user input bitmap properties?
Date: Tue, 14 May 2019 11:02:25 +0200	[thread overview]
Message-ID: <20190514090225.vel4xm4x743o4rge@kamzik.brq.redhat.com> (raw)
In-Reply-To: <87bm05ab6c.fsf@dusky.pond.sub.org>

On Tue, May 14, 2019 at 06:54:03AM +0200, Markus Armbruster wrote:
> Andrew Jones <drjones@redhat.com> writes:
> 
> > On Thu, Apr 18, 2019 at 07:48:09PM +0200, Markus Armbruster wrote:
> >> Daniel P. Berrangé <berrange@redhat.com> writes:
> >> 
> >> > On Thu, Apr 18, 2019 at 11:28:41AM +0200, Andrew Jones wrote:
> >> >> Hi all,
> >> >> 
> >> >> First some background:
> >> >> 
> >> >> For the userspace side of AArch64 guest SVE support we need to
> >> >> expose KVM's allowed vector lengths bitmap to the user and allow
> >> >> the user to choose a subset of that bitmap. Since bitmaps are a
> >> >> bit awkward to work with then we'll likely want to expose it as
> >> >> an array of vector lengths instead. Also, assuming we want to
> >> >> expose the lengths as number-of-quadwords (quadword == 128 bits
> >> >> for AArch64 and vector lengths must be multiples of quadwords)
> >> >> rather than number-of-bits, then an example array (which will
> >> >> always be a sequence) might be
> >> >> 
> >> >>  [ 8, 16, 32 ]
> >> >> 
> >> >> The user may choose a subsequence, but only through truncation,
> >> >> i.e. [ 8, 32 ] is not valid, but [ 8, 16 ] is.
> >> >> 
> >> >> Furthermore, different hosts may support different sequences
> >> >> which have the same maximum. For example, if the above sequence
> >> >> is for Host_A, then Host_B could be
> >> >> 
> >> >>  [ 8, 16, 24, 32 ]
> >> >> 
> >> >> The host must support all lengths in the sequence, which means
> >> >> that while Host_A supports 32, since it doesn't support 24 and
> >> >> we can only truncate sequences, we must use either [ 8 ] or
> >> >> [ 8, 16 ] for a compatible sequence if we intend to migrate
> >> >> between the hosts.
> >> >> 
> >> >> Now to the $SUBJECT question:
> >> >> 
> >> >> My feeling is that we should require the sequence to be
> >> >> provided on the command line as a cpu property. Something
> >> >> like
> >> >> 
> >> >>   -cpu host,sve-vl-list=8:16
> >> >> 
> >> >> (I chose ':' for the delimiter because ',' can't work, but
> >> >> if there's a better choice, then that's fine by me.)
> >> >> 
> >> >> Afaict a property list like this will require a new parser,
> >> 
> >> We had 20+ of those when I last counted.  Among the more annoying
> >> reasons CLI QAPIfication is hard[1].
> >> 
> >> >> which feels a bit funny since it seems we should already
> >> >> have support for this type of thing somewhere in QEMU. So,
> >> >> the question is: do we? I see we have array properties, but
> >> >> I don't believe that works with the command line. Should we
> >> >> only use QMP for this? We already want some QMP in order to
> >> >> query the supported vector lengths. Maybe we should use QMP
> >> >> to set the selection too? But then what about command line
> >> >> support for developers? And if the property is on the command
> >> >> line then we don't have to add it to the migration stream.
> >> >
> >> > You should be able to use arrays from the CLI with QemuOpts by repeating
> >> > the same option name many times, though I can't say it is a very
> >> > nice approach if you have many values to list as it gets very repetative.
> >> 
> >> Yes, this is one of the ways the current CLI does lists.  It's also one
> >> of the more annoying reasons CLI QAPIfication is hard[2].
> >> 
> >> QemuOpts let the last param=value win the stupidest way that could
> >> possibly work (I respect that): add to the front of the list, search it
> >> front to back.
> >> 
> >> Then somebody discovered that if you search the list manually, you can
> >> see them all, and abuse that to get a list-valued param.  I'm sure that
> >> felt clever at the time.
> >> 
> >> Another way to do lists the funky list feature of string input and opts
> >> visitor.  Yet another annoying reason CLI QAPIfication is hard[3].
> >> 
> >> We use the opts visitor's list feature for -numa node,cpus=...  Hmm,
> >> looks like we even combine it with the "multiple param=value build up a
> >> list" technique: -smp node,cpus=0-1,cpus=4-5 denotes [0,1,4,5].
> >> 
> >> > That's the curse of not having a good CLI syntax for non-scalar data in
> >> > QemuOpts & why Markus believes we should switch to JSON for the CLI too
> >> >
> >> >      -cpu host,sve-vl=8,sve-vl=16
> >> 
> >> We actually have CLI syntax for non-scalar data: dotted keys.  Dotted
> >> keys are syntactic sugar for JSON.  It looks friendlier than JSON for
> >> simple cases, then gets uglier as things get more complex, and then it
> >> falls apart: it can't quite express all of JSON.
> >> 
> >> Example: sve-vl.0=8,sve-vl.1=16
> >>     gets desugared into {"sve": [8, 16]}
> >>     if the QAPI schema has 'sve': ['int'].
> >> 
> >> The comment at the beginning of util/keyval.c explains it in more
> >> detail.
> >> 
> >> It powers -blockdev and -display.  Both options accept either JSON or
> >> dotted keys.  If the option argument starts with '{', it's JSON.
> >> Management applications should stick to JSON.
> >> 
> >> 
> >> [1] Towards a more expressive and introspectable QEMU command line
> >> https://www.linux-kvm.org/images/f/f2/Armbru-qapi-cmdline_1.pdf
> >> Slide 34 "Backward compatibility" item 1
> >> 
> >> [2] ibid, item 4
> >> 
> >> [3] ibid, item 3
> >>
> >
> > Sorry I forgot to follow up to this earlier. I looked at the examples
> > provided and saw they were all for independent command line options,
> > rather than command line options like '-cpu' that then accepts additional
> > properties. I couldn't see how I could use ',' to separate array members
> > when using properties or to use an array property input on the command
> > line.
> 
> The argument of -cpu is parsed ad hoc.  Unlike QemuOpts and dotted keys,
> parse_cpu_option() doesn't seem to support escaping ','.  Not that
> escaping would be a user-friendly solution.
> 
> >       In the end I opted to use a single uint64_t for a bitmap, as 64 is
> > big enough for now,
> 
> Do you think it'll remain big enough?

Probably not forever, and TBH I can't even give an estimate for how long.
Based on the current state, I "feel" like it'll be quite some time though.
I think we can extend this map by adding more ad hoc parsing to -cpu
later. If we added dotted key support then each array member could be
another bitmap word, for example.

> 
> >                     and even though passing some hex number on the command
> > line isn't user friendly at all, it didn't seem like a long list of a
> > repeated parameter was that user friendly either. Of course I'm still open
> > to suggestions to try to find the best balance between user friendliness,
> > current QEMU command line parsing support, and just getting a bitmap into
> > cpu state one way or another.
> 
> I'd ask for consistency with existing practice no matter how flawed if
> we had such consistency.
> 
> If I understand your "[PATCH 00/13] target/arm/kvm: enable SVE in
> guests" correctly, the bitmap form of [1, 2, 4] is
> 
>     -cpu max,sve-vls-map=11
> 
> Observe bit#0 means 1; better document that clearly.
> 
> If we used dotted keys to produce an intList, we'd do
> 
>     -cpu max,sve-vls-map.0=1,sve-vls-map.1=2,sve-vls-map.2=4
> 
> If the option argument is QAPIfied, we additionally get
> 
>     -cpu '{"type": "max", "sve-vls-map": [1, 2, 4]}'
> 
> for free.
> 
> If we did it like -numa (please don't), we'd get something like
> 
>     -cpu max,sve-vls-map=1-2,sve-vls-map=4
> 
> None of the above is exactly a pinnacle of user-friendliness.  JSON is
> at least ugly in a regular way.  Your bitmap encoded in a number is at
> least concise.
> 
> If a numerically encoded bitmap is the least bad option here, I wonder
> why it's not the least bad option for -numa...  Perhaps because there 64
> isn't big enough.
> 
> I'm afraid the numerically encoded bitmap will make its way into the
> QAPI schema sooner or later.  This will create an unfortunate
> inconsistency with the [int] encoding already there.
> 
> Who's going to use sve-vls-map?  Humans, or pretty much only machines?

My thought is primarily machines. If a human wants to use the command
line and SVE, then I'm assuming they'll be happy with sve-max-vq or
figuring out a map they like once and then sticking to it.

Thanks,
drew


  reply	other threads:[~2019-05-14  9:04 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18  9:28 [Qemu-devel] How do we do user input bitmap properties? Andrew Jones
2019-04-18  9:28 ` Andrew Jones
2019-04-18  9:46 ` Andrew Jones
2019-04-18  9:46   ` Andrew Jones
2019-04-18 10:52   ` Dave Martin
2019-04-18 10:52     ` Dave Martin
2019-04-18 11:28     ` Andrew Jones
2019-04-18 11:28       ` Andrew Jones
2019-04-18 14:03       ` Dave Martin
2019-04-18 14:03         ` Dave Martin
2019-04-18 14:43         ` Andrew Jones
2019-04-18 14:43           ` Andrew Jones
2019-04-18 14:46           ` Dave Martin
2019-04-18 14:46             ` Dave Martin
2019-04-18 14:57           ` Dr. David Alan Gilbert
2019-04-18 14:57             ` Dr. David Alan Gilbert
2019-04-18 11:26 ` Daniel P. Berrangé
2019-04-18 11:26   ` Daniel P. Berrangé
2019-04-18 15:09   ` Andrew Jones
2019-04-18 15:09     ` Andrew Jones
2019-04-18 17:48   ` Markus Armbruster
2019-04-18 17:48     ` Markus Armbruster
2019-05-13 18:42     ` Andrew Jones
2019-05-14  4:54       ` Markus Armbruster
2019-05-14  9:02         ` Andrew Jones [this message]
2019-05-14 13:32           ` Markus Armbruster
2019-05-15  8:15             ` Andrew Jones
2019-05-15 10:53               ` Dave Martin
2019-05-15 10:59                 ` Dr. David Alan Gilbert
2019-05-14 14:48           ` Igor Mammedov
2019-05-15  8:18             ` Andrew Jones
2019-05-15 10:52               ` Igor Mammedov
2019-05-15 11:54                 ` Andrew Jones
2019-05-23  8:35                   ` Andrea Bolognani
2019-05-24 18:24                     ` Eduardo Habkost
2019-05-27 16:29                       ` Andrea Bolognani
2019-05-27 18:59                         ` Eduardo Habkost
2019-05-15 11:00               ` Dave Martin
2019-05-15 11:09                 ` Dr. David Alan Gilbert
2019-05-15 12:51                   ` Dave Martin
2019-05-15 11:42                 ` Andrew Jones
2019-05-15 12:50                   ` Dave Martin
2019-05-14 15:28         ` Dave Martin
2019-04-19  0:07 ` Laszlo Ersek
2019-04-19  0:07   ` Laszlo Ersek

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=20190514090225.vel4xm4x743o4rge@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=Dave.Martin@arm.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).