From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] Introduce threadlets
Date: Fri, 5 Nov 2010 12:18:35 +0530 [thread overview]
Message-ID: <20101105064835.GA12364@linux.vnet.ibm.com> (raw)
In-Reply-To: <4CCEC354.7090300@codemonkey.ws>
* Anthony Liguori <anthony@codemonkey.ws> [2010-11-01 08:40:36]:
> On 10/26/2010 09:14 AM, Arun R Bharadwaj wrote:
> >+Q.7: Apart from the global pool of threads, can I have my own private Queue ?
> >+A.7: Yes, the threadlets framework allows subsystems to create their own private
> >+ queues with associated pools of threads.
> >+
> >+ - Define a PrivateQueue
> >+ ThreadletQueue myQueue;
> >+
> >+ - Initialize it:
> >+ threadlet_queue_init(&myQueue, my_max_threads, my_min_threads);
> >+ where my_max_threads is the maximum number of threads that can be in the
> >+ thread pool and my_min_threads is the minimum number of active threads
> >+ that can be in the thread-pool.
> >+
> >+ - Submit work:
> >+ submit_threadletwork_to_queue(&myQueue,&my_work);
> >+
> >+ - Cancel work:
> >+ cancel_threadletwork_on_queue(&myQueue,&my_work);
> >diff --git a/qemu-threadlets.c b/qemu-threadlets.c
> >new file mode 100644
> >index 0000000..8fc3be0
> >--- /dev/null
> >+++ b/qemu-threadlets.c
> >@@ -0,0 +1,167 @@
> >+/*
> >+ * Threadlet support for offloading tasks to be executed asynchronously
> >+ *
> >+ * Copyright IBM, Corp. 2008
> >+ * Copyright IBM, Corp. 2010
> >+ *
> >+ * Authors:
> >+ * Anthony Liguori<aliguori@us.ibm.com>
> >+ * Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
> >+ * Gautham R Shenoy<gautham.shenoy@gmail.com>
> >+ *
> >+ * This work is licensed under the terms of the GNU GPL, version 2. See
> >+ * the COPYING file in the top-level directory.
> >+ */
> >+
> >+#include "qemu-threadlets.h"
> >+#include "osdep.h"
> >+
> >+#define MAX_GLOBAL_THREADS 64
> >+#define MIN_GLOBAL_THREADS 64
> >+static ThreadletQueue globalqueue;
> >+static int globalqueue_init;
> >+
> >+static void *threadlet_worker(void *data)
> >+{
> >+ ThreadletQueue *queue = data;
> >+
> >+ qemu_mutex_lock(&(queue->lock));
>
> The use of parens here is unnecessary and unusual within the code
> base. I'd prefer that they be dropped.
>
> >+ while (1) {
> >+ ThreadletWork *work;
> >+ int ret = 0;
> >+
> >+ while (QTAILQ_EMPTY(&(queue->request_list))&&
> >+ (ret != ETIMEDOUT)) {
> >+ /* wait for cond to be signalled or broadcast for 1000s */
> >+ ret = qemu_cond_timedwait(&(queue->cond),
> >+ &(queue->lock), 10*100000);
> >+ }
> >+
> >+ assert(queue->idle_threads != 0);
> >+ if (QTAILQ_EMPTY(&(queue->request_list))) {
> >+ if (queue->cur_threads> queue->min_threads) {
> >+ /* We retain the minimum number of threads */
> >+ break;
>
> You set MIN_GLOBAL_THREADS to MAX_GLOBAL_THREADS which makes this
> dead code. Why are you forcing the thread pool to remain a fixed
> size?+/**
>
> >+ * submit_threadletwork: Submit to the global queue a new task to be executed
> >+ * asynchronously.
> >+ * @work: Contains information about the task that needs to be submitted.
> >+ */
> >+void submit_threadletwork(ThreadletWork *work)
> >+{
> >+ if (unlikely(!globalqueue_init)) {
>
> Why have this unlikely?
>
> >+/**
> >+ * deque_threadletwork: Cancel a task queued on the global queue.
> >+ * @work: Contains the information of the task that needs to be cancelled.
> >+ *
> >+ * Returns: 0 if the task is successfully cancelled.
> >+ * 1 otherwise.
> >+ */
> >+int deque_threadletwork(ThreadletWork *work)
> >+{
> >+ return deque_threadletwork_on_queue(&globalqueue, work);
> >+}
>
> I really struggle with the use of namespaces here.
>
> Wouldn't threadletwork_deque make more sense? And I think dequeue
> is the proper spelling.
>
> threadletwork is too long of a name too.
>
> >+/**
> >+ * threadlet_queue_init: Initialize a threadlet queue.
> >+ * @queue: The threadlet queue to be initialized.
> >+ * @max_threads: Maximum number of threads processing the queue.
> >+ * @min_threads: Minimum number of threads processing the queue.
> >+ */
> >+void threadlet_queue_init(ThreadletQueue *queue,
> >+ int max_threads, int min_threads)
> >+{
> >+ queue->cur_threads = 0;
> >+ queue->idle_threads = 0;
> >+ queue->max_threads = max_threads;
> >+ queue->min_threads = min_threads;
> >+ QTAILQ_INIT(&(queue->request_list));
> >+ qemu_mutex_init(&(queue->lock));
> >+ qemu_cond_init(&(queue->cond));
> >+}
>
> It's unclear to me why we need to have multiple threadlet pools.
> Why not just have a single global threadlet pool?
>
According to Gautham's original patchset, there is a global threadlet
pool and also a private threadlet pool which any subsystem can
declare. I have just retained the same design. This is described in
the documentation file.
-arun
> Regards,
>
> Anthony Liguori
>
next prev parent reply other threads:[~2010-11-05 6:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-26 14:14 [Qemu-devel] v8: [PATCH 0/3] Threadlets: A generic task offloading framework 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 [this message]
2010-10-26 14:14 ` [Qemu-devel] [PATCH 2/3] Make paio subsystem use threadlets Arun R Bharadwaj
2010-10-27 9:17 ` Stefan Hajnoczi
2010-10-26 14:14 ` [Qemu-devel] [PATCH 3/3] Add helper functions to enable virtio-9p make use of the threadlets Arun R Bharadwaj
-- strict thread matches above, loose matches on Subject: below --
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-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 21:00 ` 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
2010-10-20 13:13 ` Anthony Liguori
2010-10-20 3:19 ` Venkateswararao Jujjuri (JV)
2010-10-20 8:16 ` Stefan Hajnoczi
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=20101105064835.GA12364@linux.vnet.ibm.com \
--to=arun@linux.vnet.ibm.com \
--cc=anthony@codemonkey.ws \
--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).