Skip to content

Commit bf2d650

Browse files
mikechristiemstsirkin
authored andcommitted
vhost-scsi: Allocate T10 PI structs only when enabled
T10 PI is not a widely used feature. This has us only allocate the structs for it if the feature has been enabled. For a common small setup where you have 1 virtqueue and 128 commands per queue, this saves: 8MB = 32 bytes per sg * 2048 entries * 128 commands per vhost-scsi device. Signed-off-by: Mike Christie <michael.christie@oracle.com> Message-Id: <20241203191705.19431-3-michael.christie@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1 parent 4c1f3a7 commit bf2d650

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/vhost/scsi.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,12 +1651,14 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds)
16511651
goto out;
16521652
}
16531653

1654-
tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
1655-
sizeof(struct scatterlist),
1656-
GFP_KERNEL);
1657-
if (!tv_cmd->tvc_prot_sgl) {
1658-
pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
1659-
goto out;
1654+
if (vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI)) {
1655+
tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
1656+
sizeof(struct scatterlist),
1657+
GFP_KERNEL);
1658+
if (!tv_cmd->tvc_prot_sgl) {
1659+
pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
1660+
goto out;
1661+
}
16601662
}
16611663
}
16621664
return 0;

0 commit comments

Comments
 (0)