scsi: Optimize scsi_req_alloc
commit61e68b3fbd3e2b7beb636bc56f78d9c1ca25e8f9
authorFam Zheng <famz@redhat.com>
Tue, 16 Sep 2014 07:20:17 +0000 (16 15:20 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Sep 2014 13:40:51 +0000 (23 15:40 +0200)
tree94312f417d4022a681392b1526c590a18924ceb2
parent380f649e02f9545159dc3158d7c1b2e70c1005e3
scsi: Optimize scsi_req_alloc

Zeroing sense buffer for each scsi request is not efficient, we can just
leave it uninitialized because sense_len is set to 0.

Move the implicitly zeroed fields to the end of the structure and use a
partial memset.

The explicitly initialized fields (by scsi_req_alloc or scsi_req_new)
are moved to the beginning of the structure, before sense buffer, to
skip the memset.

Also change g_malloc0 to g_slice_alloc.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/scsi-bus.c
include/hw/scsi/scsi.h