summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Christie <michael.christie@oracle.com>2024-12-03 13:15:09 -0600
committerMichael S. Tsirkin <mst@redhat.com>2025-02-25 07:10:46 -0500
commitbf2d650391be508dd8b5e188b65ed32300cf3489 (patch)
tree7ab3a6e11e947477dd4989b05e175a8c0d3f2cbd
parent4c1f3a7d74277903b290dd989cbd2ea8627fc925 (diff)
downloadlinux-bf2d650391be508dd8b5e188b65ed32300cf3489.tar.gz
linux-bf2d650391be508dd8b5e188b65ed32300cf3489.tar.bz2
linux-bf2d650391be508dd8b5e188b65ed32300cf3489.zip
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>
-rw-r--r--drivers/vhost/scsi.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index c266171045c5..e361c43d0730 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1651,12 +1651,14 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds)
goto out;
}
- tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
- sizeof(struct scatterlist),
- GFP_KERNEL);
- if (!tv_cmd->tvc_prot_sgl) {
- pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
- goto out;
+ if (vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI)) {
+ tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
+ sizeof(struct scatterlist),
+ GFP_KERNEL);
+ if (!tv_cmd->tvc_prot_sgl) {
+ pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
+ goto out;
+ }
}
}
return 0;