From: Gautham R Shenoy <ego@in.ibm.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Qemu-development List <qemu-devel@nongnu.org>,
Corentin Chary <corentin.chary@gmail.com>,
Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH V3 2/3] qemu: Generic asynchronous threading framework to offload tasks
Date: Thu, 10 Jun 2010 17:07:45 +0530 [thread overview]
Message-ID: <20100610113745.GC11253@in.ibm.com> (raw)
In-Reply-To: <4C08FCA3.3020602@codemonkey.ws>
On Fri, Jun 04, 2010 at 08:16:19AM -0500, Anthony Liguori wrote:
>> --- /dev/null
>> +++ b/async-work.c
>> @@ -0,0 +1,136 @@
>> +/*
>> + * Async work support
>> + *
>> + * Copyright IBM, Corp. 2010
>> + *
>> + * Authors:
>> + * Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU GPL, version 2. See
>> + * the COPYING file in the top-level directory.
>>
>
> Please preserve the original copyright of the copied code.
Will update the comment containing the Copyright.
>
>> +
>> +struct work_item
>> +{
>> + QTAILQ_ENTRY(work_item) node;
>> + void (*func)(struct work_item *work);
>> + void *private;
>> +};
>>
>
> Structs are not named in accordance to CODING_STYLE.
Will fix this.
>
>> +static inline void async_queue_init(struct async_queue *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));
>> + QTAILQ_INIT(&(queue->work_item_pool));
>> + qemu_mutex_init(&(queue->lock));
>> + qemu_cond_init(&(queue->cond));
>> +}
>>
>
> I'd prefer there be a single queue that everything used verses multiple
> queues. Otherwise, we'll end up having per device queues and my concern is
> that we'll end up with thousands and thousands of threads with no central
> place to tune the maximum thread number.
Aah! So, the original idea was to have a single queue, but since we were
making it generic, we thought that the subsystems might like the
flexibility of having their own queue.
I suppose we are not looking to differentiate between the worker threads
belonging to different subsystems in terms of their relative
importance/priorities, right ?
>
>> +static inline struct work_item *async_work_init(struct async_queue *queue,
>> + void (*func)(struct work_item *),
>> + void *data)
>>
>
> I'd suggest actually using a Notifier as the worker or at least something
> that looks exactly like it. There's no need to pass a void * because more
> often than not, a caller just wants to pass a state structure anyway and
> they can embed the Notifier within the structure. IOW:
>
> async_work_submit(queue, &s->worker);
>
> Then in the callback:
>
> DeviceState *s = container_of(worker, DeviceState, worker);
>
> I don't think the name makes the most sense either. I think something like:
>
> threadlet_submit()
Makes sense. Will implement this.
>
> Would work best. It would be good for there to be a big comment warning
> that the routine does not run with the qemu_mutex and therefore cannot make
> use of any qemu functions without very special consideration.
>
>
> There shouldn't need to be an explicit init vs. submit function either.
Ok, will address these comments.
>
> Regards,
>
> Anthony Liguori
--
Thanks and Regards
gautham
next prev parent reply other threads:[~2010-06-10 11:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-03 8:56 [Qemu-devel] [PATCH V3 0/3] qemu: Make AIO threading framework generic Gautham R Shenoy
2010-06-03 8:56 ` [Qemu-devel] [PATCH V3 1/3] qemu: Add qemu-wrappers for pthread_attr_t Gautham R Shenoy
2010-06-03 12:31 ` [Qemu-devel] " Paolo Bonzini
2010-06-04 13:07 ` Anthony Liguori
2010-06-04 13:19 ` Corentin Chary
2010-06-04 13:27 ` Paolo Bonzini
2010-06-10 11:12 ` Gautham R Shenoy
2010-06-03 8:56 ` [Qemu-devel] [PATCH V3 2/3] qemu: Generic asynchronous threading framework to offload tasks Gautham R Shenoy
2010-06-03 11:41 ` [Qemu-devel] " Corentin Chary
2010-06-03 12:37 ` Paolo Bonzini
2010-06-04 13:16 ` [Qemu-devel] " Anthony Liguori
2010-06-05 7:03 ` Corentin Chary
2010-06-10 11:37 ` Gautham R Shenoy [this message]
2010-06-03 8:56 ` [Qemu-devel] [PATCH V3 3/3] qemu: Convert AIO code to use the generic threading infrastructure Gautham R Shenoy
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=20100610113745.GC11253@in.ibm.com \
--to=ego@in.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=corentin.chary@gmail.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).