From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: "Venkateswararao Jujjuri (JV)" <jvrao@linux.vnet.ibm.com>
Cc: Arun R Bharadwaj <arun@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] Introduce threadlets
Date: Wed, 20 Oct 2010 18:35:17 +0530 [thread overview]
Message-ID: <20101020130517.GR15844@balbir.in.ibm.com> (raw)
In-Reply-To: <4CBE661B.1010205@linux.vnet.ibm.com>
* Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com> [2010-10-19 20:46:35]:
> >> I think this is a lot more fragile. You're relying on the fact that
> >> signal will not cause the signalled thread to actually awaken until
> >> we release the lock and doing work after signalling that the
> >> signalled thread needs to be completed before it wakes up.
> >>
> >> I think you're a lot more robust in the long term if you treat
> >> condition signalling as a hand off point because it makes the code a
> >> lot more explicit about what's happening.
> >>
> >
> > OK, here is a situation that can happen
> >
> > T1 T2
> > --- ---
> > threadlet submit_threadletwork_to_queue
> > (sees condition as no work) mutex_lock
> > qemu_cond_timedwait add_work
> > ... mutex_unlock
> >
> > T3
> > --
> > cancel_threadlet_work_on_queue
> > mutex_lock (grabs it) before T1 can
> > cancels the work
> >
> >
> > qemu_cond_signal
> >
> > T1
> > --
> > Grabs mutex_lock (from within cond_timedwait)
> > Now there is no work to do, the condition
> > has changed before the thread wakes up
>
> So what? It won't find any work and goes back to sleep or exits.
>
Spurious wakeups are not good - they waste CPU cycles, consume energy.
Beyond that if we look at generic design
a. We want the thread condition to not change before it wakes up
(reduce that window at-least)
b. Although we don't care about thread priorities today in threadlet,
if we ever did and by good design you'd want the thread your waking up
to be contending for the mutex as soon the notifier releases the lock,
otherwise a lower priority thread can starve the original sleeper.
The code as posted today, does not have functional issues except for
opening up the window for spurious wakeups.
> idle_threads is decremented only in threadlet_worker(). Given that
> we have a threadlet that is not doing anywork the assert should never hit unless
> something horribly wrong .
>
--
Three Cheers,
Balbir
next prev parent reply other threads:[~2010-10-20 13:05 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 17:42 [Qemu-devel] v6: [PATCH 0/3]: Threadlets: A generic task offloading framework Arun R Bharadwaj
2010-10-19 17:42 ` [Qemu-devel] [PATCH 1/3] Introduce threadlets Arun R Bharadwaj
2010-10-19 18:36 ` Balbir Singh
2010-10-19 19:01 ` [Qemu-devel] " Paolo Bonzini
2010-10-19 19:12 ` Balbir Singh
2010-10-19 19:29 ` Paolo Bonzini
2010-10-19 21:00 ` [Qemu-devel] " Venkateswararao Jujjuri (JV)
2010-10-20 2:26 ` Balbir Singh
2010-10-19 21:36 ` Anthony Liguori
2010-10-20 2:22 ` Balbir Singh
2010-10-20 3:46 ` Venkateswararao Jujjuri (JV)
2010-10-20 13:05 ` Balbir Singh [this message]
2010-10-20 13:13 ` Anthony Liguori
2010-10-20 3:19 ` Venkateswararao Jujjuri (JV)
2010-10-20 8:16 ` Stefan Hajnoczi
2010-10-19 17:43 ` [Qemu-devel] [PATCH 2/3] Make paio subsystem use threadlets Arun R Bharadwaj
2010-10-20 2:24 ` Balbir Singh
2010-10-20 8:42 ` Kevin Wolf
2010-10-20 9:30 ` Stefan Hajnoczi
2010-10-20 13:16 ` Anthony Liguori
2010-10-21 8:40 ` Arun R Bharadwaj
2010-10-21 9:17 ` Stefan Hajnoczi
2010-10-19 17:43 ` [Qemu-devel] [PATCH 3/3] Add helper functions for virtio-9p to " Arun R Bharadwaj
2010-10-20 11:19 ` Stefan Hajnoczi
2010-10-20 13:17 ` Anthony Liguori
2010-10-20 11:57 ` [Qemu-devel] v6: [PATCH 0/3]: Threadlets: A generic task offloading framework Amit Shah
2010-10-20 12:05 ` Stefan Hajnoczi
2010-10-20 13:18 ` Anthony Liguori
2010-10-22 9:59 ` Amit Shah
2010-10-23 12:05 ` Stefan Hajnoczi
2010-10-27 7:57 ` Amit Shah
2010-10-27 8:37 ` Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2010-10-26 14:14 [Qemu-devel] v8: [PATCH 0/3] " Arun R Bharadwaj
2010-10-26 14:14 ` [Qemu-devel] [PATCH 1/3] Introduce threadlets Arun R Bharadwaj
2010-10-26 19:31 ` Blue Swirl
2010-11-01 13:40 ` Anthony Liguori
2010-11-05 6:48 ` Arun R Bharadwaj
2010-10-21 12:10 [Qemu-devel] [PATCH 0/3]: v7: Threadlets: A generic task offloading framework Arun R Bharadwaj
2010-10-21 12:10 ` [Qemu-devel] [PATCH 1/3] Introduce threadlets Arun R Bharadwaj
2010-10-22 7:02 ` Balbir Singh
2010-10-13 16:44 [Qemu-devel] [PATCH 0/3]: Threadlets: A generic task offloading framework Arun R Bharadwaj
2010-10-13 16:47 ` [Qemu-devel] [PATCH 1/3]: Introduce threadlets Arun R Bharadwaj
2010-10-13 15:30 [Qemu-devel] v5 [PATCH 0/3] qemu: Threadlets: A generic task offloading framework Arun R Bharadwaj
2010-10-13 15:31 ` [Qemu-devel] [PATCH 1/3] Introduce threadlets Arun R Bharadwaj
2010-10-14 9:02 ` Stefan Hajnoczi
2010-10-14 21:17 ` Venkateswararao Jujjuri (JV)
2010-10-15 9:52 ` Stefan Hajnoczi
2010-10-15 14:56 ` Venkateswararao Jujjuri (JV)
2010-10-14 9:15 ` Stefan Hajnoczi
2010-10-14 9:19 ` Gleb Natapov
2010-10-14 16:16 ` Avi Kivity
2010-10-14 21:32 ` Venkateswararao Jujjuri (JV)
2010-10-17 8:57 ` Avi Kivity
2010-10-18 10:47 ` Arun R Bharadwaj
2010-10-18 12:29 ` Avi Kivity
2010-10-15 8:05 ` Stefan Hajnoczi
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=20101020130517.GR15844@balbir.in.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=arun@linux.vnet.ibm.com \
--cc=jvrao@linux.vnet.ibm.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).