[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 01/25] [virtio-9p] Add infrastructure to support
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 01/25] [virtio-9p] Add infrastructure to support glib threads and coroutines. |
Date: |
Fri, 13 May 2011 16:49:32 +0100 |
On Fri, May 13, 2011 at 4:47 PM, Venkateswararao Jujjuri
<address@hidden> wrote:
> On 05/12/2011 10:48 PM, Stefan Hajnoczi wrote:
>>
>> On Thu, May 12, 2011 at 9:57 PM, Venkateswararao Jujjuri (JV)
>> <address@hidden> wrote:
>>>
>>> +/* v9fs glib thread pool */
>>> +V9fsThPool v9fs_pool;
>>
>> This should be static and an init function in this file could perform
>> initialization. Right now the initialization is inlined in
>> virtio-9p-device.c.
>>
>>> +void v9fs_qemu_submit_request(V9fsRequest *req)
>>> +{
>>> + V9fsThPool *p =&v9fs_pool;
>>> +
>>> + req->done = 0;
>>> + p->requests = g_list_append(p->requests, req);
>>> + g_thread_pool_push(v9fs_pool.pool, req, NULL);
>>> +}
>>> +
>>> +void v9fs_qemu_process_req_done(void *arg)
>>> +{
>>> + struct V9fsThPool *p =&v9fs_pool;
>>> + char byte;
>>> + ssize_t len;
>>> + GList *cur_req, *next_req;
>>> +
>>> + do {
>>> + len = read(p->rfd,&byte, sizeof(byte));
>>> + } while (len == -1&& errno == EINTR);
>>> +
>>> + for (cur_req = p->requests; cur_req != NULL; cur_req = next_req) {
>>> + V9fsRequest *req = cur_req->data;
>>> + next_req = g_list_next(cur_req);
>>> +
>>> + if (!req->done) {
>>> + continue;
>>> + }
>>
>> The requests list is only used for completion, why not enqueue only
>> completed requests and get rid of the done field. Then this function
>> doesn't have to skip over in-flight requests.
>>
>>> + Coroutine *entry = req->coroutine;
>>> + qemu_coroutine_enter(entry, NULL);
>>> +
>>> + p->requests = g_list_delete_link(p->requests, cur_req);
>>
>> Does this actually free the req?
>>
>>> +static int notifier_fds[2];
>>
>> Why global?
>>
>>> + if (!g_thread_supported()) {
>>> + g_thread_init(NULL);
>>> + }
>>
>> The logic looks inverted. But if GThread isn't supported where in big
>> trouble so we should probably exit?
>>
> Name of the function is little weird .. it basically checking if the thread
> infrastructure
> is initialized or not. One can call g_thread_init() unconditionally.. but
> this may be good
> practice.
>
> http://developer.gnome.org/glib/2.28/glib-Threads.html#g-thread-supported
Thanks I was just checking it out and noticed they a function with a
clearer name since 2.20:
http://developer.gnome.org/glib/2.28/glib-Threads.html#g-thread-get-initialized
Stefan
- [Qemu-devel] [PATCH 04/25] [virtio-9p] clean up v9fs_readlink., (continued)
- [Qemu-devel] [PATCH 04/25] [virtio-9p] clean up v9fs_readlink., Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 02/25] [virtio-9p] Change all pdu handlers to coroutines., Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 06/25] [virtio-9p] coroutines for readlink, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 07/25] [virtio-9p] Remove post functions for v9fs_mkdir., Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 14/25] hw/9pfs: Update v9fs_getattr to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 12/25] hw/9pfs: Update v9fs_statfs to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 01/25] [virtio-9p] Add infrastructure to support glib threads and coroutines., Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 13/25] hw/9pfs: Add yield support to lstat coroutine, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 16/25] hw/9pfs: Update v9fs_setattr to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 10/25] hw/9pfs: Update v9fs_readdir to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 18/25] hw/9pfs: Update v9fs_xattrwalk to coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 09/25] hw/9pfs: Add yield support for readdir related coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 19/25] hw/9pfs: Update v9fs_xattrcreate to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 17/25] hw/9pfs: Add yield support to xattr related coroutine, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 22/25] [virtio-9p] coroutine and threading for mkdir, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 20/25] hw/9pfs: Add yield support to mknod coroutine, Venkateswararao Jujjuri (JV), 2011/05/12
- [Qemu-devel] [PATCH 15/25] hw/9pfs: Add yield support to setattr related coroutines, Venkateswararao Jujjuri (JV), 2011/05/12