* [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events
@ 2012-05-25 10:25 Ronnie Sahlberg
2012-05-25 10:25 ` [Qemu-devel] [PATCH] ISCSI: redo how we set up the events to only call qemu_aio_set_fd_handler() and qemu_notify_event() if something has changed Ronnie Sahlberg
2012-05-25 11:12 ` [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: Ronnie Sahlberg @ 2012-05-25 10:25 UTC (permalink / raw)
To: pbonzini, qemu-devel
Paolo,
Please find an updated patch that implements your suggestion.
This patch updates how iscsi sets up the read and write events so that we only call qemu_aio_set_fd_handler() and qemu_notify_event() when we actually need to.
regards
ronnie sahlberg
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH] ISCSI: redo how we set up the events to only call qemu_aio_set_fd_handler() and qemu_notify_event() if something has changed.
2012-05-25 10:25 [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events Ronnie Sahlberg
@ 2012-05-25 10:25 ` Ronnie Sahlberg
2012-05-25 11:12 ` [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Ronnie Sahlberg @ 2012-05-25 10:25 UTC (permalink / raw)
To: pbonzini, qemu-devel; +Cc: Ronnie Sahlberg
Also first call out to the socket write functions director, and only set up the write event if the socket is full.
This means that we will only need to invoke these two functions very rarely which will improve performance.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
---
block/iscsi.c | 37 +++++++++++++++++++++++++++----------
1 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index ed1ad7b..d710b86 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -40,6 +40,7 @@ typedef struct IscsiLun {
int lun;
int block_size;
unsigned long num_blocks;
+ int events;
} IscsiLun;
typedef struct IscsiAIOCB {
@@ -105,18 +106,34 @@ static void
iscsi_set_events(IscsiLun *iscsilun)
{
struct iscsi_context *iscsi = iscsilun->iscsi;
+ int ev;
- qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read,
- (iscsi_which_events(iscsi) & POLLOUT)
- ? iscsi_process_write : NULL,
- iscsi_process_flush, iscsilun);
+ /* Try to write as much as we can to the socket
+ * without setting up an event
+ */
+ if (iscsi_which_events(iscsi) & POLLOUT) {
+ iscsi_process_write(iscsilun);
+ }
+
+ /* We always register a read handler. */
+ ev = POLLIN;
+ ev |= iscsi_which_events(iscsi);
+ if (ev != iscsilun->events) {
+ qemu_aio_set_fd_handler(iscsi_get_fd(iscsi),
+ iscsi_process_read,
+ (ev & POLLOUT) ? iscsi_process_write : NULL,
+ iscsi_process_flush,
+ iscsilun);
- /* If we just added the event for writeable we must call
- and the socket is already writeable the callback might
- not be invoked until after a short delay unless we call
- qemu_notify_event().
+ }
+
+ /* If we just added an event, the callback might be delayed
+ * unless we call qemu_notify_event().
*/
- qemu_notify_event();
+ if (ev & ~iscsilun->events) {
+ qemu_notify_event();
+ }
+ iscsilun->events = ev;
}
static void
--
1.7.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events
2012-05-25 10:25 [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events Ronnie Sahlberg
2012-05-25 10:25 ` [Qemu-devel] [PATCH] ISCSI: redo how we set up the events to only call qemu_aio_set_fd_handler() and qemu_notify_event() if something has changed Ronnie Sahlberg
@ 2012-05-25 11:12 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2012-05-25 11:12 UTC (permalink / raw)
To: Ronnie Sahlberg; +Cc: qemu-devel
Il 25/05/2012 12:25, Ronnie Sahlberg ha scritto:
> This patch updates how iscsi sets up the read and write events so
> that we only call qemu_aio_set_fd_handler() and qemu_notify_event()
> when we actually need to.
Applied, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-25 11:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-25 10:25 [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events Ronnie Sahlberg
2012-05-25 10:25 ` [Qemu-devel] [PATCH] ISCSI: redo how we set up the events to only call qemu_aio_set_fd_handler() and qemu_notify_event() if something has changed Ronnie Sahlberg
2012-05-25 11:12 ` [Qemu-devel] [PATCH 0/1] ISCSI: Optimize how we set up the events Paolo Bonzini
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).