From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Eric Blake" <eblake@redhat.com>,
"QEMU Trivial" <qemu-trivial@nongnu.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [PATCH] osdep.h: Add doc comment for qemu_get_thread_id()
Date: Thu, 30 Jul 2020 17:10:58 +0200 [thread overview]
Message-ID: <87k0ylvy0t.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAFEAcA9ukzKGiaV6Tazu8Aezn39v81DKQik1b=jEy=NLnau05w@mail.gmail.com> (Peter Maydell's message of "Tue, 28 Jul 2020 16:25:04 +0100")
Peter Maydell <peter.maydell@linaro.org> writes:
> On Tue, 28 Jul 2020 at 16:17, Eric Blake <eblake@redhat.com> wrote:
>>
>> On 7/16/20 10:41 AM, Peter Maydell wrote:
>> > Add a documentation comment for qemu_get_thread_id(): since this
>> > is rather host-OS-specific it's useful if people writing the
>> > implementation and people thinking of using the function know
>> > what the purpose and limitations are.
>> >
>> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> > ---
>> > Based on conversation with Dan on IRC, and prompted by the recent
>> > patch to add OpenBSD support.
>> >
>> > Q: should we document exactly what the thread-id value is for
>> > each host platform in the QMP documentation ? Somebody writing
>> > a management layer app should ideally not have to grovel through
>> > the application to figure out what they should do with the
>> > integer value they get back from query-cpus...
>> >
>> > include/qemu/osdep.h | 14 ++++++++++++++
>> > 1 file changed, 14 insertions(+)
>>
>> Do we need a counterpart change...
>>
>> >
>> > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
>> > index 4841b5c6b5f..8279f72e5ed 100644
>> > --- a/include/qemu/osdep.h
>> > +++ b/include/qemu/osdep.h
>> > @@ -515,6 +515,20 @@ bool qemu_has_ofd_lock(void);
>> >
>> > bool qemu_write_pidfile(const char *pidfile, Error **errp);
>> >
>> > +/**
>> > + * qemu_get_thread_id: Return OS-specific ID of current thread
>> > + *
>> > + * This function returns an OS-specific identifier of the
>> > + * current thread. This will be used for the "thread-id" field in
>> > + * the response to the QMP query-cpus and query-iothreads commands.
>>
>> ...to the qapi definition of query-cpus and query-iothreads?
>
> Well, that was my question above. Currently the QAPI documentation
> says absolutely nothing about what the thread-id values mean
> for any host OS (beyond "ID of the underlying host thread"), which
> means that any management layer application needs to look in the
> implementation to find out what they actually are...
... which they will have to do to actually use it for the purpose we
have in mind, namely:
>> > + * The intention is that a VM management layer application can then
>> > + * use it to tie specific QEMU vCPU and IO threads to specific host
>> > + * CPUs using whatever the host OS's CPU affinity setting API is.
>> > + * New implementations of this function for new host OSes should
>> > + * return the most sensible integer ID that works for that purpose.
>> > + *
>> > + * This function should not be used for anything else inside QEMU.
>> > + */
Do they?
> Improving the QAPI docs would probably be something like:
> * add a list of host OSes and semantics to the doc comment
> for CpuInfoFast
> * add cross-references to that definition from everywhere
> else in QAPI that uses a thread-id/thread_id
> * add a comment in the C file to say "if you're adding another
> OS ifdef here please update the QAPI doc comment"
If they do, then this sounds like a plan.
By the way, the #else case smells:
#else
return getpid();
#endif
The PID is quite unlikely to be "an OS-specific identifier of the
current thread". Shouldn't we fail instead of lie when we don't know
how to compute the truth?
WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "QEMU Trivial" <qemu-trivial@nongnu.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [PATCH] osdep.h: Add doc comment for qemu_get_thread_id()
Date: Thu, 30 Jul 2020 17:10:58 +0200 [thread overview]
Message-ID: <87k0ylvy0t.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAFEAcA9ukzKGiaV6Tazu8Aezn39v81DKQik1b=jEy=NLnau05w@mail.gmail.com> (Peter Maydell's message of "Tue, 28 Jul 2020 16:25:04 +0100")
Peter Maydell <peter.maydell@linaro.org> writes:
> On Tue, 28 Jul 2020 at 16:17, Eric Blake <eblake@redhat.com> wrote:
>>
>> On 7/16/20 10:41 AM, Peter Maydell wrote:
>> > Add a documentation comment for qemu_get_thread_id(): since this
>> > is rather host-OS-specific it's useful if people writing the
>> > implementation and people thinking of using the function know
>> > what the purpose and limitations are.
>> >
>> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> > ---
>> > Based on conversation with Dan on IRC, and prompted by the recent
>> > patch to add OpenBSD support.
>> >
>> > Q: should we document exactly what the thread-id value is for
>> > each host platform in the QMP documentation ? Somebody writing
>> > a management layer app should ideally not have to grovel through
>> > the application to figure out what they should do with the
>> > integer value they get back from query-cpus...
>> >
>> > include/qemu/osdep.h | 14 ++++++++++++++
>> > 1 file changed, 14 insertions(+)
>>
>> Do we need a counterpart change...
>>
>> >
>> > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
>> > index 4841b5c6b5f..8279f72e5ed 100644
>> > --- a/include/qemu/osdep.h
>> > +++ b/include/qemu/osdep.h
>> > @@ -515,6 +515,20 @@ bool qemu_has_ofd_lock(void);
>> >
>> > bool qemu_write_pidfile(const char *pidfile, Error **errp);
>> >
>> > +/**
>> > + * qemu_get_thread_id: Return OS-specific ID of current thread
>> > + *
>> > + * This function returns an OS-specific identifier of the
>> > + * current thread. This will be used for the "thread-id" field in
>> > + * the response to the QMP query-cpus and query-iothreads commands.
>>
>> ...to the qapi definition of query-cpus and query-iothreads?
>
> Well, that was my question above. Currently the QAPI documentation
> says absolutely nothing about what the thread-id values mean
> for any host OS (beyond "ID of the underlying host thread"), which
> means that any management layer application needs to look in the
> implementation to find out what they actually are...
... which they will have to do to actually use it for the purpose we
have in mind, namely:
>> > + * The intention is that a VM management layer application can then
>> > + * use it to tie specific QEMU vCPU and IO threads to specific host
>> > + * CPUs using whatever the host OS's CPU affinity setting API is.
>> > + * New implementations of this function for new host OSes should
>> > + * return the most sensible integer ID that works for that purpose.
>> > + *
>> > + * This function should not be used for anything else inside QEMU.
>> > + */
Do they?
> Improving the QAPI docs would probably be something like:
> * add a list of host OSes and semantics to the doc comment
> for CpuInfoFast
> * add cross-references to that definition from everywhere
> else in QAPI that uses a thread-id/thread_id
> * add a comment in the C file to say "if you're adding another
> OS ifdef here please update the QAPI doc comment"
If they do, then this sounds like a plan.
By the way, the #else case smells:
#else
return getpid();
#endif
The PID is quite unlikely to be "an OS-specific identifier of the
current thread". Shouldn't we fail instead of lie when we don't know
how to compute the truth?
next prev parent reply other threads:[~2020-07-30 15:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 15:41 [PATCH] osdep.h: Add doc comment for qemu_get_thread_id() Peter Maydell
2020-07-28 15:02 ` Peter Maydell
2020-07-28 15:02 ` Peter Maydell
2020-07-28 15:16 ` Eric Blake
2020-07-28 15:25 ` Peter Maydell
2020-07-28 15:25 ` Peter Maydell
2020-07-30 15:10 ` Markus Armbruster [this message]
2020-07-30 15:10 ` Markus Armbruster
2020-07-30 15:52 ` Peter Maydell
2020-07-30 15:52 ` Peter Maydell
2020-07-30 15:59 ` Daniel P. Berrangé
2020-07-30 15:59 ` Daniel P. Berrangé
2020-07-30 16:24 ` Eric Blake
2020-07-30 16:24 ` Eric Blake
2020-07-30 16:40 ` Daniel P. Berrangé
2020-07-30 16:40 ` Daniel P. Berrangé
2020-07-31 7:44 ` Markus Armbruster
2020-07-31 7:44 ` Markus Armbruster
2020-07-31 13:46 ` Eric Blake
2020-07-31 13:46 ` Eric Blake
2020-07-31 13:51 ` Daniel P. Berrangé
2020-07-31 13:51 ` Daniel P. Berrangé
-- strict thread matches above, loose matches on Subject: below --
2020-10-12 15:33 [PATCH 00/10] target/arm: Various v8.1M minor features Peter Maydell
2020-10-12 15:33 ` [PATCH] osdep.h: Add doc comment for qemu_get_thread_id() Peter Maydell
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=87k0ylvy0t.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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.