On 02/06/2014 04:11 PM, Nicholas A. Bellinger wrote: >> +struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev) >> > +{ >> > + struct Scsi_Host *shost = sdev->host; >> > + struct blk_mq_hw_ctx *hctx; >> > + struct request_queue *q; >> > + struct request *rq; >> > + struct scsi_cmnd *cmd; >> > + struct blk_mq_reg reg; >> > + int i, j, sgl_size; >> > + >> > + memset(®, 0, sizeof(reg)); >> > + reg.ops = &scsi_mq_ops; >> > + reg.queue_depth = shost->cmd_per_lun; >> > + if (!reg.queue_depth) >> > + reg.queue_depth = 1; >> > + >> > + /* XXX: what to do about chained S/G lists? */ >> > + if (shost->hostt->sg_tablesize > SCSI_MAX_SG_SEGMENTS) >> > + shost->sg_tablesize = SCSI_MAX_SG_SEGMENTS; >> > + sgl_size = shost->sg_tablesize * sizeof(struct scatterlist); >> > + >> > + reg.cmd_size = sizeof(struct scsi_cmnd) + >> > + sgl_size + >> > + shost->hostt->cmd_size; >> > + if (scsi_host_get_prot(shost)) >> > + reg.cmd_size += sizeof(struct scsi_data_buffer) + sgl_size; > OK, so your in-lining the allocation of data + protection SGLs from > blk-mq.. > > The original prototype code was doing these allocations separately below > for each pre-allocated cmd, and offering LLD's to optionally > pre-allocate their own descripts using sh->hostt->cmd_size if > necessary.. > > This was necessary to eliminate all fast-path allocations for > virtio-scsi, and I'd like to see something similar here as an optional > feature as well. Yeah, it would be nice if like in Nick's patches, the driver could just set the scsi_host_template->cmd_size then when the scsi_cmnd got to the driver's queuecommand, the driver could just get its internal cmd struct from the scsi_cmnd struct (for example in Nick's patch it was off the SCp.ptr). I started converting my iscsi mq patch from Nick's code to Christoph's and am currently trying to figure out how to setup the scsi_host_template->cmd_pool. Current iscsi patch is attached if anyone cares. However, one question I had with both approaches is how to deal with per cmd pci/dma memory and preallocations.