From: Juan Quintela <quintela@redhat.com>
To: "manish.mishra" <manish.mishra@nutanix.com>
Cc: qemu-devel@nongnu.org, berrange@redhat.com, peterx@redhat.com,
dgilbert@redhat.com, lsoaresp@redhat.com
Subject: Re: [PATCH] multifd: Avoid busy-wait in multifd_send_pages()
Date: Wed, 26 Apr 2023 14:05:49 +0200 [thread overview]
Message-ID: <87leieg86a.fsf@secure.mitica> (raw)
In-Reply-To: <82cfd4b3-fbea-b147-e84a-d8d160088c14@nutanix.com> (manish mishra's message of "Wed, 26 Apr 2023 16:56:58 +0530")
"manish.mishra" <manish.mishra@nutanix.com> wrote:
> On 26/04/23 4:35 pm, Juan Quintela wrote:
>> "manish.mishra" <manish.mishra@nutanix.com> wrote:
>>> On 26/04/23 3:58 pm, Juan Quintela wrote:
>> Before:
>>
>> while (true) {
>> ....
>> sem_post(channels_ready)
>> }
>>
>> And you want to add to the initialization a counter equal to the number
>> of channels.
>>
>> Now:
>>
>> while (true) {
>> sem_post(channels_ready)
>> ....
>> }
>>
>> It is semantically the same, but when we setup it ready it means that
>> when we set it to 1, we now that the channel and thread are ready for
>> action.
>>
>>> May be we can do one thing let the sem_post in while loop at same
>>> position itself. But we can do another post just before start
>> I can see how this can make any difference.
>>
>>
>>> of this while loop, as that will be called only once it should do work
>>> of initialising count equal to multiFD channels?
>> Yeap. But I can see what difference do we have here.
>>
>> Later, Juan.
>>
>
> Thanks Juan,
> Just confirming if i misunderstood something :)
>
> I meant your approach makes sense, i was just suggesting a small change. To do something like this.
>
> qemu_sem_init(&multifd_send_state->channels_ready, 0);
>
> static void *multifd_send_thread(void *opaque) {
> ...
>
> sem_post(channels_ready); // Post once at start of thread and let one in loop as it is.
>
> while (true) {
> ....
> sem_post(channels_ready)
> }
> }
>
>
> Something like below has issue that we are marking channel_ready even
> before channel is actually ready,
I think it is exactly the same.
> i meant if network is slow it may
> take some time to update pending_job and hence we can busy loop in
> send_multifd_page().
No difference from send_multifd_page() point of view.
Notice that I mank that the channel is ready before I do any work.
send_multifd_page() does a sem_wait() before doing anything related to
this channel, so I can't see how it can be a differnce.
> static void *multifd_send_thread(void *opaque) {
> ...
>
> while (true) {
> sem_post(channels_ready);
> ....
> }
> }
>
>
> Not sure if we are already in agreement :) just confirming.
> sem_post(channels_ready); // Post once at start of thread and let one in loop as it is.
> while (true) {
> ...
> sem_post(channels_ready)
> }
and
> while (true) {
> sem_post(channels_ready)
> ...
> }
When "..." is exactly the same don't make any difference, the only
difference is that in one case we "write" to semposts, and in the other
we write just one.
Or I am missing something.
Later, Juan.
next prev parent reply other threads:[~2023-04-26 12:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 16:05 [PATCH] multifd: Avoid busy-wait in multifd_send_pages() manish.mishra
2023-04-26 10:28 ` Juan Quintela
2023-04-26 10:39 ` manish.mishra
2023-04-26 11:05 ` Juan Quintela
2023-04-26 11:26 ` manish.mishra
2023-04-26 12:05 ` Juan Quintela [this message]
2023-04-26 12:38 ` manish.mishra
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=87leieg86a.fsf@secure.mitica \
--to=quintela@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lsoaresp@redhat.com \
--cc=manish.mishra@nutanix.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 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).